This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Lightweight peer implementation
- From: Thomas Fitzsimmons <fitzsim at redhat dot com>
- To: GCJ Patch List <java-patches at gcc dot gnu dot org>
- Date: 08 Aug 2003 14:49:06 -0400
- Subject: Lightweight peer implementation
Hello,
This patch is a first step toward support for lightweight components
that draw on GTK widgets. The patch prevents a crash in the
ComponentMouse test from Acunia's open-wonka-visualtest.
Please review and comment.
Thanks,
Tom
2003-08-08 Thomas Fitzsimmons <fitzsim@redhat.com>
* Makefile.am (gtk_awt_peer_sources): Add
GtkLightweightPeer.java. Remove GLightweightPeer.java.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Return before
attempting to create GTK widgets if this is a lightweight peer.
* gnu/java/awt/peer/gtk/GtkToolkit.java (createComponent): New
method.
* gnu/java/awt/peer/gtk/GtkLightweightPeer.java: New file.
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.312
diff -u -b -B -r1.312 Makefile.am
--- Makefile.am 31 Jul 2003 11:55:05 -0000 1.312
+++ Makefile.am 8 Aug 2003 17:25:58 -0000
@@ -215,6 +215,7 @@
gnu/java/awt/peer/gtk/GtkImage.java \
gnu/java/awt/peer/gtk/GtkImagePainter.java \
gnu/java/awt/peer/gtk/GtkLabelPeer.java \
+gnu/java/awt/peer/gtk/GtkLightweightPeer.java \
gnu/java/awt/peer/gtk/GtkListPeer.java \
gnu/java/awt/peer/gtk/GtkMainThread.java \
gnu/java/awt/peer/gtk/GtkMenuBarPeer.java \
@@ -757,7 +758,6 @@
gnu/java/awt/EmbeddedWindow.java \
gnu/java/awt/EmbeddedWindowSupport.java \
gnu/java/awt/EventModifier.java \
-gnu/java/awt/GLightweightPeer.java \
gnu/java/awt/image/ImageDecoder.java \
gnu/java/awt/image/XBMDecoder.java \
gnu/java/awt/peer/EmbeddedWindowPeer.java \
Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.5
diff -u -b -B -r1.5 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java 5 Aug 2003 18:04:09 -0000 1.5
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java 8 Aug 2003 17:26:00 -0000
@@ -97,6 +97,9 @@
super (awtComponent);
this.awtComponent = awtComponent;
+ if (this instanceof GtkLightweightPeer)
+ return;
+
/* temporary try/catch block until all peers use this creation method */
try {
create ();
Index: gnu/java/awt/peer/gtk/GtkToolkit.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java,v
retrieving revision 1.3
diff -u -b -B -r1.3 GtkToolkit.java
--- gnu/java/awt/peer/gtk/GtkToolkit.java 27 Jul 2003 19:04:42 -0000 1.3
+++ gnu/java/awt/peer/gtk/GtkToolkit.java 8 Aug 2003 17:26:00 -0000
@@ -238,6 +238,11 @@
return new GtkFileDialogPeer (fd);
}
+ protected LightweightPeer createComponent(Component c)
+ {
+ return new GtkLightweightPeer (c);
+ }
+
protected FramePeer createFrame (Frame f)
{
return new GtkFramePeer (f);
Index: gnu/java/awt/peer/gtk/GtkLightweightPeer.java
===================================================================
RCS file: gnu/java/awt/peer/gtk/GtkLightweightPeer.java
diff -N gnu/java/awt/peer/gtk/GtkLightweightPeer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/peer/gtk/GtkLightweightPeer.java 8 Aug 2003 17:40:16 -0000
@@ -0,0 +1,89 @@
+/* GtkLightweightPeer.java --
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.peer.gtk;
+
+import java.awt.*;
+import java.awt.event.PaintEvent;
+import java.awt.peer.*;
+import java.awt.image.*;
+import gnu.java.awt.peer.gtk.GtkComponentPeer;
+
+public class GtkLightweightPeer extends GtkComponentPeer
+ implements LightweightPeer
+{
+ public GtkLightweightPeer(Component c)
+ {
+ super(c);
+ }
+
+ /* Replace all of GtkComponentPeer's and GtkGenericPeer's native
+ * methods with empty methods. Some of these methods will probably
+ * need to be filled in. */
+ public void dispose () {}
+
+ boolean isEnabled () { return false; }
+ static boolean modalHasGrab () { return false; }
+
+ int[] gtkWidgetGetForeground ()
+ {
+ int[] f = {0, 0, 0};
+ return f;
+ }
+ int[] gtkWidgetGetBackground ()
+ {
+ int[] b = {0, 0, 0};
+ return b;
+ }
+ void gtkWidgetSetVisible (boolean b) {}
+ void gtkWidgetGetDimensions(int[] dim) {}
+ void gtkWidgetGetLocationOnScreen(int[] point) {}
+ void gtkWidgetSetCursor (int type) {}
+
+ void connectHooks () {}
+
+ public void requestFocus () {}
+
+ public void setNativeBounds (int x, int y, int width, int height) {}
+
+ void set (String name, String value) {}
+ void set (String name, boolean value) {}
+ void set (String name, int value) {}
+ void set (String name, float value) {}
+ void set (String name, Object value) {}
+}