diff options
author | Roman Kennke <roman@kennke.org> | 2006-10-12 10:20:52 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-10-12 10:20:52 +0000 |
commit | 78f3ff1ab23d4344c4401f4153b3d301aa7d766a (patch) | |
tree | 974831b446188c3c499b991332a5f198a3fd8cb2 /javax/swing/JComponent.java | |
parent | e5306e02ad24faa819380d91a3a0e400062c4aab (diff) | |
download | classpath-78f3ff1ab23d4344c4401f4153b3d301aa7d766a.tar.gz |
2006-10-12 Roman Kennke <kennke@aicas.com>
* javax/swing/JComponent.java
(paintImmediately2): Added support for components which need
to force themselves as paint root.
(isPaintRoot): New method. This should be overridden by components
which need to force themselves as paint root.
* javax/swing/JViewport.java
(isPaintRoot): Overridden to force the viewport as paint root
when running in backingstore mode.
Diffstat (limited to 'javax/swing/JComponent.java')
-rw-r--r-- | javax/swing/JComponent.java | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java index 91bb5428f..f98f01fdf 100644 --- a/javax/swing/JComponent.java +++ b/javax/swing/JComponent.java @@ -2188,6 +2188,10 @@ public abstract class JComponent extends Container implements Serializable components.add(c); if (! onTop && jc != null && ! jc.isOptimizedDrawingEnabled()) { + // Indicates whether we reset the paint root to be the current + // component. + boolean updatePaintRoot = false; + // Check obscured state of the child. // Generally, we have 3 cases here: // 1. Not obscured. No need to paint from the parent. @@ -2195,23 +2199,32 @@ public abstract class JComponent extends Container implements Serializable // 3. Completely obscured. No need to paint anything. if (c != this) { - int count = c.getComponentCount(); - int i = 0; - for (; i < count && c.getComponent(i) != child; i++); + if (jc.isPaintRoot()) + updatePaintRoot = true; + else + { + int count = c.getComponentCount(); + int i = 0; + for (; i < count && c.getComponent(i) != child; i++); - if (jc.isCompletelyObscured(i, paintX, paintY, paintW, paintH)) - return; // No need to paint anything. - else if (jc.isPartiallyObscured(i, paintX, paintY, paintW, + if (jc.isCompletelyObscured(i, paintX, paintY, paintW, paintH)) - { - // Paint from parent. - paintRoot = jc; - pIndex = pCount; - offsX = 0; - offsY = 0; - haveBuffer = false; + return; // No need to paint anything. + else if (jc.isPartiallyObscured(i, paintX, paintY, paintW, + paintH)) + updatePaintRoot = true; + } } + if (updatePaintRoot) + { + // Paint from parent. + paintRoot = jc; + pIndex = pCount; + offsX = 0; + offsY = 0; + haveBuffer = false; + } } pCount++; // Check if component is double buffered. @@ -2257,8 +2270,7 @@ public abstract class JComponent extends Container implements Serializable // Actually trigger painting. if (haveBuffer) - paintRoot.paintDoubleBuffered(paintX, paintY, paintW, - paintH); + paintRoot.paintDoubleBuffered(paintX, paintY, paintW, paintH); else { Graphics g = paintRoot.getGraphics(); @@ -2303,6 +2315,19 @@ public abstract class JComponent extends Container implements Serializable } /** + * This returns true when a component needs to force itself as a paint + * origin. This is used for example in JViewport to make sure that it + * gets to update its backbuffer. + * + * @return true when a component needs to force itself as a paint + * origin + */ + boolean isPaintRoot() + { + return false; + } + + /** * Performs double buffered repainting. */ private void paintDoubleBuffered(int x, int y, int w, int h) |