diff options
author | Robert Schuster <theBohemian@gmx.net> | 2006-05-15 15:42:47 +0000 |
---|---|---|
committer | Robert Schuster <theBohemian@gmx.net> | 2006-05-15 15:42:47 +0000 |
commit | dafab8249fbf6ee69d854f2d66faec1bcc94af2c (patch) | |
tree | 537e38228211d86683b90b68e6f84ee2ac6b6bb0 | |
parent | e83a5c02b456119ff558d6ce32932da429211a6c (diff) | |
download | classpath-dafab8249fbf6ee69d854f2d66faec1bcc94af2c.tar.gz |
2006-05-15 Robert Schuster <robertschuster@fsfe.org>
Fixes PR 27197.
* javax/swing/text/FieldView.java:
(paint): Calculate intersection between clip and allocation area and
set that as new clip.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | javax/swing/text/FieldView.java | 24 |
2 files changed, 28 insertions, 3 deletions
@@ -1,3 +1,10 @@ +2006-05-15 Robert Schuster <robertschuster@fsfe.org> + + Fixes PR 27197. + * javax/swing/text/FieldView.java: + (paint): Calculate intersection between clip and allocation area and + set that as new clip. + 2006-05-15 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/text/JTextComponent.java: Marked stub methods. diff --git a/javax/swing/text/FieldView.java b/javax/swing/text/FieldView.java index 0c2f0fef1..f41f90130 100644 --- a/javax/swing/text/FieldView.java +++ b/javax/swing/text/FieldView.java @@ -50,6 +50,7 @@ import java.awt.event.ActionListener; import javax.swing.BoundedRangeModel; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; @@ -241,12 +242,29 @@ public class FieldView extends PlainView Shape newAlloc = adjustAllocation(s); - // Set a clip to prevent drawing outside of the allocation area. - // TODO: Is there a better way to achieve this? Shape clip = g.getClip(); - g.setClip(s); + if (clip != null) + { + // Reason for this: The allocation area is always determined by the + // size of the component (and its insets) regardless of whether + // parts of the component are invisible or not (e.g. when the + // component is part of a JScrollPane and partly moved out of + // the user-visible range). However the clip of the Graphics + // instance may be adjusted properly to that condition but + // does not handle insets. By calculating the intersection + // we get the correct clip to paint the text in all cases. + Rectangle r = s.getBounds(); + Rectangle cb = clip.getBounds(); + SwingUtilities.computeIntersection(r.x, r.y, r.width, r.height, cb); + + g.setClip(cb); + } + else + g.setClip(s); + super.paint(g, newAlloc); g.setClip(clip); + } public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf) |