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 2009/11/06 15:35:50 UTC
svn commit: r833412 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: skin/ skin/terra/ text/
Author: gbrown
Date: Fri Nov 6 14:35:50 2009
New Revision: 833412
URL: http://svn.apache.org/viewvc?rev=833412&view=rev
Log:
Various minor TextArea and TextInput updates.
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Node.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Fri Nov 6 14:35:50 2009
@@ -1479,7 +1479,7 @@
@Override
public void layout() {
if (documentView != null) {
- final TextArea textArea = (TextArea)getComponent();
+ TextArea textArea = (TextArea)getComponent();
int width = getWidth();
documentView.setBreakWidth(Math.max(width - (margin.left + margin.right), 0));
documentView.validate();
@@ -1487,7 +1487,9 @@
updateSelection();
caretX = caret.x;
- scrollCharacterToVisible(textArea.getSelectionStart());
+ if (textArea.isFocused()) {
+ scrollCharacterToVisible(textArea.getSelectionStart());
+ }
showCaret(textArea.isFocused()
&& textArea.getSelectionLength() == 0);
@@ -1536,13 +1538,11 @@
if (documentView == null) {
offset = -1;
} else {
- int height = getHeight();
-
x = Math.min(documentView.getWidth() - 1, Math.max(x - margin.left, 0));
if (y < margin.top) {
offset = documentView.getNextInsertionPoint(x, -1, Direction.FORWARD);
- } else if (y > height - margin.bottom - 1) {
+ } else if (y > documentView.getHeight() + margin.top) {
offset = documentView.getNextInsertionPoint(x, -1, Direction.BACKWARD);
} else {
offset = documentView.getInsertionPoint(x, y - margin.top);
@@ -2095,6 +2095,12 @@
offset = documentView.getCharacterCount() - 1;
}
+ // TODO This works, but it doesn't produce the "right" UE
+ char c = document.getCharacterAt(offset);
+ if (c == '\n') {
+ offset++;
+ }
+
textArea.setSelection(selectionStart, offset - selectionStart);
scrollCharacterToVisible(offset);
} else {
@@ -2164,8 +2170,13 @@
super.focusedChanged(component, obverseComponent);
TextArea textArea = (TextArea)getComponent();
- showCaret(textArea.isFocused()
- && textArea.getSelectionLength() == 0);
+ if (textArea.isFocused()
+ && textArea.getSelectionLength() == 0) {
+ scrollCharacterToVisible(textArea.getSelectionStart());
+ showCaret(true);
+ } else {
+ showCaret(false);
+ }
repaintComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java Fri Nov 6 14:35:50 2009
@@ -47,7 +47,7 @@
/**
* Terra calendar button skin.
- *
+ *
* TODO Calendar pass-through styles
*/
public class TerraCalendarButtonSkin extends CalendarButtonSkin {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Fri Nov 6 14:35:50 2009
@@ -259,7 +259,8 @@
} else {
// Scroll lead selection to visible
int selectionStart = textInput.getSelectionStart();
- if (selectionStart < n) {
+ if (selectionStart < n
+ && textInput.isFocused()) {
scrollCharacterToVisible(selectionStart);
}
}
@@ -1283,7 +1284,17 @@
}
}
- showCaret(textInput.getSelectionLength() == 0);
+ if (textInput.getSelectionLength() == 0) {
+ TextNode textNode = textInput.getTextNode();
+ int selectionStart = textInput.getSelectionStart();
+ if (selectionStart < textNode.getCharacterCount()) {
+ scrollCharacterToVisible(selectionStart);
+ }
+
+ showCaret(true);
+ } else {
+ showCaret(false);
+ }
} else {
// If focus was permanently transferred within this window,
// clear the selection
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java Fri Nov 6 14:35:50 2009
@@ -278,9 +278,9 @@
}
@Override
- public char getCharacter(int offset) {
+ public char getCharacterAt(int offset) {
Node node = getNodeAt(offset);
- return node.getCharacter(offset - node.getOffset());
+ return node.getCharacterAt(offset - node.getOffset());
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java Fri Nov 6 14:35:50 2009
@@ -128,7 +128,7 @@
}
@Override
- public char getCharacter(int offset) {
+ public char getCharacterAt(int offset) {
return 0x00;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Node.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Node.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Node.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Node.java Fri Nov 6 14:35:50 2009
@@ -160,7 +160,7 @@
*
* @param offset
*/
- public abstract char getCharacter(int offset);
+ public abstract char getCharacterAt(int offset);
/**
* Returns the number of characters in this node.
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Paragraph.java Fri Nov 6 14:35:50 2009
@@ -57,6 +57,18 @@
}
@Override
+ public char getCharacterAt(int offset) {
+ char c;
+ if (offset == getCharacterCount() - 1) {
+ c = '\n';
+ } else {
+ c = super.getCharacterAt(offset);
+ }
+
+ return c;
+ }
+
+ @Override
public int getCharacterCount() {
return super.getCharacterCount() + 1;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java?rev=833412&r1=833411&r2=833412&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java Fri Nov 6 14:35:50 2009
@@ -65,7 +65,7 @@
@Override
public char current() {
- return (index < endIndex) ? getCharacter(index) : DONE;
+ return (index < endIndex) ? getCharacterAt(index) : DONE;
}
@Override
@@ -183,7 +183,7 @@
}
@Override
- public char getCharacter(int index) {
+ public char getCharacterAt(int index) {
if (index < 0
|| index >= textBuilder.length()) {
throw new IndexOutOfBoundsException();