You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/09/10 22:06:53 UTC

svn commit: r995961 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk/skin: TextAreaSkin2.java TextAreaSkinParagraphView2.java

Author: gbrown
Date: Fri Sep 10 20:06:52 2010
New Revision: 995961

URL: http://svn.apache.org/viewvc?rev=995961&view=rev
Log:
TextAreaSkin2 fixes.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView2.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java?rev=995961&r1=995960&r2=995961&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java Fri Sep 10 20:06:52 2010
@@ -89,7 +89,8 @@ public class TextAreaSkin2 extends Compo
                     if (index != -1) {
                         // If the next character is a paragraph terminator, increment
                         // the selection
-                        if (textArea.getCharacterAt(index) == '\n') {
+                        if (index < textArea.getCharacterCount()
+                            && textArea.getCharacterAt(index) == '\n') {
                             index++;
                         }
 
@@ -1147,55 +1148,49 @@ public class TextAreaSkin2 extends Compo
     private void updateSelection() {
         TextArea2 textArea = (TextArea2)getComponent();
 
-        if (textArea.getCharacterCount() > 0) {
-            // Update the caret
-            int selectionStart = textArea.getSelectionStart();
-
-            Bounds leadingSelectionBounds = getCharacterBounds(selectionStart);
-            caret = leadingSelectionBounds.toRectangle();
-            caret.width = 1;
-
-            // Update the selection
-            int selectionLength = textArea.getSelectionLength();
-
-            if (selectionLength > 0) {
-                int selectionEnd = selectionStart + selectionLength - 1;
-                Bounds trailingSelectionBounds = getCharacterBounds(selectionEnd);
-                selection = new Area();
-
-                int firstRowIndex = getRowAt(selectionStart);
-                int lastRowIndex = getRowAt(selectionEnd);
-
-                if (firstRowIndex == lastRowIndex) {
-                    selection.add(new Area(new Rectangle(leadingSelectionBounds.x,
-                        leadingSelectionBounds.y, trailingSelectionBounds.x
-                            + trailingSelectionBounds.width - leadingSelectionBounds.x,
-                        trailingSelectionBounds.y + trailingSelectionBounds.height
-                            - leadingSelectionBounds.y)));
-                } else {
-                    int width = getWidth();
-
-                    selection.add(new Area(new Rectangle(leadingSelectionBounds.x,
-                        leadingSelectionBounds.y, width - margin.right - leadingSelectionBounds.x,
-                        leadingSelectionBounds.height)));
-
-                    if (lastRowIndex - firstRowIndex > 0) {
-                        selection.add(new Area(new Rectangle(margin.left, leadingSelectionBounds.y
-                            + leadingSelectionBounds.height, width - (margin.left + margin.right),
-                            trailingSelectionBounds.y
-                                - (leadingSelectionBounds.y + leadingSelectionBounds.height))));
-                    }
+        // Update the caret
+        int selectionStart = textArea.getSelectionStart();
 
-                    selection.add(new Area(new Rectangle(margin.left, trailingSelectionBounds.y,
-                        trailingSelectionBounds.x + trailingSelectionBounds.width - margin.left,
-                        trailingSelectionBounds.height)));
-                }
+        Bounds leadingSelectionBounds = getCharacterBounds(selectionStart);
+        caret = leadingSelectionBounds.toRectangle();
+        caret.width = 1;
+
+        // Update the selection
+        int selectionLength = textArea.getSelectionLength();
+
+        if (selectionLength > 0) {
+            int selectionEnd = selectionStart + selectionLength - 1;
+            Bounds trailingSelectionBounds = getCharacterBounds(selectionEnd);
+            selection = new Area();
+
+            int firstRowIndex = getRowAt(selectionStart);
+            int lastRowIndex = getRowAt(selectionEnd);
+
+            if (firstRowIndex == lastRowIndex) {
+                selection.add(new Area(new Rectangle(leadingSelectionBounds.x,
+                    leadingSelectionBounds.y, trailingSelectionBounds.x
+                        + trailingSelectionBounds.width - leadingSelectionBounds.x,
+                    trailingSelectionBounds.y + trailingSelectionBounds.height
+                        - leadingSelectionBounds.y)));
             } else {
-                selection = null;
+                int width = getWidth();
+
+                selection.add(new Area(new Rectangle(leadingSelectionBounds.x,
+                    leadingSelectionBounds.y, width - margin.right - leadingSelectionBounds.x,
+                    leadingSelectionBounds.height)));
+
+                if (lastRowIndex - firstRowIndex > 0) {
+                    selection.add(new Area(new Rectangle(margin.left, leadingSelectionBounds.y
+                        + leadingSelectionBounds.height, width - (margin.left + margin.right),
+                        trailingSelectionBounds.y
+                            - (leadingSelectionBounds.y + leadingSelectionBounds.height))));
+                }
+
+                selection.add(new Area(new Rectangle(margin.left, trailingSelectionBounds.y,
+                    trailingSelectionBounds.x + trailingSelectionBounds.width - margin.left,
+                    trailingSelectionBounds.height)));
             }
         } else {
-            // Clear the caret and the selection
-            caret = new Rectangle();
             selection = null;
         }
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView2.java?rev=995961&r1=995960&r2=995961&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView2.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkinParagraphView2.java Fri Sep 10 20:06:52 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.pivot.wtk.skin;
 
-import java.awt.Color;
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
@@ -128,9 +127,6 @@ class TextAreaSkinParagraphView2 impleme
 
     @Override
     public void paint(Graphics2D graphics) {
-        graphics.setColor(Color.GREEN);
-        graphics.fillRect(0, 0, getWidth(), getHeight());
-
         TextArea2 textArea = (TextArea2)textAreaSkin.getComponent();
 
         int selectionStart = textArea.getSelectionStart();