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/03 00:36:35 UTC

svn commit: r992137 - in /pivot/trunk: core/src/org/apache/pivot/text/ wtk-terra/src/org/apache/pivot/wtk/skin/terra/

Author: gbrown
Date: Thu Sep  2 22:36:35 2010
New Revision: 992137

URL: http://svn.apache.org/viewvc?rev=992137&view=rev
Log:
Text updates.

Added:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextAreaSkin2.java
Modified:
    pivot/trunk/core/src/org/apache/pivot/text/CharSequenceCharacterIterator.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java

Modified: pivot/trunk/core/src/org/apache/pivot/text/CharSequenceCharacterIterator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/text/CharSequenceCharacterIterator.java?rev=992137&r1=992136&r2=992137&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/text/CharSequenceCharacterIterator.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/text/CharSequenceCharacterIterator.java Thu Sep  2 22:36:35 2010
@@ -25,7 +25,8 @@ public class CharSequenceCharacterIterat
     private CharSequence charSequence;
     private int beginIndex;
     private int endIndex;
-    private int index;
+
+    private int index = -1;
 
     public CharSequenceCharacterIterator(CharSequence charSequence) {
         this(charSequence, 0);
@@ -48,6 +49,10 @@ public class CharSequenceCharacterIterat
             endIndex = charSequence.length();
         }
 
+        if (beginIndex > endIndex) {
+            throw new IllegalArgumentException();
+        }
+
         if (beginIndex < 0
             || endIndex > charSequence.length()) {
             throw new IndexOutOfBoundsException();
@@ -62,7 +67,7 @@ public class CharSequenceCharacterIterat
         this.beginIndex = beginIndex;
         this.endIndex = endIndex;
 
-        index = 0;
+        setIndex(index);
     }
 
     @Override

Added: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextAreaSkin2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextAreaSkin2.java?rev=992137&view=auto
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextAreaSkin2.java (added)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextAreaSkin2.java Thu Sep  2 22:36:35 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.wtk.skin.terra;
+
+import org.apache.pivot.wtk.Theme;
+import org.apache.pivot.wtk.skin.TextAreaSkin2;
+
+/**
+ * Terra text area skin.
+ */
+public class TerraTextAreaSkin2 extends TextAreaSkin2 {
+    public TerraTextAreaSkin2() {
+        setColor(1);
+        setInactiveColor(7);
+        setSelectionColor(4);
+        setSelectionBackgroundColor(14);
+        setInactiveSelectionColor(1);
+        setInactiveSelectionBackgroundColor(9);
+    }
+
+    public final void setColor(int color) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setColor(theme.getColor(color));
+    }
+
+    public final void setInactiveColor(int inactiveColor) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setInactiveColor(theme.getColor(inactiveColor));
+    }
+
+    public final void setBackgroundColor(int backgroundColor) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setBackgroundColor(theme.getColor(backgroundColor));
+    }
+
+    public final void setSelectionColor(int backgroundColor) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setSelectionColor(theme.getColor(backgroundColor));
+    }
+
+    public final void setSelectionBackgroundColor(int backgroundColor) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setSelectionBackgroundColor(theme.getColor(backgroundColor));
+    }
+
+    public final void setInactiveSelectionColor(int backgroundColor) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setInactiveSelectionColor(theme.getColor(backgroundColor));
+    }
+
+    public final void setInactiveSelectionBackgroundColor(int backgroundColor) {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+        setInactiveSelectionBackgroundColor(theme.getColor(backgroundColor));
+    }
+}

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=992137&r1=992136&r2=992137&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Thu Sep  2 22:36:35 2010
@@ -29,7 +29,6 @@ import java.awt.font.GlyphVector;
 import java.awt.font.LineMetrics;
 import java.awt.geom.Area;
 import java.awt.geom.Rectangle2D;
-import java.text.CharacterIterator;
 
 import org.apache.pivot.collections.Dictionary;
 import org.apache.pivot.text.CharSequenceCharacterIterator;
@@ -229,18 +228,20 @@ public class TerraTextInputSkin extends 
 
         int n = textInput.getCharacterCount();
         if (n > 0) {
-            CharacterIterator ci;
+            CharSequence characters;
             if (textInput.isPassword()) {
                 StringBuilder passwordBuilder = new StringBuilder(n);
                 for (int i = 0; i < n; i++) {
                     passwordBuilder.append(BULLET);
                 }
 
-                ci = new CharSequenceCharacterIterator(passwordBuilder);
+                characters = passwordBuilder;
             } else {
-                ci = textInput.getCharacterIterator();
+                characters = textInput.getCharacters();
             }
 
+            CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);
+
             FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             glyphVector = font.createGlyphVector(fontRenderContext, ci);
 
@@ -445,11 +446,11 @@ public class TerraTextInputSkin extends 
         return offset;
     }
 
-    public Bounds getCharacterBounds(int offset) {
+    public Bounds getCharacterBounds(int index) {
         Bounds characterBounds = null;
 
         if (glyphVector != null) {
-            Shape glyphBounds = glyphVector.getGlyphLogicalBounds(offset);
+            Shape glyphBounds = glyphVector.getGlyphLogicalBounds(index);
             Rectangle2D glyphBounds2D = glyphBounds.getBounds2D();
 
             int x = (int)Math.floor(glyphBounds2D.getX()) + padding.left - scrollLeft + 1;

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java?rev=992137&r1=992136&r2=992137&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java Thu Sep  2 22:36:35 2010
@@ -77,6 +77,7 @@ import org.apache.pivot.wtk.TablePane;
 import org.apache.pivot.wtk.TableView;
 import org.apache.pivot.wtk.TableViewHeader;
 import org.apache.pivot.wtk.TextArea;
+import org.apache.pivot.wtk.TextArea2;
 import org.apache.pivot.wtk.TextInput;
 import org.apache.pivot.wtk.Theme;
 import org.apache.pivot.wtk.Tooltip;
@@ -146,6 +147,7 @@ public final class TerraTheme extends Th
         componentSkinMap.put(TableView.class, TerraTableViewSkin.class);
         componentSkinMap.put(TabPane.class, TerraTabPaneSkin.class);
         componentSkinMap.put(TextArea.class, TerraTextAreaSkin.class);
+        componentSkinMap.put(TextArea2.class, TerraTextAreaSkin2.class);
         componentSkinMap.put(TextInput.class, TerraTextInputSkin.class);
         componentSkinMap.put(Tooltip.class, TerraTooltipSkin.class);
         componentSkinMap.put(TreeView.class, TerraTreeViewSkin.class);