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
This commit is contained in:
David Jee 2004-01-26 21:55:42 +00:00 committed by David Jee
parent 81a88a6157
commit 7edbd87e17
7 changed files with 191 additions and 90 deletions

View file

@ -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)
@ -4224,42 +4232,6 @@ p * <li>the set of backward traversal keys
return newEvent;
}
/**
* 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

View file

@ -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);