diff options
author | David Jee <djee@redhat.com> | 2004-01-26 21:55:42 +0000 |
---|---|---|
committer | David Jee <djee@gcc.gnu.org> | 2004-01-26 21:55:42 +0000 |
commit | 7edbd87e17d9240077eed1993436365ad6c4365c (patch) | |
tree | 9ab7045766c5842438bf57c60f381f2d8dce8bb0 /libjava/java | |
parent | 81a88a6157451550a5753e436021523f93226fc9 (diff) | |
download | gcc-7edbd87e17d9240077eed1993436365ad6c4365c.zip gcc-7edbd87e17d9240077eed1993436365ad6c4365c.tar.gz gcc-7edbd87e17d9240077eed1993436365ad6c4365c.tar.bz2 |
2004-01-26 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(handleEvent): Implemented. Handles PaintEvents.
(paint): Implemented. Use GTK native methods to queue updates
for this heavyweight peer.
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(handleEvent): Removed.
* java/awt/Component.java
(paint): Implemented. Explictly paint the heavyweight peer.
(update): Clear the background for heavyweight components.
(paintAll): No need to call peer.paint() anymore.
(processEvent): Don't process PaintEvents here. It's now done in
the peer's handleEvent().
(processPaintEvent): Removed.
* java/awt/Container.java
(paint): No need to call super.paint(). Visit heavyweight
children as well.
(update): Don't clear the background here. It's done in
Component.update().
(visitChildren): Added check to not recurse into Containers.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(filter_expose_event_handler): New method. Filter unwanted
expose events while painting heavyweight peers.
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilter):
New method. Connect filter and block pre_event_handler.
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeFilter):
New method. Disconnect filter and unblock pre_event_handler.
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetQueueDrawArea):
New method. Invalidate and update given area.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(pre_event_handler): Add checks for unwanted expose events.
From-SVN: r76668
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/awt/Component.java | 52 | ||||
-rw-r--r-- | libjava/java/awt/Container.java | 16 |
2 files changed, 20 insertions, 48 deletions
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index b440c51..87c73b5 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -1702,6 +1702,9 @@ public abstract class Component */ public void paint(Graphics g) { + // Paint the heavyweight peer + if (!isLightweight() && peer != null) + peer.paint(g); } /** @@ -1719,6 +1722,15 @@ public abstract class Component */ public void update(Graphics g) { + if (!isLightweight()) + { + Rectangle clip = g.getClipBounds(); + if (clip == null) + g.clearRect(0, 0, width, height); + else + g.clearRect(clip.x, clip.y, clip.width, clip.height); + } + paint(g); } @@ -1732,8 +1744,6 @@ public abstract class Component { if (! visible) return; - if (peer != null) - peer.paint(g); paint(g); } @@ -2787,8 +2797,6 @@ public abstract class Component if (e instanceof FocusEvent) processFocusEvent((FocusEvent) e); - else if (e instanceof PaintEvent) - processPaintEvent((PaintEvent) e); else if (e instanceof MouseWheelEvent) processMouseWheelEvent((MouseWheelEvent) e); else if (e instanceof MouseEvent) @@ -4225,42 +4233,6 @@ p * <li>the set of backward traversal keys } /** - * Does the work for a paint event. - * - * @param event the event to process - */ - private void processPaintEvent(PaintEvent event) - { - // Can't do graphics without peer - if (peer == null) - return; - - Graphics gfx = getGraphics(); - try - { - Shape clip = event.getUpdateRect(); - gfx.setClip(clip); - - switch (event.id) - { - case PaintEvent.PAINT: - paint(gfx); - break; - case PaintEvent.UPDATE: - update(gfx); - break; - default: - throw new IllegalArgumentException("unknown paint event"); - } - event.consume (); - } - finally - { - gfx.dispose(); - } - } - - /** * This method is used to implement transferFocus(). CHILD is the child * making the request. This is overridden by Container; when called for an * ordinary component there is no child and so we always return null. diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java index 5d176be..57cd833 100644 --- a/libjava/java/awt/Container.java +++ b/libjava/java/awt/Container.java @@ -663,8 +663,9 @@ public class Container extends Component { if (!isShowing()) return; - super.paint(g); - visitChildren(g, GfxPaintVisitor.INSTANCE, true); + // Visit heavyweights as well, in case they were + // erased when we cleared the background for this container. + visitChildren(g, GfxPaintVisitor.INSTANCE, false); } /** @@ -678,11 +679,6 @@ public class Container extends Component */ public void update(Graphics g) { - Rectangle clip = g.getClipBounds(); - if (clip == null) - g.clearRect(0, 0, width, height); - else - g.clearRect(clip.x, clip.y, clip.width, clip.height); super.update(g); } @@ -1204,8 +1200,12 @@ public class Container extends Component for (int i = ncomponents - 1; i >= 0; --i) { Component comp = component[i]; + // If we're visiting heavyweights as well, + // don't recurse into Containers here. This avoids + // painting the same nested child multiple times. boolean applicable = comp.isVisible() - && (comp.isLightweight() || !lightweightOnly); + && (comp.isLightweight() + || !lightweightOnly && ! (comp instanceof Container)); if (applicable) visitChild(gfx, visitor, comp); |