Changed license to Creative Commons Zero (CC0).
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / gui / textEditorComponent / TextEditComponent.java
index b7c633f..5f5602e 100755 (executable)
@@ -1,19 +1,17 @@
 /*
- * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko. 
+ * This project is released under Creative Commons Zero (CC0) license.
  *
+*
  */
 
 package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
-import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.gui.GuiComponent;
 import eu.svjatoslav.sixth.e3d.gui.TextPointer;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
+import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas.TextCanvas;
 
@@ -40,15 +38,15 @@ public class TextEditComponent extends GuiComponent implements ClipboardOwner {
     boolean repaintPage = false;
 
     public TextEditComponent(final Transform transform,
-                             final ViewContext viewContext, final Point2D size) {
-        super(transform, viewContext, size.to3D());
+                             final ViewPanel viewPanel, final Point2D size) {
+        super(transform, viewPanel, size.to3D());
 
         cursorLocation = new TextPointer(0, 0);
 
         // initialize visual panel
 
-        final int columns = (int) (size.x / TextCanvas.FONT_CHAR_WIDTH);
-        final int rows = (int) (size.y / TextCanvas.FONT_CHAR_HEIGHT);
+        final int columns = (int) (size.x / TextCanvas.FONT_CHAR_WIDTH_PIXELS);
+        final int rows = (int) (size.y / TextCanvas.FONT_CHAR_HEIGHT_PIXELS);
 
         textCanvas = new TextCanvas(new Transform(), new TextPointer(rows,
                 columns), Color.WHITE, colorConfig.normalBack);
@@ -249,8 +247,8 @@ public class TextEditComponent extends GuiComponent implements ClipboardOwner {
      * Parse key presses.
      */
     @Override
-    public void keyPressed(final KeyEvent event, final ViewContext viewContext) {
-        super.keyPressed(event, viewContext);
+    public boolean keyPressed(final KeyEvent event, final ViewPanel viewPanel) {
+        super.keyPressed(event, viewPanel);
 
         processKeyEvent(event);
 
@@ -259,6 +257,7 @@ public class TextEditComponent extends GuiComponent implements ClipboardOwner {
         checkCursorBoundaries();
 
         repaintWhatNeeded();
+        return true;
     }
 
     /**
@@ -360,7 +359,6 @@ public class TextEditComponent extends GuiComponent implements ClipboardOwner {
                 }
 
             cursorLocation.column = 0;
-            return;
         }
     }