Hi,
it seems that my latest patches made swing painting more sensible in
respect to clipping. This is indeed a good thing, since it can save
valuable painting time, with optimized components even better. However,
it uncovers some smaller bugs that are related to clipping. Like this
one.
There were two reasons why textfields haven't been painted correctly
after my fixes:
- the initial allocation for the views didn't respect the insets of the
text component, so the Graphics clip was initialized slightly off
- the damageLineInRange method in PlainView only caused the area of the
line repainted, that is still there, that means, if I have 'abcde' and
delete the 'e', then only the area of 'abcd' gets repainted, leaving
the 'e' there. I fixed this by causing the repaint call to cover the
whole width of the text component (== the whole line). If somebody has a
clever idea how to optimize this, then say so. I would not consider it
worth the effort though
2005-10-13 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/JTextComponent.java
(replaceSelection): Removed debug statement.
* javax/swing/text/PlainView.java
(updateDamage): Removed unnecessary repaint call.
(damageLineRange): Trigger repaint over the whole width of the
text component at the requested line range. Otherwise we might
not clear deleted text.
* javax/swing/plaf/basic/BasicTextUI.java
(DocumentHandler.changedUpdate): Use visibleEditorRect as
initial allocation.
(DocumentHandler.removeUpdate): Use visibleEditorRect as
initial allocation.
(DocumentHandler.insertUpdate): Use visibleEditorRect as
initial allocation.
(getVisibleEditorRect): If component width and height values are
invalid (==uninitialized), return a Rectangle of (0,0,0,0) instead
of null.
/Roman
Index: javax/swing/text/JTextComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/JTextComponent.java,v
retrieving revision 1.41
diff -u -r1.41 JTextComponent.java
--- javax/swing/text/JTextComponent.java 12 Oct 2005 12:19:55 -0000 1.41
+++ javax/swing/text/JTextComponent.java 13 Oct 2005 12:49:08 -0000
@@ -1420,7 +1420,6 @@
public synchronized void replaceSelection(String content)
{
- System.err.println("replaceSelection");
int dot = caret.getDot();
int mark = caret.getMark();
Index: javax/swing/text/PlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v
retrieving revision 1.20
diff -u -r1.20 PlainView.java
--- javax/swing/text/PlainView.java 12 Oct 2005 17:35:49 -0000 1.20
+++ javax/swing/text/PlainView.java 13 Oct 2005 12:49:09 -0000
@@ -421,8 +421,6 @@
maxLineLength = longestNewLength;
longestLine = longestNewLine;
}
- // Repaint the container
- ((JTextComponent)getContainer()).repaint();
}
/**
@@ -435,7 +433,7 @@
*/
public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f)
{
- updateDamage(changes, a, f);
+ updateDamage(changes, a, f);
}
/**
@@ -448,7 +446,7 @@
*/
public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f)
{
- updateDamage(changes, a, f);
+ updateDamage(changes, a, f);
}
/**
@@ -478,17 +476,17 @@
{
if (a == null)
return;
-
+
Rectangle rec0 = lineToRect(a, line0);
Rectangle rec1 = lineToRect(a, line1);
-
+
if (rec0 == null || rec1 == null)
// something went wrong, repaint the entire host to be safe
host.repaint();
else
{
Rectangle repaintRec = rec0.union(rec1);
- host.repaint(repaintRec.x, repaintRec.y, repaintRec.width,
+ host.repaint(0, repaintRec.y, host.getWidth(),
repaintRec.height);
}
}
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.45
diff -u -r1.45 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java 12 Oct 2005 12:10:00 -0000 1.45
+++ javax/swing/plaf/basic/BasicTextUI.java 13 Oct 2005 12:49:09 -0000
@@ -367,8 +367,7 @@
*/
public void changedUpdate(DocumentEvent ev)
{
- Dimension size = textComponent.getSize();
- rootView.changedUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ rootView.changedUpdate(ev, getVisibleEditorRect(),
rootView.getViewFactory());
}
@@ -379,8 +378,7 @@
*/
public void insertUpdate(DocumentEvent ev)
{
- Dimension size = textComponent.getSize();
- rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ rootView.insertUpdate(ev, getVisibleEditorRect(),
rootView.getViewFactory());
}
@@ -391,8 +389,7 @@
*/
public void removeUpdate(DocumentEvent ev)
{
- Dimension size = textComponent.getSize();
- rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ rootView.removeUpdate(ev, getVisibleEditorRect(),
rootView.getViewFactory());
}
}
@@ -1017,7 +1014,7 @@
int height = textComponent.getHeight();
if (width <= 0 || height <= 0)
- return null;
+ return new Rectangle(0, 0, 0, 0);
Insets insets = textComponent.getInsets();
return new Rectangle(insets.left, insets.top,
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches