aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-01-31 17:54:14 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-01-31 17:54:14 +0000
commit5aac1dac6279f13c13e4068c4c734c48f0084205 (patch)
tree3d061835fbf308ad2ee29fe5eed56c06842c6b38 /libjava/gnu
parent371ac725580efe2c70111c2403a98b0fef3b11d6 (diff)
downloadgcc-5aac1dac6279f13c13e4068c4c734c48f0084205.zip
gcc-5aac1dac6279f13c13e4068c4c734c48f0084205.tar.gz
gcc-5aac1dac6279f13c13e4068c4c734c48f0084205.tar.bz2
Window.java (Window(Window,GraphicsConfiguration)): Don't try to find graphics configuration.
* java/awt/Window.java (Window(Window,GraphicsConfiguration)): Don't try to find graphics configuration. * java/awt/Toolkit.java (default_toolkit_name): Use new Configuration entry. * gnu/classpath/Configuration.java.in (default_awt_peer_toolkit): New global. * configure: Rebuilt. * configure.in (TOOLKIT): New subst. (--enable-java-awt) [xlib, gtk]: Set TOOLKIT if required. Do AWT tests much earlier. Run Gtk tests. Make jniinclude directory. Make output directories for .c files. * Makefile.in: Rebuilt. * Makefile.am (lib_gnu_java_awt_peer_gtk_la_SOURCES): New macro. (toolexeclib_LTLIBRARIES): Added cond_gtk_ltlibrary. (all_java_source_files): Added new sources. ($(lib_gnu_java_awt_peer_gtk_la_OBJECTS)): New target. (gtk_c_files): New macro. (gtk_c_source_files): New macro. (cond_gtk_ltlibrary): New macro. ($(gtk_c_files)): New target. (lib_gnu_java_awt_peer_gtk_la_LIBADD): New macro. (gtk_awt_peer_sources): New macro. (gtk_c_headers): New macro. ($(gtk_c_headers)): New target. (ACLOCAL_AMFLAGS): New macro. * gtk.m4, glib.m4, libart.m4: New files. * gnu/java/awt/peer/gtk/GdkFontMetrics.java, gnu/java/awt/peer/gtk/GdkGraphics.java, gnu/java/awt/peer/gtk/GtkArg.java, gnu/java/awt/peer/gtk/GtkArgList.java, gnu/java/awt/peer/gtk/GtkButtonPeer.java, gnu/java/awt/peer/gtk/GtkCanvasPeer.java, gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java, gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java, gnu/java/awt/peer/gtk/GtkCheckboxPeer.java, gnu/java/awt/peer/gtk/GtkChoicePeer.java, gnu/java/awt/peer/gtk/GtkClipboard.java, gnu/java/awt/peer/gtk/GtkComponentPeer.java, gnu/java/awt/peer/gtk/GtkContainerPeer.java, gnu/java/awt/peer/gtk/GtkDialogPeer.java, gnu/java/awt/peer/gtk/GtkFileDialogPeer.java, gnu/java/awt/peer/gtk/GtkFontPeer.java, gnu/java/awt/peer/gtk/GtkFramePeer.java, gnu/java/awt/peer/gtk/GtkGenericPeer.java, 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/GtkListPeer.java, gnu/java/awt/peer/gtk/GtkMainThread.java, gnu/java/awt/peer/gtk/GtkMenuBarPeer.java, gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java, gnu/java/awt/peer/gtk/GtkMenuItemPeer.java, gnu/java/awt/peer/gtk/GtkMenuPeer.java, gnu/java/awt/peer/gtk/GtkOffScreenImage.java, gnu/java/awt/peer/gtk/GtkPanelPeer.java, gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java, gnu/java/awt/peer/gtk/GtkScrollbarPeer.java, gnu/java/awt/peer/gtk/GtkScrollPanePeer.java, gnu/java/awt/peer/gtk/GtkTextAreaPeer.java, gnu/java/awt/peer/gtk/GtkTextComponentPeer.java, gnu/java/awt/peer/gtk/GtkTextFieldPeer.java, gnu/java/awt/peer/gtk/GtkToolkit.java, gnu/java/awt/peer/gtk/GtkWindowPeer.java, gnu/java/awt/peer/gtk/TestAWT.java, gnu/java/awt/peer/gtk/Test.java: New files from Classpath. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c, jni/gtk-peer/gthread-jni.c, jni/gtk-peer/gthread-jni.h, jni/gtk-peer/gtkpeer.h, jni/classpath/jcl.c, jni/classpath/jcl.h, jni/classpath/jnilink.c, jni/classpath/jnilink.h, jni/classpath/native_state.c, jni/classpath/native_state.h, jni/classpath/primlib.c, jni/classpath/primlib.h: Likewise. From-SVN: r62187
Diffstat (limited to 'libjava/gnu')
-rw-r--r--libjava/gnu/classpath/Configuration.java.in5
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java108
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GdkGraphics.java322
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkArg.java61
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkArgList.java75
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java89
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java92
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java86
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java56
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java114
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java90
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkClipboard.java167
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java391
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java125
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java76
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java70
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java74
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java132
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkGenericPeer.java84
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkImage.java286
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkImagePainter.java239
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java88
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkListPeer.java126
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkMainThread.java80
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java69
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java54
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java92
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java99
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java87
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkPanelPeer.java53
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java65
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java91
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java78
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java102
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java79
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java98
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkToolkit.java329
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java111
-rw-r--r--libjava/gnu/java/awt/peer/gtk/Test.java299
-rw-r--r--libjava/gnu/java/awt/peer/gtk/TestAWT.java571
40 files changed, 5312 insertions, 1 deletions
diff --git a/libjava/gnu/classpath/Configuration.java.in b/libjava/gnu/classpath/Configuration.java.in
index 1002b62..5a4b97e 100644
--- a/libjava/gnu/classpath/Configuration.java.in
+++ b/libjava/gnu/classpath/Configuration.java.in
@@ -1,5 +1,5 @@
/* gnu.classpath.Configuration
- Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,4 +56,7 @@ public interface Configuration
boolean HAVE_NATIVE_GET_PROXY_DATA = false;
boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false;
+
+ // Name of default AWT peer library.
+ String default_awt_peer_toolkit = "@TOOLKIT@";
}
diff --git a/libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java b/libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java
new file mode 100644
index 0000000..45690b0
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java
@@ -0,0 +1,108 @@
+/* GdkFontMetrics.java
+ Copyright (C) 1999, 2002 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.*;
+
+public class GdkFontMetrics extends FontMetrics
+{
+ private final int native_state = GtkGenericPeer.getUniqueInteger();
+
+ private static final int ASCENT = 0, MAX_ASCENT = 1,
+ DESCENT = 2, MAX_DESCENT = 3,
+ MAX_ADVANCE = 4;
+
+ private int[] metrics;
+ private native int[] initState (String xlfd, int pts);
+
+ public GdkFontMetrics (Font font)
+ {
+ super (font);
+ metrics = initState (((GtkFontPeer)font.getPeer ()).getXLFD (),
+ font.getSize ());
+ }
+
+ native public int stringWidth (String str);
+
+ public int charWidth (char ch)
+ {
+ return stringWidth (new String (new char[] { ch }));
+ }
+
+ public int charsWidth (char data[], int off, int len)
+ {
+ return stringWidth (new String (data, off, len));
+ }
+
+ /*
+ Sun's Motif implementation always returns 0 or 1 here (???), but
+ going by the X11 man pages, it seems as though we should return
+ font.ascent + font.descent.
+ */
+ public int getLeading ()
+ {
+ return 1;
+// return metrics[ASCENT] + metrics[DESCENT];
+ }
+
+ public int getAscent ()
+ {
+ return metrics[ASCENT];
+ }
+
+ public int getMaxAscent ()
+ {
+ return metrics[MAX_ASCENT];
+ }
+
+ public int getDescent ()
+ {
+ return metrics[DESCENT];
+ }
+
+ public int getMaxDescent ()
+ {
+ return metrics[MAX_DESCENT];
+ }
+
+ public int getMaxAdvance ()
+ {
+ return metrics[MAX_ADVANCE];
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java
new file mode 100644
index 0000000..3e3d04bb
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -0,0 +1,322 @@
+/* GdkGraphics.java
+ Copyright (C) 1998, 1999, 2002 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.image.*;
+
+public class GdkGraphics extends Graphics
+{
+ private final int native_state = GtkGenericPeer.getUniqueInteger();
+
+ Color color, xorColor;
+ GtkComponentPeer component;
+ Font font;
+ Rectangle clip;
+
+ int xOffset = 0;
+ int yOffset = 0;
+
+ static final int GDK_COPY = 0, GDK_XOR = 2;
+
+ native int[] initState (GtkComponentPeer component);
+ native void initState (int width, int height);
+ native void copyState (GdkGraphics g);
+
+ GdkGraphics (GdkGraphics g)
+ {
+ color = g.color;
+ xorColor = g.xorColor;
+ font = g.font;
+ clip = new Rectangle (g.clip);
+ component = g.component;
+
+ copyState (g);
+ }
+
+ GdkGraphics (int width, int height)
+ {
+ initState (width, height);
+ color = Color.black;
+ clip = new Rectangle (0, 0, width, height);
+ font = new Font ("Dialog", Font.PLAIN, 10);
+ }
+
+ GdkGraphics (GtkComponentPeer component)
+ {
+ this.component = component;
+ int rgb[] = initState (component);
+ color = new Color (rgb[0], rgb[1], rgb[2]);
+ font = new Font ("Dialog", Font.PLAIN, 10);
+ Dimension d = component.awtComponent.getSize ();
+ clip = new Rectangle (0, 0, d.width, d.height);
+ }
+
+ public native void clearRect (int x, int y, int width, int height);
+
+ public void clipRect (int x, int y, int width, int height)
+ {
+ clip = clip.intersection (new Rectangle (x, y, width, height));
+ setClipRectangle (clip.x, clip.y, clip.width, clip.height);
+ }
+
+ native public void copyArea (int x, int y, int width, int height,
+ int dx, int dy);
+
+ public Graphics create ()
+ {
+ return new GdkGraphics (this);
+ }
+
+// public Graphics create (int x, int y, int width, int height)
+// {
+// GdkGraphics g = new GdkGraphics (this);
+// System.out.println ("translating by: " + x +" " + y);
+// g.translate (x, y);
+// g.clipRect (0, 0, width, height);
+
+// return g;
+// }
+
+ native public void dispose ();
+
+ native void copyPixmap (Graphics g, int x, int y, int width, int height);
+ public boolean drawImage (Image img, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (img instanceof GtkOffScreenImage)
+ {
+ copyPixmap (img.getGraphics (),
+ x, y, img.getWidth (null), img.getHeight (null));
+ return true;
+ }
+
+ GtkImage image = (GtkImage) img;
+ new GtkImagePainter (image, this, x, y, -1, -1, bgcolor);
+ return image.isLoaded ();
+ }
+
+ public boolean drawImage (Image img, int x, int y, ImageObserver observer)
+ {
+ if (img instanceof GtkOffScreenImage)
+ {
+ copyPixmap (img.getGraphics (),
+ x, y, img.getWidth (null), img.getHeight (null));
+ return true;
+ }
+
+ return drawImage (img, x, y, component.getBackground (), observer);
+ }
+
+ public boolean drawImage (Image img, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (img instanceof GtkOffScreenImage)
+ {
+ throw new RuntimeException ();
+ }
+
+ GtkImage image = (GtkImage) img;
+ new GtkImagePainter (image, this, x, y, width, height, bgcolor);
+ return image.isLoaded ();
+ }
+
+ public boolean drawImage (Image img, int x, int y, int width, int height,
+ ImageObserver observer)
+ {
+ return drawImage (img, x, y, width, height, component.getBackground (),
+ observer);
+ }
+
+ public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (img instanceof GtkOffScreenImage)
+ {
+ throw new RuntimeException ();
+ }
+
+ GtkImage image = (GtkImage) img;
+ new GtkImagePainter (image, this, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, bgcolor);
+ return image.isLoaded ();
+ }
+
+ public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ ImageObserver observer)
+ {
+ return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
+ component.getBackground (), observer);
+ }
+
+ native public void drawLine (int x1, int y1, int x2, int y2);
+
+ native public void drawArc (int x, int y, int width, int height,
+ int startAngle, int arcAngle);
+ native public void fillArc (int x, int y, int width, int height,
+ int startAngle, int arcAngle);
+ native public void drawOval(int x, int y, int width, int height);
+ native public void fillOval(int x, int y, int width, int height);
+
+ native public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
+ native public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
+
+ native public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints);
+
+ native public void drawRect(int x, int y, int width, int height);
+ native public void fillRect (int x, int y, int width, int height);
+
+ native void drawString (String str, int x, int y, String fname, int size);
+ public void drawString (String str, int x, int y)
+ {
+ drawString (str, x, y,
+ ((GtkFontPeer)font.getPeer ()).getXLFD (), font.getSize ());
+ }
+
+ public void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ // System.out.println ("drawRoundRect called [UNIMPLEMENTED]");
+ }
+
+ public void fillRoundRect (int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ // System.out.println ("fillRoundRect called [UNIMPLEMENTED]");
+ }
+
+ public Shape getClip ()
+ {
+ return getClipBounds ();
+ }
+
+ public Rectangle getClipBounds ()
+ {
+// System.out.println ("returning CLIP: " + clip);
+ return new Rectangle (clip.x, clip.y, clip.width, clip.height);
+ }
+
+ public Color getColor ()
+ {
+ return color;
+ }
+
+ public Font getFont ()
+ {
+ return font;
+ }
+
+ public FontMetrics getFontMetrics (Font font)
+ {
+ return new GdkFontMetrics (font);
+ }
+
+ native void setClipRectangle (int x, int y, int width, int height);
+
+ public void setClip (int x, int y, int width, int height)
+ {
+ clip.x = x;
+ clip.y = y;
+ clip.width = width;
+ clip.height = height;
+
+ setClipRectangle (x, y, width, height);
+ }
+
+ public void setClip (Rectangle clip)
+ {
+ setClip (clip.x, clip.y, clip.width, clip.height);
+ }
+
+ public void setClip (Shape clip)
+ {
+ setClip (clip.getBounds ());
+ }
+
+ native private void setFGColor (int red, int green, int blue);
+
+ public void setColor (Color c)
+ {
+ color = c;
+
+ if (xorColor == null) /* paint mode */
+ setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
+ else /* xor mode */
+ setFGColor (color.getRed () ^ xorColor.getRed (),
+ color.getGreen () ^ xorColor.getGreen (),
+ color.getBlue () ^ xorColor.getBlue ());
+ }
+
+ public void setFont (Font font)
+ {
+ this.font = font;
+ }
+
+ native void setFunction (int gdk_func);
+
+ public void setPaintMode ()
+ {
+ xorColor = null;
+
+ setFunction (GDK_COPY);
+ setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
+ }
+
+ public void setXORMode (Color c)
+ {
+ xorColor = c;
+
+ setFunction (GDK_XOR);
+ setFGColor (color.getRed () ^ xorColor.getRed (),
+ color.getGreen () ^ xorColor.getGreen (),
+ color.getBlue () ^ xorColor.getBlue ());
+ }
+
+ native public void translateNative (int x, int y);
+
+ public void translate (int x, int y)
+ {
+ clip.x -= x;
+ clip.y -= y;
+
+ translateNative (x, y);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkArg.java b/libjava/gnu/java/awt/peer/gtk/GtkArg.java
new file mode 100644
index 0000000..0491856
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkArg.java
@@ -0,0 +1,61 @@
+/* GtkArg.java
+ Copyright (C) 1999 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;
+
+public class GtkArg
+{
+ String name;
+ Object value;
+
+ public GtkArg (String name, Object value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName ()
+ {
+ return name;
+ }
+
+ public Object getValue ()
+ {
+ return value;
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkArgList.java b/libjava/gnu/java/awt/peer/gtk/GtkArgList.java
new file mode 100644
index 0000000..c777047
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkArgList.java
@@ -0,0 +1,75 @@
+/* GtkArgList.java
+ Copyright (C) 1999 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.util.Vector;
+
+public class GtkArgList extends Vector
+{
+ void add (GtkArg arg)
+ {
+ addElement (arg);
+ }
+
+ void add (String name, boolean value)
+ {
+ addElement (new GtkArg (name, new Boolean (value)));
+ }
+
+ void add (String name, int value)
+ {
+ addElement (new GtkArg (name, new Integer (value)));
+ }
+
+ void add (String name, float value)
+ {
+ addElement (new GtkArg (name, new Float (value)));
+ }
+
+ void add (String name, Object value)
+ {
+ addElement (new GtkArg (name, value));
+ }
+
+ synchronized void setArgs (GtkComponentPeer cp)
+ {
+ for (int i = 0; i < elementCount; i++)
+ cp.set ((GtkArg)elementData[i]);
+ }
+}
+
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java
new file mode 100644
index 0000000..94603c0
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java
@@ -0,0 +1,89 @@
+/* GtkButtonPeer.java -- Implements ButtonPeer with GTK
+ Copyright (C) 1998, 1999 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.MouseEvent;
+import java.awt.event.KeyEvent;
+import java.awt.peer.*;
+
+public class GtkButtonPeer extends GtkComponentPeer
+ implements ButtonPeer
+{
+ native void create ();
+
+ public GtkButtonPeer (Button b)
+ {
+ super (b);
+ }
+
+ public void setLabel (String label)
+ {
+ set ("label", label);
+ }
+
+ public void handleEvent (AWTEvent e)
+ {
+ if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled ()
+ && !modalHasGrab ())
+ {
+ MouseEvent me = (MouseEvent) e;
+ if (!me.isConsumed ()
+ && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0)
+ postActionEvent (((Button)awtComponent).getActionCommand (),
+ me.getModifiers ());
+ }
+
+ if (e.getID () == KeyEvent.KEY_PRESSED)
+ {
+ KeyEvent ke = (KeyEvent) e;
+ if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_SPACE)
+ postActionEvent (((Button)awtComponent).getActionCommand (),
+ ke.getModifiers ());
+ }
+
+ super.handleEvent (e);
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ super.getArgs (component, args);
+
+ args.add ("label", ((Button)component).getLabel ());
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
new file mode 100644
index 0000000..59c28f9
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
@@ -0,0 +1,92 @@
+/* GtkCanvasPeer.java
+ Copyright (C) 1998, 1999 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.*;
+
+public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
+{
+ native void create ();
+
+ public GtkCanvasPeer (Canvas c)
+ {
+ super (c);
+ }
+
+ public Graphics getGraphics ()
+ {
+ return new GdkGraphics (this);
+ }
+
+ public void handleEvent (AWTEvent event)
+ {
+ int id = event.getID();
+
+ switch (id)
+ {
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ {
+ try
+ {
+ Graphics g = getGraphics ();
+ g.setClip (((PaintEvent)event).getUpdateRect());
+
+ if (id == PaintEvent.PAINT)
+ awtComponent.paint (g);
+ else
+ awtComponent.update (g);
+
+ g.dispose ();
+ }
+ catch (InternalError e)
+ {
+ System.err.println (e);
+ }
+ }
+ break;
+ }
+ }
+
+ /* Preferred size for a drawing widget is always what the user requested */
+ public Dimension getPreferredSize ()
+ {
+ return awtComponent.getSize ();
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java
new file mode 100644
index 0000000..9903c31
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java
@@ -0,0 +1,86 @@
+/* GtkCheckboxGroupPeer.java - Wrap a CheckboxGroup
+ Copyright (C) 2002 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.*;
+import java.util.*;
+
+// Note that there is no peer interface for a CheckboxGroup. We
+// introduce our own in order to make it easier to keep a piece of
+// native state for each one.
+public class GtkCheckboxGroupPeer extends GtkGenericPeer
+{
+ // This maps from a CheckboxGroup to the native peer.
+ private static WeakHashMap map = new WeakHashMap ();
+
+ // Find the native peer corresponding to a CheckboxGroup.
+ public static synchronized GtkCheckboxGroupPeer
+ getCheckboxGroupPeer (CheckboxGroup group)
+ {
+ if (group == null)
+ return null;
+ GtkCheckboxGroupPeer nat = (GtkCheckboxGroupPeer) map.get (group);
+ if (nat == null)
+ {
+ nat = new GtkCheckboxGroupPeer ();
+ map.put (group, nat);
+ }
+ return nat;
+ }
+
+ private GtkCheckboxGroupPeer ()
+ {
+ // We don't need any special state here. Note that we can't store
+ // a reference to the java-side CheckboxGroup. That would mean
+ // they could never be collected.
+ super (null);
+ }
+
+ // Dispose of our native resources.
+ public native void dispose ();
+
+ // Remove a given checkbox from this group.
+ public native void remove (GtkCheckboxPeer box);
+
+ // When collected, clean up the native state.
+ protected void finalize ()
+ {
+ dispose ();
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java
new file mode 100644
index 0000000..1bff706
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java
@@ -0,0 +1,56 @@
+/* GtkCheckboxMenuItemPeer.java -- Implements CheckboxMenuItemPeer with GTK+
+ Copyright (C) 1999 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.peer.CheckboxMenuItemPeer;
+import java.awt.peer.MenuItemPeer;
+
+public class GtkCheckboxMenuItemPeer extends GtkMenuItemPeer
+ implements CheckboxMenuItemPeer
+{
+ native void create (String label);
+
+ public GtkCheckboxMenuItemPeer (CheckboxMenuItem menu)
+ {
+ super (menu);
+ setState (menu.getState ());
+ }
+
+ native public void setState (boolean t);
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
new file mode 100644
index 0000000..48f8804
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
@@ -0,0 +1,114 @@
+/* GtkCheckboxPeer.java -- Implements CheckboxPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.peer.*;
+import java.awt.*;
+
+public class GtkCheckboxPeer extends GtkComponentPeer
+ implements CheckboxPeer
+{
+ // Group from last time it was set.
+ public GtkCheckboxGroupPeer old_group;
+
+ public native void nativeCreate (GtkCheckboxGroupPeer group);
+ public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
+ public native void connectHooks ();
+
+ public GtkCheckboxPeer (Checkbox c)
+ {
+ super (c);
+ }
+
+ // We can't fully use the ordinary getArgs code here, due to
+ // oddities of this particular widget. In particular we must be
+ // able to switch between a checkbutton and a radiobutton
+ // dynamically.
+ public void create ()
+ {
+ CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup ();
+ old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g);
+ nativeCreate (old_group);
+ }
+
+ public void setState (boolean state)
+ {
+ set ("active", state);
+ }
+
+ public void setLabel (String label)
+ {
+ set ("label", label);
+ }
+
+ public void setCheckboxGroup (CheckboxGroup group)
+ {
+ GtkCheckboxGroupPeer gp
+ = GtkCheckboxGroupPeer.getCheckboxGroupPeer (group);
+ if (gp != old_group)
+ {
+ if (old_group != null)
+ old_group.remove (this);
+ nativeSetCheckboxGroup (gp);
+ old_group = gp;
+ }
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ super.getArgs (component, args);
+ args.add ("active", ((Checkbox) component).getState ());
+ args.add ("label", ((Checkbox) component).getLabel ());
+ }
+
+ // Override the superclass postItemEvent so that the peer doesn't
+ // need information that we have.
+ public void postItemEvent (Object item, int stateChange)
+ {
+ super.postItemEvent (awtComponent, stateChange);
+ }
+
+ public void dispose ()
+ {
+ // Notify the group so that the native state can be cleaned up
+ // appropriately.
+ if (old_group != null)
+ old_group.remove (this);
+ super.dispose ();
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java
new file mode 100644
index 0000000..19e1a56
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java
@@ -0,0 +1,90 @@
+/* GtkChoicePeer.java -- Implements ChoicePeer with GTK
+ Copyright (C) 1998, 1999 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.peer.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class GtkChoicePeer extends GtkComponentPeer
+ implements ChoicePeer
+{
+ native void create ();
+
+ public GtkChoicePeer (Choice c)
+ {
+ super (c);
+
+ int count = c.getItemCount ();
+ if (count > 0)
+ {
+ String items[] = new String[count];
+ for (int i = 0; i < count; i++)
+ items[i] = c.getItem (i);
+
+ append (items);
+ }
+ }
+
+ native void append (String items[]);
+
+ native public void add (String item, int index);
+ native public void remove (int index);
+ native public void select (int position);
+
+ public void addItem (String item, int position)
+ {
+ add (item, position);
+ }
+
+ /*
+ public void handleEvent (AWTEvent event)
+ {
+ if (event instanceof ItemEvent)
+ ((Choice) awtComponent).select ((String) ((ItemEvent)event).getItem ());
+ super.handleEvent (event);
+ }
+ */
+
+ protected void postItemEvent (Object item, int stateChange)
+ {
+ if (stateChange == ItemEvent.SELECTED)
+ ((Choice) awtComponent).select ((String) item);
+ super.postItemEvent (item, stateChange);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkClipboard.java b/libjava/gnu/java/awt/peer/gtk/GtkClipboard.java
new file mode 100644
index 0000000..d2587d9
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkClipboard.java
@@ -0,0 +1,167 @@
+/* GtkClipboard.java
+ Copyright (C) 1999 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.io.*;
+import java.net.*;
+import java.util.*;
+import java.awt.datatransfer.*;
+import java.awt.image.*;
+import java.awt.peer.*;
+
+public class GtkClipboard extends Clipboard
+{
+ /* the number of milliseconds that we'll wait around for the
+ owner of the GDK_SELECTION_PRIMARY selection to convert
+ the requested data */
+ final static int SELECTION_RECEIVED_TIMEOUT = 5000;
+
+ /* We currently only support transferring of text between applications */
+ static String selection;
+ static Object selectionLock = new Object ();
+
+ static boolean hasSelection = false;
+
+ protected
+ GtkClipboard ()
+ {
+ super ("System Clipboard");
+ initNativeState ();
+ }
+
+ public Transferable
+ getContents (Object requestor)
+ {
+ synchronized (this)
+ {
+ if (hasSelection)
+ return contents;
+ }
+
+ /* Java doesn't own the selection, so we need to ask X11 */
+ synchronized (selectionLock)
+ {
+ requestStringConversion ();
+ try
+ {
+ selectionLock.wait (SELECTION_RECEIVED_TIMEOUT);
+ }
+ catch (InterruptedException e)
+ {
+ return null;
+ }
+
+ return (selection == null) ? null : new StringSelection (selection);
+ }
+ }
+
+ void
+ stringSelectionReceived (String newSelection)
+ {
+ synchronized (selectionLock)
+ {
+ selection = newSelection;
+ selectionLock.notify ();
+ }
+ }
+
+ /* convert Java clipboard data into a String suitable for sending
+ to another application */
+ synchronized String
+ stringSelectionHandler () throws IOException
+ {
+ String selection = null;
+
+ try {
+ if (contents.isDataFlavorSupported (DataFlavor.stringFlavor))
+ selection = (String)contents.getTransferData (DataFlavor.stringFlavor);
+ else if (contents.isDataFlavorSupported (DataFlavor.plainTextFlavor))
+ {
+ StringBuffer sbuf = new StringBuffer ();
+ InputStreamReader reader;
+ char readBuf[] = new char[512];
+ int numChars;
+
+ reader = new InputStreamReader
+ ((InputStream)
+ contents.getTransferData (DataFlavor.plainTextFlavor), "UNICODE");
+
+ while (true)
+ {
+ numChars = reader.read (readBuf);
+ if (numChars == -1)
+ break;
+ sbuf.append (readBuf, 0, numChars);
+ }
+
+ selection = new String (sbuf);
+ }
+ } catch (Exception e) { }
+
+ return selection;
+ }
+
+ public synchronized void
+ setContents (Transferable contents, ClipboardOwner owner)
+ {
+ selectionGet ();
+
+ this.contents = contents;
+ this.owner = owner;
+
+ hasSelection = true;
+ }
+
+ synchronized
+ void selectionClear ()
+ {
+ hasSelection = false;
+
+ if (owner != null)
+ {
+ owner.lostOwnership (this, contents);
+ owner = null;
+ contents = null;
+ }
+ }
+
+ native void initNativeState ();
+ native static void requestStringConversion ();
+ native static void selectionGet ();
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
new file mode 100644
index 0000000..6e3b252
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -0,0 +1,391 @@
+/* GtkComponentPeer.java -- Implements ComponentPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.*;
+import java.awt.image.*;
+import java.awt.peer.ComponentPeer;
+
+public class GtkComponentPeer extends GtkGenericPeer
+ implements ComponentPeer
+{
+ Component awtComponent;
+
+ /* this isEnabled differs from Component.isEnabled, in that it
+ knows if a parent is disabled. In that case Component.isEnabled
+ may return true, but our isEnabled will always return false */
+ native boolean isEnabled ();
+ native static boolean modalHasGrab ();
+
+ native int[] gtkWidgetGetForeground ();
+ native int[] gtkWidgetGetBackground ();
+ native void gtkWidgetSetVisible (boolean b);
+ native void gtkWidgetGetDimensions(int[] dim);
+ native void gtkWidgetGetLocationOnScreen(int[] point);
+ native void gtkWidgetSetCursor (int type);
+
+ void create ()
+ {
+ throw new RuntimeException ();
+ }
+
+ native void connectHooks ();
+
+ protected GtkComponentPeer (Component awtComponent)
+ {
+ super (awtComponent);
+ this.awtComponent = awtComponent;
+
+ /* temporary try/catch block until all peers use this creation method */
+ try {
+ create ();
+
+ GtkArgList args = new GtkArgList ();
+ getArgs (awtComponent, args);
+ args.setArgs (this);
+
+ connectHooks ();
+
+ if (awtComponent.getForeground () == null)
+ awtComponent.setForeground (getForeground ());
+ if (awtComponent.getBackground () == null)
+ awtComponent.setBackground (getBackground ());
+ // if (c.getFont () == null)
+ // c.setFont (cp.getFont ());
+
+ if (! (awtComponent instanceof Window))
+ {
+ setCursor (awtComponent.getCursor ());
+ Rectangle bounds = awtComponent.getBounds ();
+ setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
+ }
+ } catch (RuntimeException ex) { ; }
+ }
+
+ public int checkImage (Image image, int width, int height,
+ ImageObserver observer)
+ {
+ GtkImage i = (GtkImage) image;
+ return i.checkImage ();
+ }
+
+ public Image createImage (ImageProducer producer)
+ {
+ return new GtkImage (producer, null);
+ }
+
+ public Image createImage (int width, int height)
+ {
+ GdkGraphics g = new GdkGraphics (width, height);
+ return new GtkOffScreenImage (null, g, width, height);
+ }
+
+ public void disable ()
+ {
+ setEnabled (false);
+ }
+
+ public void enable ()
+ {
+ setEnabled (true);
+ }
+
+ public ColorModel getColorModel ()
+ {
+ return ColorModel.getRGBdefault ();
+ }
+
+ public FontMetrics getFontMetrics (Font font)
+ {
+ return new GdkFontMetrics (font);
+ }
+
+ public Graphics getGraphics ()
+ {
+ return null;
+ }
+
+ public Point getLocationOnScreen ()
+ {
+ int point[] = new int[2];
+ gtkWidgetGetLocationOnScreen (point);
+ return new Point (point[0], point[1]);
+ }
+
+ public Dimension getMinimumSize ()
+ {
+ int dim[]=new int[2];
+ gtkWidgetGetDimensions (dim);
+ Dimension d = new Dimension (dim[0],dim[1]);
+ return (d);
+ }
+
+ public Dimension getPreferredSize ()
+ {
+ int dim[]=new int[2];
+ gtkWidgetGetDimensions (dim);
+ Dimension d = new Dimension (dim[0],dim[1]);
+ return (d);
+ }
+
+ public Toolkit getToolkit ()
+ {
+ return Toolkit.getDefaultToolkit();
+ }
+
+ public void handleEvent (AWTEvent event)
+ {
+ }
+
+ public boolean isFocusTraversable ()
+ {
+ return true;
+ }
+
+ public Dimension minimumSize ()
+ {
+ return getMinimumSize();
+ }
+
+ public void paint (Graphics g)
+ {
+ awtComponent.paint (g);
+ }
+
+ public Dimension preferredSize()
+ {
+ return getPreferredSize();
+ }
+
+ public boolean prepareImage (Image image, int width, int height,
+ ImageObserver observer)
+ {
+ GtkImage i = (GtkImage) image;
+
+ if (i.isLoaded ()) return true;
+
+ class PrepareImage extends Thread
+ {
+ GtkImage image;
+ ImageObserver observer;
+
+ PrepareImage (GtkImage image, ImageObserver observer)
+ {
+ this.image = image;
+ this.observer = observer;
+ }
+
+ public void run ()
+ {
+ // XXX: need to return data to image observer
+ image.source.startProduction (null);
+ }
+ }
+
+ new PrepareImage (i, observer).start ();
+ return false;
+ }
+
+ public void print (Graphics g)
+ {
+ throw new RuntimeException ();
+ }
+
+ public void repaint (long tm, int x, int y, int width, int height)
+ {
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE,
+ new Rectangle (x, y, width, height)));
+ }
+
+ native public void requestFocus ();
+
+ public void reshape (int x, int y, int width, int height)
+ {
+ setBounds (x, y, width, height);
+ }
+
+ public void setBackground (Color c)
+ {
+ // System.out.println ("setBackground [UNIMPLEMENTED");
+ }
+
+ native public void setNativeBounds (int x, int y, int width, int height);
+
+ public void setBounds (int x, int y, int width, int height)
+ {
+ Component parent = awtComponent.getParent ();
+
+ if (parent instanceof Frame)
+ {
+ Insets insets = ((Frame)parent).getInsets ();
+ /* convert Java's coordinate space into GTK+'s coordinate space */
+ setNativeBounds (x-insets.left, y-insets.top, width, height);
+ }
+ else
+ setNativeBounds (x, y, width, height);
+ }
+
+ public void setCursor (Cursor cursor)
+ {
+ gtkWidgetSetCursor (cursor.getType ());
+ }
+
+ public void setEnabled (boolean b)
+ {
+ set ("sensitive", b);
+ }
+
+ public void setFont (Font f)
+ {
+ }
+
+ public void setForeground (Color c)
+ {
+ // System.out.println ("setForeground [UNIMPLEMENTED");
+ }
+
+ public Color getForeground ()
+ {
+ int rgb[] = gtkWidgetGetForeground ();
+ return new Color (rgb[0], rgb[1], rgb[2]);
+ }
+
+ public Color getBackground ()
+ {
+ int rgb[] = gtkWidgetGetBackground ();
+ return new Color (rgb[0], rgb[1], rgb[2]);
+ }
+
+ public void setVisible (boolean b)
+ {
+ set ("visible", b);
+ }
+
+ public void hide ()
+ {
+ setVisible (false);
+ }
+
+ public void show ()
+ {
+ setVisible (true);
+ }
+
+ protected void postMouseEvent(int id, long when, int mods, int x, int y,
+ int clickCount, boolean popupTrigger)
+ {
+ q.postEvent(new MouseEvent(awtComponent, id, when, mods, x, y,
+ clickCount, popupTrigger));
+ }
+
+ protected void postExposeEvent (int x, int y, int width, int height)
+ {
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+ new Rectangle (x, y, width, height)));
+ }
+
+ protected void postKeyEvent (int id, long when, int mods,
+ int keyCode, char keyChar)
+ {
+ q.postEvent (new KeyEvent (awtComponent, id, when, mods,
+ keyCode, keyChar));
+ }
+
+ protected void postFocusEvent (int id, boolean temporary)
+ {
+ q.postEvent (new FocusEvent (awtComponent, id, temporary));
+ }
+
+ protected void postItemEvent (Object item, int stateChange)
+ {
+ q.postEvent (new ItemEvent ((ItemSelectable)awtComponent,
+ ItemEvent.ITEM_STATE_CHANGED,
+ item, stateChange));
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ args.add ("visible", component.isVisible ());
+ args.add ("sensitive", component.isEnabled ());
+
+ ComponentPeer p;
+
+ do
+ {
+ component = component.getParent ();
+ p = component.getPeer ();
+ } while (p instanceof java.awt.peer.LightweightPeer);
+
+ args.add ("parent", p);
+ }
+
+ native void set (String name, String value);
+ native void set (String name, boolean value);
+ native void set (String name, int value);
+ native void set (String name, float value);
+ native void set (String name, Object value);
+
+ void set (GtkArg arg)
+ {
+ String name = arg.getName ();
+ Object value = arg.getValue ();
+
+ if (value instanceof Boolean)
+ set (name, ((Boolean)value).booleanValue ());
+ else if (value instanceof Integer)
+ set (name, ((Integer)value).intValue ());
+ else if (value instanceof Float)
+ set (name, ((Float)value).floatValue ());
+ else if (value instanceof String)
+ set (name, ((String) value));
+ else
+ set (name, value);
+ }
+
+ public GraphicsConfiguration getGraphicsConfiguration ()
+ {
+ // FIXME: just a stub for now.
+ return null;
+ }
+
+ public void setEventMask (long mask)
+ {
+ // FIXME: just a stub for now.
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java
new file mode 100644
index 0000000..fef88cd
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java
@@ -0,0 +1,125 @@
+/* GtkContainerPeer.java -- Implements ContainerPeer with GTK
+ Copyright (C) 1998, 1999 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.*;
+import java.awt.peer.ContainerPeer;
+
+public class GtkContainerPeer extends GtkComponentPeer
+ implements ContainerPeer
+{
+ Insets insets;
+ Container c;
+
+ public GtkContainerPeer(Container c)
+ {
+ super (c);
+ this.c = c;
+ insets = new Insets (0, 0, 0, 0);
+ }
+
+ public void beginValidate()
+ {
+ }
+
+ public void endValidate()
+ {
+// q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+// new Rectangle (x, y, width, height)));
+// Graphics gc = getGraphics ();
+// if (gc != null)
+// {
+// awtComponent.update (gc);
+// gc.dispose ();
+// }
+// System.out.println ("got here");
+// awtComponent.repaint ();
+ }
+
+ public Insets getInsets()
+ {
+ return insets;
+ }
+
+ public Insets insets()
+ {
+ return getInsets ();
+ }
+
+ public void setBounds (int x, int y, int width, int height)
+ {
+ super.setBounds (x, y, width, height);
+ awtComponent.validate ();
+ }
+
+ public Graphics getGraphics ()
+ {
+ return new GdkGraphics (this);
+ }
+
+ public void handleEvent (AWTEvent event)
+ {
+ int id = event.getID();
+
+ switch (id)
+ {
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ {
+ try
+ {
+ Graphics g = getGraphics ();
+ g.setClip (((PaintEvent)event).getUpdateRect());
+
+ if (id == PaintEvent.PAINT)
+ awtComponent.paint (g);
+ else
+ awtComponent.update (g);
+
+ g.dispose ();
+ }
+ catch (InternalError e)
+ {
+ System.err.println (e);
+ }
+ }
+ break;
+ }
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java
new file mode 100644
index 0000000..b47956d
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java
@@ -0,0 +1,76 @@
+/* GtkDialogPeer.java -- Implements DialogPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.peer.*;
+import java.awt.event.*;
+
+public class GtkDialogPeer extends GtkWindowPeer
+ implements DialogPeer
+{
+ public GtkDialogPeer (Dialog dialog)
+ {
+ super (dialog);
+ }
+
+ void create ()
+ {
+ create (GTK_WINDOW_DIALOG);
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ super.getArgs (component, args);
+
+ Dialog dialog = (Dialog) component;
+
+ args.add ("modal", dialog.isModal ());
+ args.add ("allow_shrink", dialog.isResizable ());
+ args.add ("allow_grow", dialog.isResizable ());
+ }
+
+ public void handleEvent (AWTEvent event)
+ {
+// int id = event.getID();
+
+// if (id == WindowEvent.WINDOW_CLOSING)
+// System.out.println ("got a closing event");
+ }
+
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
new file mode 100644
index 0000000..3376787
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
@@ -0,0 +1,70 @@
+/* GtkFileDialogPeer.java -- Implements FileDialogPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.io.FilenameFilter;
+import java.awt.peer.*;
+import java.awt.*;
+
+public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
+{
+ native void create ();
+
+ public GtkFileDialogPeer (FileDialog fd)
+ {
+ super (fd);
+ }
+
+ public void setDirectory (String directory)
+ {
+ setFile (directory);
+ }
+
+ public native void setFile (String file);
+ public native void connectHooks ();
+
+ public void setFilenameFilter (FilenameFilter filter)
+ {
+ /* GTK has no filters. */
+ }
+
+ public Graphics getGraphics ()
+ {
+ return null;
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java
new file mode 100644
index 0000000..47a46e8
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java
@@ -0,0 +1,74 @@
+/* GtkFontPeer.java -- Implements FontPeer with GTK+
+ Copyright (C) 1999 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.peer.FontPeer;
+import java.awt.Font;
+import java.util.ResourceBundle;
+
+public class GtkFontPeer implements FontPeer
+{
+ private static ResourceBundle bundle;
+
+ static
+ {
+ try
+ {
+ bundle = ResourceBundle.getBundle ("gnu.java.awt.peer.gtk.font");
+ }
+ catch (Throwable ignored)
+ {
+ bundle = null;
+ }
+ }
+
+ final private String Xname;
+
+ public GtkFontPeer (String name, int style)
+ {
+ if (bundle != null)
+ Xname = bundle.getString (name.toLowerCase () + "." + style);
+ else
+ Xname = "-*-*-medium-r-normal-*-12-*-*-*-c-*-*-*";
+ }
+
+ public String getXLFD ()
+ {
+ return Xname;
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java
new file mode 100644
index 0000000..e16a570
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -0,0 +1,132 @@
+/* GtkFramePeer.java -- Implements FramePeer with GTK
+ Copyright (C) 1999, 2002 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.peer.*;
+import java.awt.event.*;
+
+public class GtkFramePeer extends GtkWindowPeer
+ implements FramePeer
+{
+ int menuBarHeight = 0;
+ native int getMenuBarHeight ();
+
+ native public void setMenuBarPeer (MenuBarPeer bar);
+
+ public void setMenuBar (MenuBar bar)
+ {
+ if (bar == null)
+ setMenuBarPeer (null);
+ else
+ setMenuBarPeer ((MenuBarPeer) bar.getPeer ());
+ }
+
+ public GtkFramePeer (Frame frame)
+ {
+ super (frame);
+ }
+
+ void create ()
+ {
+ create (GTK_WINDOW_TOPLEVEL);
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ super.getArgs (component, args);
+
+ Frame frame = (Frame) component;
+
+ args.add ("title", frame.getTitle ());
+ args.add ("allow_shrink", frame.isResizable ());
+ args.add ("allow_grow", frame.isResizable ());
+ }
+ public void setIconImage (Image image)
+ {
+ /* TODO: Waiting on Toolkit Image routines */
+ }
+
+ public Graphics getGraphics ()
+ {
+ GdkGraphics g = new GdkGraphics (this);
+ g.translateNative (-insets.left, -insets.top);
+ return g;
+ }
+
+ public void setBounds (int x, int y, int width, int height)
+ {
+ super.setBounds (0, 0, width - insets.left - insets.right,
+ height - insets.top - insets.bottom + menuBarHeight);
+ }
+
+ protected void postConfigureEvent (int x, int y, int width, int height,
+ int top, int left, int bottom, int right)
+ {
+ if (((Frame)awtComponent).getMenuBar () != null)
+ {
+ menuBarHeight = getMenuBarHeight ();
+ top += menuBarHeight;
+ }
+
+ super.postConfigureEvent (0, 0,
+ width + left + right,
+ height + top + bottom - menuBarHeight,
+ top, left, bottom, right);
+ }
+
+ protected void postMouseEvent(int id, long when, int mods, int x, int y,
+ int clickCount, boolean popupTrigger)
+ {
+ super.postMouseEvent (id, when, mods,
+ x + insets.left, y + insets.top,
+ clickCount, popupTrigger);
+ }
+
+ protected void postExposeEvent (int x, int y, int width, int height)
+ {
+// System.out.println ("x + insets.left:" + (x + insets.left));
+// System.out.println ("y + insets.top :" + (y + insets.top));
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+ new Rectangle (x + insets.left,
+ y + insets.top,
+ width, height)));
+ }
+}
+
+
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkGenericPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkGenericPeer.java
new file mode 100644
index 0000000..914b7a6
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkGenericPeer.java
@@ -0,0 +1,84 @@
+/* GtkGenericPeer.java - Has a hashcode. Yuck.
+ Copyright (C) 1998, 1999, 2002 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.*;
+
+public class GtkGenericPeer
+{
+ final int native_state = getUniqueInteger ();
+
+ // Next native state value we will assign.
+ private static int next_native_state = 0;
+
+ // The widget or other java-side object we wrap.
+ protected Object awtWidget;
+
+ // Global event queue.
+ protected static EventQueue q = null;
+
+ // Dispose of our native state.
+ public native void dispose ();
+
+ protected GtkGenericPeer (Object awtWidget)
+ {
+ this.awtWidget = awtWidget;
+ }
+
+ public static void enableQueue (EventQueue sq)
+ {
+ if (q == null)
+ q = sq;
+ }
+
+ protected void postActionEvent (String command, int mods)
+ {
+ q.postEvent (new ActionEvent (awtWidget, ActionEvent.ACTION_PERFORMED,
+ command, mods));
+ }
+
+ // Return a unique integer for use in the native state mapping
+ // code. We can't use a hash code since that is not guaranteed to
+ // be unique.
+ static synchronized int getUniqueInteger ()
+ {
+ // Let's assume this will never wrap.
+ return next_native_state++;
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkImage.java b/libjava/gnu/java/awt/peer/gtk/GtkImage.java
new file mode 100644
index 0000000..f0c8bf4
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkImage.java
@@ -0,0 +1,286 @@
+/* GtkImage.java
+ Copyright (C) 1999, 2002 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.util.*;
+import java.awt.image.*;
+
+public class GtkImage extends Image implements ImageConsumer
+{
+ int width = -1, height = -1;
+ Hashtable props = null;
+ boolean isLoaded = false;
+ boolean isCacheable = true;
+ boolean loading = false;
+
+ Vector widthObservers = new Vector ();
+ Vector heightObservers = new Vector ();
+ Vector propertyObservers = new Vector ();
+
+ ImageProducer source;
+ Graphics g;
+
+ /* Variables in which we stored cached data, if possible.
+
+ An image is cached if the following properties are true:
+ 1. The ColorModel passed into setColorModel is the same ColorModel
+ passed to all invocations of setPixels.
+ 2. The image contains a single frame.
+
+ */
+ int[] pixelCache;
+ ColorModel model;
+
+ public
+ GtkImage (ImageProducer producer, Graphics g)
+ {
+ source = producer;
+ this.g = g;
+
+ source.addConsumer (this);
+ }
+
+ public synchronized int
+ getWidth (ImageObserver observer)
+ {
+ if (width == -1)
+ widthObservers.addElement (observer);
+
+ return width;
+ }
+
+ public synchronized int
+ getHeight (ImageObserver observer)
+ {
+ if (height == -1)
+ heightObservers.addElement (observer);
+
+ return height;
+ }
+
+ public ImageProducer
+ getSource ()
+ {
+ return source;
+ }
+
+ public Graphics
+ getGraphics ()
+ {
+ return g;
+ }
+
+ public synchronized Object
+ getProperty (String name, ImageObserver observer)
+ {
+ if (props == null)
+ {
+ propertyObservers.addElement (observer);
+ return null;
+ }
+
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ public synchronized void
+ flush ()
+ {
+ isLoaded = false;
+ isCacheable = true;
+ width = height = -1;
+ props = null;
+ pixelCache = null;
+ model = null;
+
+ source.removeConsumer (this);
+ source.addConsumer (this);
+ }
+
+ public boolean
+ isLoaded ()
+ {
+ return isLoaded;
+ }
+
+ /* ImageConsumer methods */
+
+ public synchronized void
+ setDimensions (int width, int height)
+ {
+ pixelCache = new int[width*height];
+
+ this.width = width;
+ this.height = height;
+
+ for (int i = 0; i < widthObservers.size (); i++)
+ {
+ ImageObserver io = (ImageObserver) widthObservers.elementAt (i);
+ io.imageUpdate (this, ImageObserver.WIDTH, -1, -1, width, height);
+ }
+
+ for (int i = 0; i < heightObservers.size (); i++)
+ {
+ ImageObserver io = (ImageObserver) heightObservers.elementAt (i);
+ io.imageUpdate (this, ImageObserver.HEIGHT, -1, -1, width, height);
+ }
+ }
+
+ public synchronized void
+ setProperties (Hashtable props)
+ {
+ this.props = props;
+
+ for (int i = 0; i < propertyObservers.size (); i++)
+ {
+ ImageObserver io = (ImageObserver) propertyObservers.elementAt (i);
+ io.imageUpdate (this, ImageObserver.PROPERTIES, -1, -1, width, height);
+ }
+ }
+
+ public synchronized void
+ setColorModel (ColorModel model)
+ {
+ if (this.model == null || this.model == model)
+ this.model = model;
+ else
+ isCacheable = false;
+ }
+
+ public synchronized void
+ setHints (int flags)
+ {
+ }
+
+ public synchronized void
+ setPixels (int x, int y, int width, int height, ColorModel cm, byte[] pixels,
+ int offset, int scansize)
+ {
+ setPixels (x, y, width, height, cm, convertPixels (pixels), offset,
+ scansize);
+ }
+
+ public synchronized void
+ setPixels (int x, int y, int width, int height, ColorModel cm, int[] pixels,
+ int offset, int scansize)
+ {
+ loading = true;
+
+ if (!isCacheable)
+ return;
+
+ if (cm != model || pixelCache == null)
+ {
+ isCacheable = false;
+ return;
+ }
+
+ if (scansize == width)
+ {
+ System.arraycopy (pixels, offset,
+ pixelCache, y * this.width + x,
+ pixels.length - offset);
+ }
+ else // skip over scansize-width for each row
+ {
+ for (int i = 0; i < height; i++)
+ System.arraycopy (pixels, offset + (i * scansize),
+ pixelCache, (y + i) * this.width + x,
+ width);
+ }
+ }
+
+ public synchronized void
+ imageComplete (int status)
+ {
+ if (status == ImageConsumer.STATICIMAGEDONE && isCacheable)
+ isLoaded = true;
+
+ if (status == ImageConsumer.SINGLEFRAMEDONE)
+ isCacheable = false;
+
+ source.removeConsumer (this);
+ }
+
+ public synchronized void
+ startProduction (GtkImagePainter painter)
+ {
+ if (isLoaded)
+ {
+ painter.setDimensions (width, height);
+ painter.setPixels (0, 0, width, height, model, pixelCache, 0, width);
+ }
+ else
+ {
+ source.startProduction (painter);
+ source.removeConsumer (painter);
+ }
+ }
+
+ private int[]
+ convertPixels (byte[] pixels)
+ {
+ int ret[] = new int[pixels.length];
+
+ for (int i = 0; i < pixels.length; i++)
+ ret[i] = pixels[i];
+
+ return ret;
+ }
+
+ synchronized int
+ checkImage ()
+ {
+ int bits = 0;
+
+ if (width != -1)
+ bits |= ImageObserver.WIDTH;
+ if (height != -1)
+ bits |= ImageObserver.HEIGHT;
+ if (props != null)
+ bits |= ImageObserver.PROPERTIES;
+ if (loading)
+ bits |= ImageObserver.SOMEBITS;
+ if (isLoaded)
+ bits |= ImageObserver.ALLBITS;
+
+ return bits;
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkImagePainter.java b/libjava/gnu/java/awt/peer/gtk/GtkImagePainter.java
new file mode 100644
index 0000000..3ea22cd
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkImagePainter.java
@@ -0,0 +1,239 @@
+/* GtkImagePainter.java
+ Copyright (C) 1999, 2000 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.image.*;
+import java.util.*;
+
+public class GtkImagePainter implements Runnable, ImageConsumer
+{
+ GtkImage image;
+ GdkGraphics gc;
+ int startX, startY;
+ int redBG;
+ int greenBG;
+ int blueBG;
+ double affine[];
+ int width, height;
+ boolean flipX, flipY;
+ Rectangle clip;
+ int s_width, s_height;
+
+ public
+ GtkImagePainter (GtkImage image, GdkGraphics gc, int x, int y,
+ int width, int height, Color bgcolor)
+ {
+ this.image = image;
+ this.gc = (GdkGraphics) gc.create ();
+ startX = x;
+ startY = y;
+ redBG = bgcolor.getRed ();
+ greenBG = bgcolor.getGreen ();
+ blueBG = bgcolor.getBlue ();
+ this.width = width;
+ this.height = height;
+ flipX = flipY = false;
+ s_width = s_height = 0;
+ clip = null;
+
+ new Thread (this).start ();
+ }
+
+ public
+ GtkImagePainter (GtkImage image, GdkGraphics gc,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor)
+ {
+ this.image = image;
+ this.gc = (GdkGraphics) gc.create ();
+ startX = (dx1 < dx2) ? dx1 : dx2;
+ startY = dy1;
+ redBG = bgcolor.getRed ();
+ greenBG = bgcolor.getGreen ();
+ blueBG = bgcolor.getBlue ();
+
+ this.width = Math.abs (dx2 - dx1);
+ this.height = Math.abs (dy2 - dy1);
+
+ flipX = ((dx1 > dx2 && sx2 > sx1)
+ || (dx1 < dx2 && sx2 < sx1));
+
+ flipY = ((dy1 > dy2 && sy2 > sy1)
+ || (dy1 < dy2 && sy2 < sy1));
+
+ s_width = Math.abs (sx2 - sx1);
+ s_height = Math.abs (sy2 - sy1);
+ clip = new Rectangle (sx1, sy1, s_width, s_height);
+
+ new Thread (this).start ();
+ }
+
+ public void
+ run ()
+ {
+ image.startProduction (this);
+ gc.dispose ();
+ }
+
+ /* Convert pixel data into a format that gdkrgb can understand */
+ static int[]
+ convertPixels (int[] pixels, ColorModel model)
+ {
+ if (model.equals (ColorModel.getRGBdefault ()))
+ return pixels;
+
+ int ret[] = new int[pixels.length];
+
+ for (int i = 0; i < pixels.length; i++)
+ ret[i] = model.getRGB (pixels[i]);
+
+ return ret;
+ }
+
+ static int[]
+ convertPixels (byte[] pixels, ColorModel model)
+ {
+ int ret[] = new int[pixels.length];
+
+ for (int i = 0; i < pixels.length; i++)
+ ret[i] = model.getRGB (pixels[i]);
+
+ return ret;
+ }
+
+ native void
+ drawPixels (GdkGraphics gc, int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height, int[] pixels, int offset,
+ int scansize, double affine[]);
+
+
+ public void
+ setPixels (int x, int y, int width, int height, ColorModel model,
+ int[] pixels, int offset, int scansize)
+ {
+ if (clip != null)
+ {
+ Rectangle r;
+ r = clip.intersection (new Rectangle (x, y, width, height));
+ if (r.width == 0 && r.height == 0)
+ return;
+
+ offset += r.y * scansize + r.x;
+
+ r.translate (-Math.abs (clip.x - startX), -Math.abs (clip.y - startY));
+
+ width = r.width;
+ height = r.height;
+ x = r.x;
+ y = r.y;
+ }
+
+ drawPixels (gc, redBG, greenBG, blueBG,
+ startX + x, startY + y,
+ width, height, convertPixels (pixels, model), offset,
+ scansize, affine);
+ }
+
+ public void
+ setPixels (int x, int y, int width, int height, ColorModel model,
+ byte[] pixels, int offset, int scansize)
+ {
+ setPixels (x, y, width, height, model, convertPixels (pixels, model),
+ offset, scansize);
+ }
+
+ public void
+ setDimensions (int width, int height)
+ {
+ if (!flipX && !flipY &&
+ ((this.width == -1 && this.height == -1)
+ || (this.width == width && this.height == height)))
+ return;
+
+ affine = new double[6];
+ affine[1] = affine[2] = affine[4] = affine[5] = 0;
+
+ if (clip != null)
+ {
+ affine[0] = this.width / (double) s_width;
+ affine[3] = this.height / (double) s_height;
+ }
+ else
+ {
+ affine[0] = this.width / (double) width;
+ affine[3] = this.height / (double) height;
+ }
+
+ if (flipX)
+ {
+ affine[0] = -affine[0];
+ affine[4] = this.width;
+ }
+
+ if (flipY)
+ {
+ affine[3] = -affine[3];
+ affine[5] = this.height;
+ }
+
+ if (affine[0] == 1 && affine[3] == 1)
+ affine = null;
+ }
+
+ public void
+ setProperties (Hashtable props)
+ {
+ }
+
+ public void
+ setColorModel (ColorModel model)
+ {
+ }
+
+ public void
+ setHints (int flags)
+ {
+ }
+
+ public void
+ imageComplete (int status)
+ {
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java
new file mode 100644
index 0000000..5cd3fb7
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java
@@ -0,0 +1,88 @@
+/* GtkLabelPeer.java -- Implements LabelPeer with GTK
+ Copyright (C) 1998, 1999 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.peer.*;
+
+public class GtkLabelPeer extends GtkComponentPeer
+ implements LabelPeer
+{
+ native void create ();
+
+ public GtkLabelPeer (Label l)
+ {
+ super (l);
+ }
+
+ public void setText (String text)
+ {
+ set ("label", text);
+ }
+
+ public void setAlignment (int alignment)
+ {
+ set ("xalign", getGtkAlignment (alignment));
+ }
+
+ float getGtkAlignment (int alignment)
+ {
+ switch (alignment)
+ {
+ case Label.LEFT:
+ return 0.0f;
+ case Label.CENTER:
+ return 0.5f;
+ case Label.RIGHT:
+ return 1.0f;
+ }
+
+ return 0.0f;
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ super.getArgs (component, args);
+
+ Label label = (Label) component;
+
+ args.add ("label", label.getText ());
+ args.add ("xalign", getGtkAlignment (label.getAlignment ()));
+ args.add ("yalign", 0.5f);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java
new file mode 100644
index 0000000..6686457
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java
@@ -0,0 +1,126 @@
+/* GtkListPeer.java -- Implements ListPeer with GTK
+ Copyright (C) 1998, 1999 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.peer.*;
+
+public class GtkListPeer extends GtkComponentPeer
+ implements ListPeer
+{
+// native void create (ComponentPeer parent, String [] items, boolean mode);
+
+ native void create ();
+ native void connectHooks ();
+
+ native void getSize (int rows, int dims[]);
+
+ public GtkListPeer (List list)
+ {
+ super (list);
+
+ setMultipleMode (list.isMultipleMode ());
+
+ if (list.getItemCount () > 0)
+ append (list.getItems ());
+ }
+
+ native void append (String items[]);
+
+ public native void add (String item, int index);
+
+ public void addItem (String item, int index)
+ {
+ add (item, index);
+ }
+
+ public void clear ()
+ {
+ removeAll ();
+ }
+
+ public native void delItems (int start, int end);
+ public native void deselect (int index);
+
+ public Dimension getMinimumSize (int rows)
+ {
+ int dims[] = new int[2];
+
+ getSize (rows, dims);
+ return (new Dimension (dims[0], dims[1]));
+ }
+
+ public Dimension getPreferredSize (int rows)
+ {
+ int dims[] = new int[2];
+
+ getSize (rows, dims);
+ return (new Dimension (dims[0], dims[1]));
+ }
+
+ public native int[] getSelectedIndexes ();
+ public native void makeVisible (int index);
+
+ public Dimension minimumSize (int rows)
+ {
+ return (getMinimumSize (rows));
+ }
+
+ public Dimension preferredSize (int rows)
+ {
+ return (getPreferredSize (rows));
+ }
+
+ public void removeAll ()
+ {
+ delItems (0, -1);
+ }
+
+ public native void select (int index);
+ public native void setMultipleMode (boolean b);
+
+ public void setMultipleSelections (boolean b)
+ {
+ setMultipleMode (b);
+ }
+
+ protected void postItemEvent (int item, int stateChange)
+ {
+ postItemEvent (new Integer (item), stateChange);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java b/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java
new file mode 100644
index 0000000..6efa841
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java
@@ -0,0 +1,80 @@
+/* GtkMainThread.java -- Runs gtk_main()
+ Copyright (C) 1998, 1999 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;
+
+public class GtkMainThread extends GtkGenericPeer implements Runnable
+{
+ private static Thread mainThread = null;
+ private static Object mainThreadLock = new Object();
+
+ static native void gtkInit();
+ native void gtkMain();
+
+ public GtkMainThread()
+ {
+ super (null);
+ synchronized (mainThreadLock)
+ {
+ if (mainThread != null)
+ throw new IllegalStateException();
+ mainThread = new Thread(this, "GtkMain");
+ }
+
+ synchronized (this)
+ {
+ mainThread.start();
+ try {
+ wait();
+ } catch (InterruptedException e) { }
+ }
+ }
+
+ public void run()
+ {
+ synchronized (this)
+ {
+ gtkInit();
+ notify();
+ }
+ gtkMain();
+ }
+}
+
+
+
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
new file mode 100644
index 0000000..6ceb864
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
@@ -0,0 +1,69 @@
+/* GtkMenuBarPeer.java -- Implements MenuBarPeer with GTK+
+ Copyright (C) 1999 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.peer.MenuBarPeer;
+import java.awt.peer.MenuPeer;
+
+public class GtkMenuBarPeer extends GtkMenuComponentPeer
+ implements MenuBarPeer
+{
+
+ native void create ();
+ native void addMenu (MenuPeer menu);
+
+ public GtkMenuBarPeer (MenuBar target)
+ {
+ super (target);
+ create ();
+ }
+
+ /* In Gnome, help menus are no longer right flushed. */
+ public void addHelpMenu (Menu menu)
+ {
+ addMenu (menu);
+ }
+
+ public void addMenu (Menu menu)
+ {
+ addMenu ((MenuPeer) menu.getPeer ());
+ }
+
+ native public void delMenu (int index);
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
new file mode 100644
index 0000000..e04ce99
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
@@ -0,0 +1,54 @@
+/* GtkMenuComponentPeer.java -- Implements MenuComponentPeer with GTK+
+ Copyright (C) 1999 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.peer.MenuComponentPeer;
+
+public class GtkMenuComponentPeer extends GtkGenericPeer
+ implements MenuComponentPeer
+{
+ public GtkMenuComponentPeer (Object awtWidget)
+ {
+ super (awtWidget);
+ }
+
+ public void dispose ()
+ {
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
new file mode 100644
index 0000000..1428011
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
@@ -0,0 +1,92 @@
+/* GtkMenuItemPeer.java -- Implements MenuItemPeer with GTK+
+ Copyright (C) 1999 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.peer.MenuItemPeer;
+import java.awt.peer.MenuComponentPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.MenuPeer;
+
+public class GtkMenuItemPeer extends GtkMenuComponentPeer
+ implements MenuItemPeer
+{
+ native void create (String label);
+
+ public GtkMenuItemPeer (MenuItem item)
+ {
+ super (item);
+ create (item.getLabel ());
+ setEnabled (item.isEnabled ());
+ setParent (item);
+ }
+
+ void setParent (MenuItem item)
+ {
+ // add ourself differently, based on what type of parent we have
+ // yes, the typecasting here is nasty.
+ Object parent = item.getParent ();
+ if (parent instanceof MenuBar)
+ {
+ ((GtkMenuBarPeer)((MenuBar)parent).getPeer ()).addMenu ((MenuPeer) this);
+ }
+ else // parent instanceof Menu
+ {
+ ((GtkMenuPeer)((Menu)parent).getPeer ()).addItem (this,
+ item.getShortcut ());
+ }
+ }
+
+ public void disable ()
+ {
+ setEnabled (false);
+ }
+
+ public void enable ()
+ {
+ setEnabled (true);
+ }
+
+ native public void setEnabled (boolean b);
+ native public void setLabel (String label);
+
+ protected void postMenuActionEvent ()
+ {
+ postActionEvent (((MenuItem)awtWidget).getActionCommand (), 0);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java
new file mode 100644
index 0000000..51733a6
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java
@@ -0,0 +1,99 @@
+/* GtkMenuPeer.java -- Implements MenuPeer with GTK+
+ Copyright (C) 1999 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.peer.MenuPeer;
+import java.awt.peer.MenuItemPeer;
+
+public class GtkMenuPeer extends GtkMenuItemPeer
+ implements MenuPeer
+{
+ native void create (String label);
+ native void addItem (MenuItemPeer item, int key, boolean shiftModifier);
+ native void setupAccelGroup (GtkGenericPeer container);
+
+ public GtkMenuPeer (Menu menu)
+ {
+ super (menu);
+
+ MenuContainer parent = menu.getParent ();
+ if (parent instanceof Menu)
+ setupAccelGroup ((GtkGenericPeer)((Menu)parent).getPeer ());
+ else if (parent instanceof Component)
+ setupAccelGroup ((GtkGenericPeer)((Component)parent).getPeer ());
+ else
+ setupAccelGroup (null);
+ }
+
+ public void addItem (MenuItem item)
+ {
+ int key = 0;
+ boolean shiftModifier = false;
+
+ MenuShortcut ms = item.getShortcut ();
+ if (ms != null)
+ {
+ key = ms.getKey ();
+ shiftModifier = ms.usesShiftModifier ();
+ }
+
+ addItem ((MenuItemPeer) item.getPeer (), key, shiftModifier);
+ }
+
+ public void addItem (MenuItemPeer item, MenuShortcut ms)
+ {
+ int key = 0;
+ boolean shiftModifier = false;
+
+ if (ms != null)
+ {
+ key = ms.getKey ();
+ shiftModifier = ms.usesShiftModifier ();
+ }
+
+ addItem (item, key, shiftModifier);
+ }
+
+ public void addSeparator ()
+ {
+ addItem (new MenuItem ("-"));
+ }
+
+ native public void delItem (int index);
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java b/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java
new file mode 100644
index 0000000..135fbf6
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java
@@ -0,0 +1,87 @@
+/* GtkOffScreenImage.java
+ Copyright (C) 1999 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.image.*;
+
+public class GtkOffScreenImage extends Image
+{
+ int width, height;
+ ImageProducer source;
+ Graphics g;
+
+ public GtkOffScreenImage (ImageProducer source, Graphics g,
+ int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+
+ this.source = source;
+ this.g = g;
+ }
+
+ public int getWidth (ImageObserver observer)
+ {
+ return width;
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ return height;
+ }
+
+ public ImageProducer getSource ()
+ {
+ return source;
+ }
+
+ public Graphics getGraphics ()
+ {
+ return g;
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ return Image.UndefinedProperty;
+ }
+
+ public void flush ()
+ {
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkPanelPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkPanelPeer.java
new file mode 100644
index 0000000..168e075
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkPanelPeer.java
@@ -0,0 +1,53 @@
+/* GtkPanelPeer.java -- Implements PanelPeer with GTK
+ Copyright (C) 1998, 1999 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.peer.*;
+import java.awt.*;
+
+public class GtkPanelPeer extends GtkContainerPeer
+ implements PanelPeer
+{
+ native void create ();
+ native void connectHooks ();
+
+ public GtkPanelPeer (Panel p)
+ {
+ super (p);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java
new file mode 100644
index 0000000..c7a645a
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java
@@ -0,0 +1,65 @@
+/* GtkPopupMenuPeer.java -- Implements PopupMenuPeer with GTK+
+ Copyright (C) 1999 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.peer.ComponentPeer;
+import java.awt.peer.PopupMenuPeer;
+
+public class GtkPopupMenuPeer extends GtkMenuPeer
+ implements PopupMenuPeer
+{
+ public GtkPopupMenuPeer (PopupMenu menu)
+ {
+ super (menu);
+ }
+
+ native void setupAccelGroup (GtkGenericPeer container);
+
+ void setParent (MenuItem item)
+ {
+ // we don't need to "add" ourselves to our parent
+ }
+
+ native void show (int x, int y, long time);
+ public void show (Component origin, int x, int y)
+ {
+ Point abs = origin.getLocationOnScreen ();
+ show (abs.x + x, abs.y + y, 0);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
new file mode 100644
index 0000000..9abde2a
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
@@ -0,0 +1,91 @@
+/* GtkScrollPanePeer.java -- Implements ScrollPanePeer with GTK
+ Copyright (C) 1998, 1999 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.peer.*;
+import java.awt.*;
+
+public class GtkScrollPanePeer extends GtkContainerPeer
+ implements ScrollPanePeer
+{
+ native void create ();
+
+ native void gtkScrolledWindowNew(ComponentPeer parent,
+ int policy, int w, int h, int[] dims);
+ native void gtkScrolledWindowSetScrollPosition(int x, int y);
+ native void gtkScrolledWindowSetHScrollIncrement (int u);
+ native void gtkScrolledWindowSetVScrollIncrement (int u);
+ native void gtkScrolledWindowSetSize(int w, int h);
+
+ public GtkScrollPanePeer (ScrollPane sp)
+ {
+ super (sp);
+
+ setPolicy (sp.getScrollbarDisplayPolicy ());
+ }
+
+ native void setPolicy (int policy);
+ native public void childResized (int width, int height);
+ native public int getHScrollbarHeight ();
+ native public int getVScrollbarWidth ();
+ native public void setScrollPosition (int x, int y);
+
+// public Dimension getPreferredSize ()
+// {
+// return new Dimension (60, 60);
+// }
+
+ public void setUnitIncrement (Adjustable adj, int u)
+ {
+ if (adj.getOrientation()==Adjustable.HORIZONTAL)
+ gtkScrolledWindowSetHScrollIncrement (u);
+ else
+ gtkScrolledWindowSetVScrollIncrement (u);
+ }
+
+ public void setValue (Adjustable adj, int v)
+ {
+// System.out.println("SPP: setVal: "+adj+":"+v);
+// Point p=myScrollPane.getScrollPosition ();
+// if (adj.getOrientation()==Adjustable.HORIZONTAL)
+// gtkScrolledWindowSetScrollPosition (v,p.y);
+// else
+// gtkScrolledWindowSetScrollPosition (p.x,v);
+// adj.setValue(v);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
new file mode 100644
index 0000000..07aee67
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java
@@ -0,0 +1,78 @@
+/* GtkScrollbarPeer.java -- Implements ScrollbarPeer with GTK+
+ Copyright (C) 1998, 1999 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.peer.*;
+import java.awt.event.AdjustmentEvent;
+
+public class GtkScrollbarPeer extends GtkComponentPeer
+ implements ScrollbarPeer
+{
+ void create ()
+ {
+ Scrollbar sb = (Scrollbar) awtComponent;
+
+ create (sb.getOrientation (), sb.getValue (),
+ sb.getMinimum (), sb.getMaximum (),
+ sb.getUnitIncrement (), sb.getBlockIncrement (),
+ sb.getVisibleAmount ());
+ }
+
+ native void create (int orientation, int value,
+ int min, int max, int stepIncr, int pageIncr,
+ int visibleAmount);
+
+ native void connectHooks ();
+
+ public GtkScrollbarPeer (Scrollbar s)
+ {
+ super (s);
+ }
+
+ native public void setLineIncrement (int amount);
+ native public void setPageIncrement (int amount);
+ native public void setValues (int value, int visible, int min, int max);
+
+ protected void postAdjustmentEvent (int type, int value)
+ {
+ q.postEvent (new AdjustmentEvent ((Adjustable)awtComponent,
+ AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
+ type, value));
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
new file mode 100644
index 0000000..7a648b9
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
@@ -0,0 +1,102 @@
+/* GtkTextAreaPeer.java -- Implements TextAreaPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.peer.*;
+import java.awt.*;
+
+public class GtkTextAreaPeer extends GtkTextComponentPeer
+ implements TextAreaPeer
+{
+ native void create (int scrollbarVisibility);
+
+ void create ()
+ {
+ create (((TextArea)awtComponent).getScrollbarVisibility ());
+ }
+
+ // native void create (Object parent, String text, int scroll);
+ native void gtkTextGetSize (int rows, int cols, int dims[]);
+
+ public GtkTextAreaPeer (TextArea ta)
+ {
+ super (ta);
+ }
+
+ public native void insert (String str, int pos);
+ public native void replaceRange (String str, int start, int end);
+
+ public Dimension getMinimumSize (int rows, int cols)
+ {
+ int dims[] = new int[2];
+
+ gtkTextGetSize (rows, cols, dims);
+
+ return (new Dimension (dims[0], dims[1]));
+ }
+
+ public Dimension getPreferredSize (int rows, int cols)
+ {
+ int dims[] = new int[2];
+
+ gtkTextGetSize (rows, cols, dims);
+
+ return (new Dimension (dims[0], dims[1]));
+ }
+
+ /* Deprecated */
+ public Dimension minimumSize (int rows, int cols)
+ {
+ return getMinimumSize (rows, cols);
+ }
+
+ public Dimension preferredSize (int rows, int cols)
+ {
+ return getPreferredSize (rows, cols);
+ }
+
+ public void replaceText (String str, int start, int end)
+ {
+ replaceRange (str, start, end);
+ }
+
+ public void insertText (String str, int pos)
+ {
+ insert (str, pos);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java
new file mode 100644
index 0000000..b9205cc
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java
@@ -0,0 +1,79 @@
+/* GtkTextComponentPeer.java -- Implements TextComponentPeer with GTK
+ Copyright (C) 1998, 1999 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.peer.*;
+import java.awt.*;
+
+public class GtkTextComponentPeer extends GtkComponentPeer
+ implements TextComponentPeer
+{
+ GtkTextComponentPeer (TextComponent tc)
+ {
+ super (tc);
+
+ setText (tc.getText ());
+ }
+
+ public native int getCaretPosition ();
+ public void setCaretPosition (int pos)
+ {
+ set ("text_position", pos);
+ }
+ public native int getSelectionStart ();
+ public native int getSelectionEnd ();
+ public native String getText ();
+ public native void select (int start, int end);
+
+ public void setEditable (boolean state)
+ {
+ set ("editable", state);
+ }
+
+ public native void setText (String text);
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ super.getArgs (component, args);
+
+ TextComponent tc = (TextComponent) component;
+
+ args.add ("text_position", tc.getCaretPosition ());
+ args.add ("editable", tc.isEditable ());
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
new file mode 100644
index 0000000..4dc23f8
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
@@ -0,0 +1,98 @@
+/* GtkTextFieldPeer.java -- Implements TextFieldPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.peer.*;
+import java.awt.*;
+
+public class GtkTextFieldPeer extends GtkTextComponentPeer
+ implements TextFieldPeer
+{
+
+// native void create (ComponentPeer parent, String text);
+
+ native void create ();
+ native void createHooks ();
+
+ native void gtkEntryGetSize (int cols, int dims[]);
+
+ public GtkTextFieldPeer (TextField tf)
+ {
+ super (tf);
+
+ if (tf.echoCharIsSet ())
+ setEchoChar (tf.getEchoChar ());
+ }
+
+ public Dimension getMinimumSize (int cols)
+ {
+ int dims[] = new int[2];
+
+ gtkEntryGetSize (cols, dims);
+
+ return (new Dimension (dims[0], dims[1]));
+ }
+
+ public Dimension getPreferredSize (int cols)
+ {
+ int dims[] = new int[2];
+
+ gtkEntryGetSize (cols, dims);
+
+ return (new Dimension (dims[0], dims[1]));
+ }
+
+ public native void setEchoChar (char c);
+
+ /* Deprecated */
+
+ public Dimension minimumSize (int cols)
+ {
+ return getMinimumSize (cols);
+ }
+
+ public Dimension preferredSize (int cols)
+ {
+ return getPreferredSize (cols);
+ }
+
+ public void setEchoCharacter (char c)
+ {
+ setEchoChar (c);
+ }
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java
new file mode 100644
index 0000000..ffdc910
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -0,0 +1,329 @@
+/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
+ Copyright (C) 1998, 1999, 2002, 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.datatransfer.*;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.image.*;
+import java.awt.peer.*;
+import java.net.*;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import gnu.java.awt.image.*;
+import gnu.classpath.Configuration;
+
+/* This class uses a deprecated method java.awt.peer.ComponentPeer.getPeer().
+ This merits comment. We are basically calling Sun's bluff on this one.
+ We think Sun has deprecated it simply to discourage its use as it is
+ bad programming style. However, we need to get at a component's peer in
+ this class. If getPeer() ever goes away, we can implement a hash table
+ that will keep up with every window's peer, but for now this is faster. */
+
+public class GtkToolkit extends java.awt.Toolkit
+{
+ GtkMainThread main;
+ Hashtable containers = new Hashtable();
+ static EventQueue q = new EventQueue();
+ static Clipboard systemClipboard;
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("gtkpeer");
+ }
+
+ public GtkToolkit ()
+ {
+ main = new GtkMainThread ();
+ systemClipboard = new GtkClipboard ();
+ GtkGenericPeer.enableQueue (q);
+ }
+
+ native public void beep ();
+ native private void getScreenSizeDimensions (int[] xy);
+
+ public int checkImage (Image image, int width, int height,
+ ImageObserver observer)
+ {
+ return ImageObserver.ALLBITS;
+
+// GtkImage i = (GtkImage) image;
+// return i.checkImage ();
+ }
+
+ public Image createImage (String filename)
+ {
+ // FIXME - gcj local: GdkPixbufDecoder doesn't work.
+ // return new GtkImage (new GdkPixbufDecoder (filename), null);
+ return null;
+ }
+
+ public Image createImage (URL url)
+ {
+ // FIXME - gcj local: GdkPixbufDecoder doesn't work.
+ // return new GtkImage (new GdkPixbufDecoder (url), null);
+ return null;
+ }
+
+ public Image createImage (ImageProducer producer)
+ {
+ return new GtkImage (producer, null);
+ }
+
+ public Image createImage (byte[] imagedata, int imageoffset,
+ int imagelength)
+ {
+ // System.out.println ("createImage byte[] NOT SUPPORTED");
+ return null;
+ }
+
+ public ColorModel getColorModel ()
+ {
+ return ColorModel.getRGBdefault ();
+ }
+
+ public String[] getFontList ()
+ {
+ return (new String[] { "Dialog",
+ "DialogInput",
+ "Monospaced",
+ "Serif",
+ "SansSerif" });
+ }
+
+ public FontMetrics getFontMetrics (Font font)
+ {
+ return new GdkFontMetrics (font);
+ }
+
+ public Image getImage (String filename)
+ {
+ // FIXME - gcj local: GdkPixbufDecoder doesn't work.
+ // return new GtkImage (new GdkPixbufDecoder (filename), null);
+ return null;
+ }
+
+ public Image getImage (URL url)
+ {
+ // FIXME - gcj local: GdkPixbufDecoder doesn't work.
+ // return new GtkImage (new GdkPixbufDecoder (url), null);
+ return null;
+ }
+
+ public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props)
+ {
+ return null;
+ }
+
+ native public int getScreenResolution();
+
+ public Dimension getScreenSize () {
+ int dim[] = new int[2];
+ getScreenSizeDimensions(dim);
+ return new Dimension(dim[0], dim[1]);
+ }
+
+ public Clipboard getSystemClipboard()
+ {
+ return systemClipboard;
+ }
+
+ public boolean prepareImage (Image image, int width, int height,
+ ImageObserver observer)
+ {
+ return false;
+ }
+
+ native public void sync ();
+
+ protected void setComponentState (Component c, GtkComponentPeer cp)
+ {
+ /* Make the Component reflect Peer defaults */
+ if (c.getForeground () == null)
+ c.setForeground (cp.getForeground ());
+ if (c.getBackground () == null)
+ c.setBackground (cp.getBackground ());
+ // if (c.getFont () == null)
+ // c.setFont (cp.getFont ());
+
+ /* Make the Peer reflect the state of the Component */
+ if (! (c instanceof Window))
+ {
+ cp.setCursor (c.getCursor ());
+
+ Rectangle bounds = c.getBounds ();
+ cp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
+ cp.setVisible (c.isVisible ());
+ }
+ }
+
+ protected ButtonPeer createButton (Button b)
+ {
+ return new GtkButtonPeer (b);
+ }
+
+ protected CanvasPeer createCanvas (Canvas c)
+ {
+ return new GtkCanvasPeer (c);
+ }
+
+ protected CheckboxPeer createCheckbox (Checkbox cb)
+ {
+ return new GtkCheckboxPeer (cb);
+ }
+
+ protected CheckboxMenuItemPeer createCheckboxMenuItem (CheckboxMenuItem cmi)
+ {
+ return new GtkCheckboxMenuItemPeer (cmi);
+ }
+
+ protected ChoicePeer createChoice (Choice c)
+ {
+ return new GtkChoicePeer (c);
+ }
+
+ protected DialogPeer createDialog (Dialog d)
+ {
+ return new GtkDialogPeer (d);
+ }
+
+ protected FileDialogPeer createFileDialog (FileDialog fd)
+ {
+ return new GtkFileDialogPeer (fd);
+ }
+
+ protected FramePeer createFrame (Frame f)
+ {
+ return new GtkFramePeer (f);
+ }
+
+ protected LabelPeer createLabel (Label label)
+ {
+ return new GtkLabelPeer (label);
+ }
+
+ protected ListPeer createList (List list)
+ {
+ return new GtkListPeer (list);
+ }
+
+ protected MenuPeer createMenu (Menu m)
+ {
+ return new GtkMenuPeer (m);
+ }
+
+ protected MenuBarPeer createMenuBar (MenuBar mb)
+ {
+ return new GtkMenuBarPeer (mb);
+ }
+
+ protected MenuItemPeer createMenuItem (MenuItem mi)
+ {
+ return new GtkMenuItemPeer (mi);
+ }
+
+ protected PanelPeer createPanel (Panel p)
+ {
+ return new GtkPanelPeer (p);
+ }
+
+ protected PopupMenuPeer createPopupMenu (PopupMenu target)
+ {
+ return new GtkPopupMenuPeer (target);
+ }
+
+ protected ScrollPanePeer createScrollPane (ScrollPane sp)
+ {
+ return new GtkScrollPanePeer (sp);
+ }
+
+ protected ScrollbarPeer createScrollbar (Scrollbar sb)
+ {
+ return new GtkScrollbarPeer (sb);
+ }
+
+ protected TextAreaPeer createTextArea (TextArea ta)
+ {
+ return new GtkTextAreaPeer (ta);
+ }
+
+ protected TextFieldPeer createTextField (TextField tf)
+ {
+ return new GtkTextFieldPeer (tf);
+ }
+
+ protected WindowPeer createWindow (Window w)
+ {
+ return new GtkWindowPeer (w);
+ }
+
+ protected FontPeer getFontPeer (String name, int style)
+ {
+ try {
+ GtkFontPeer fp = new GtkFontPeer (name, style);
+ return fp;
+ } catch (MissingResourceException ex) {
+ return null;
+ }
+ }
+
+ protected EventQueue getSystemEventQueueImpl()
+ {
+ return q;
+ }
+
+ protected void loadSystemColors (int[] systemColors)
+ {
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e)
+ {
+ throw new Error("not implemented");
+ }
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ {
+ throw new Error("not implemented");
+ }
+} // class GtkToolkit
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java
new file mode 100644
index 0000000..7ef667e
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java
@@ -0,0 +1,111 @@
+/* GtkWindowPeer.java -- Implements WindowPeer with GTK
+ Copyright (C) 1998, 1999, 2002 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.peer.*;
+import java.awt.*;
+
+public class GtkWindowPeer extends GtkContainerPeer
+ implements WindowPeer
+{
+ static protected final int GTK_WINDOW_TOPLEVEL = 0;
+ static protected final int GTK_WINDOW_DIALOG = 1;
+ static protected final int GTK_WINDOW_POPUP = 2;
+
+ native void create (int type);
+
+ void create ()
+ {
+ create (GTK_WINDOW_POPUP);
+ }
+
+ native void connectHooks ();
+
+ public GtkWindowPeer (Window window)
+ {
+ super (window);
+
+ Dimension d = window.getSize ();
+ setBounds (0, 0, d.width, d.height);
+ }
+
+ public void getArgs (Component component, GtkArgList args)
+ {
+ args.add ("visible", component.isVisible ());
+ args.add ("sensitive", component.isEnabled ());
+ }
+
+ native public void toBack ();
+ native public void toFront ();
+
+ native public void setBounds (int x, int y, int width, int height);
+
+ public void setTitle (String title)
+ {
+ set ("title", title);
+ }
+
+ native public void setResizable (boolean r);
+
+ protected void postConfigureEvent (int x, int y, int width, int height,
+ int top, int left, int bottom, int right)
+ {
+ /*
+ If our borders change (which often happens when we opaque resize),
+ we need to make sure that a new layout will happen, since Sun
+ forgets to handle this case.
+ */
+ if (insets.top != top
+ || insets.left != left
+ || insets.bottom != bottom
+ || insets.right != right)
+ {
+ awtComponent.invalidate ();
+ }
+
+ insets.top = top;
+ insets.left = left;
+ insets.bottom = bottom;
+ insets.right = right;
+
+ awtComponent.setBounds (x, y, width, height);
+ awtComponent.validate ();
+ }
+
+ native public void setVisible (boolean b);
+}
diff --git a/libjava/gnu/java/awt/peer/gtk/Test.java b/libjava/gnu/java/awt/peer/gtk/Test.java
new file mode 100644
index 0000000..7ecb593
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/Test.java
@@ -0,0 +1,299 @@
+/* Test.java -- Tests the GTK Toolkit
+ Copyright (C) 1998, 1999 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. */
+
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.peer.*;
+import java.awt.datatransfer.*;
+import gnu.java.awt.image.*;
+import java.io.*;
+
+class Test
+{
+ static int xs = 5, ys = 5;
+
+ public static void main(String args[])
+ {
+ if (args.length == 0)
+ {
+ Properties prop=System.getProperties ();
+ prop.put ("awt.toolkit","gnu.java.awt.peer.gtk.GtkToolkit");
+ }
+
+ final Frame f=new Frame();
+ f.setTitle ("Red Hat Classpath");
+
+// f.addComponentListener (new ComponentAdapter() {
+// public void componentMoved (ComponentEvent e) {
+// System.out.println("component moved");
+// }
+// public void componentResized (ComponentEvent e) {
+// System.out.println("component resized");
+// }
+// });
+ f.setSize(200,200);
+
+ Panel pan=new Panel();
+
+ final Label l = new Label ("Pithy Message:");
+ l.setCursor (Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR));
+ pan.add (l);
+
+ TextField tf = new TextField("Hello world!");
+ pan.add(tf);
+
+ final Image img;
+ img = Toolkit.getDefaultToolkit ().createImage (new XBMDecoder ("fvwm.xbm"));
+
+
+ final Canvas ch = new Canvas () {
+
+ public void update (Graphics g)
+ {
+ System.out.println ("update called");
+ super.update (g);
+ }
+ public void paint (Graphics g) {
+ g.drawString("Hello world!", xs+5, ys+10);
+ g.setColor (Color.blue);
+ g.drawLine (xs,ys,xs+20,ys+20);
+
+// System.out.println (TextArea.SCROLLBARS_BOTH);
+// System.out.println (TextArea.SCROLLBARS_HORIZONTAL_ONLY);
+// System.out.println (TextArea.SCROLLBARS_VERTICAL_ONLY);
+
+// Font f1 = new Font ("TimesRoman", Font.PLAIN, 10);
+// System.out.println (f1.getName ());
+// System.out.println (f1.getFamily ());
+
+// Font font = new Font ("Serif", Font.PLAIN, 18);
+// g.setFont (font);
+// g.setXORMode (Color.red);
+
+
+// System.out.println (g.getFontMetrics (font).stringWidth ("foobar"));
+
+// System.out.println (g.drawImage (img, 0, 0, this));
+ }
+ };
+
+ ch.setSize(60, 60);
+// List ch=new List();
+// ch.add("Ding");
+// ch.add("September");
+// ch.add("Red");
+// ch.add("Quassia");
+// ch.add("Pterodactyl");
+
+// ch.addMouseListener(new MouseAdapter() {
+// public void mousePressed(MouseEvent e) {
+// System.out.println("mouse pressed ch");
+// System.out.println("shift = " + e.isShiftDown());
+// System.out.println("meta = " + e.isMetaDown());
+// System.out.println("alt = " + e.isAltDown());
+// System.out.println("ctrl = " + e.isControlDown());
+// System.out.println("x = " + e.getX());
+// System.out.println("y = " + e.getY());
+// System.out.println("clickcount = " + e.getClickCount());
+// System.out.println("when = " + e.getWhen());
+// System.out.println();
+// }
+// public void mouseReleased(MouseEvent e) {
+// System.out.println("mouse released ch");
+// }
+// public void mouseClicked(MouseEvent e) {
+// System.out.println("mouse clicked ch");
+// }
+// });
+
+ pan.add(ch);
+ f.add(pan,"North");
+
+ final ScrollPane sp=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
+ System.out.println ("ALWAYS HERE: " + ScrollPane.SCROLLBARS_ALWAYS);
+ System.out.println ("ALWAYS" + ScrollPane.SCROLLBARS_ALWAYS);
+ System.out.println ("NEEDED" + ScrollPane.SCROLLBARS_AS_NEEDED);
+ System.out.println ("NEVER " + ScrollPane.SCROLLBARS_NEVER);
+
+
+ final Panel p=new Panel();
+ System.out.println ("PREFERED: " + p.getPreferredSize ());
+ p.add(new Button("Stop"));
+ System.out.println ("PREFERED: " + p.getPreferredSize ());
+ p.add(new Button("evil"));
+ System.out.println ("PREFERED: " + p.getPreferredSize ());
+ p.add(new Button("hoarders"));
+ p.add(new Button("use"));
+ p.add(new Button("GNU"));
+ p.add(new Scrollbar(Scrollbar.HORIZONTAL));
+ System.out.println ("PREFERED: " + p.getPreferredSize ());
+
+ sp.add(p);
+ f.add(sp,"South");
+
+ Panel east_panel = new Panel();
+ east_panel.setLayout(new GridLayout (0,1));
+
+// CheckboxGroup group = new CheckboxGroup();
+
+// Checkbox cb=new Checkbox("one", group, true);
+// east_panel.add(cb);
+// cb=new Checkbox("two", group, false);
+// east_panel.add(cb);
+
+// cb.addMouseListener(new MouseAdapter() {
+// public void mousePressed(MouseEvent e) {
+// System.out.println("mouse pressed cb");
+// System.out.println("shift = " + e.isShiftDown());
+// System.out.println("meta = " + e.isMetaDown());
+// System.out.println("alt = " + e.isAltDown());
+// System.out.println("ctrl = " + e.isControlDown());
+// System.out.println("x = " + e.getX());
+// System.out.println("y = " + e.getY());
+// System.out.println("clickcount = " + e.getClickCount());
+// System.out.println("when = " + e.getWhen());
+// System.out.println();
+// }
+// public void mouseReleased(MouseEvent e) {
+// System.out.println("mouse released cb");
+// }
+// public void mouseClicked(MouseEvent e) {
+// System.out.println("mouse clicked cb");
+// }
+// public void mouseEntered(MouseEvent e) {
+// System.out.println("mouse entered cb");
+// }
+// public void mouseExited(MouseEvent e) {
+// System.out.println("mouse exited cb");
+// }
+// });
+
+ f.add(east_panel,"East");
+
+ final Button wb=new Button();
+ wb.setLabel("Destroy Frame on Click");
+ wb.addActionListener (new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ ScrollPanePeer peer = (ScrollPanePeer)sp.getPeer ();
+ if (peer != null)
+ {
+ System.out.println (peer.getHScrollbarHeight ());
+ System.out.println (peer.getVScrollbarWidth ());
+ }
+
+ l.setText ("Hello World!");
+ System.out.println ("PREFERED: " + p.getPreferredSize ());
+
+ final Dialog d = new Dialog (f);
+ d.setModal (true);
+ Button b = new Button ("foobar");
+ b.addMouseListener (new MouseAdapter () {
+ public void mousePressed (MouseEvent me) {
+ System.out.println ("I got called");
+ d.hide ();
+
+// System.out.println (ScrollPane.SCROLLBARS_ALWAYS);
+// System.out.println (ScrollPane.SCROLLBARS_AS_NEEDED);
+// System.out.println (ScrollPane.SCROLLBARS_NEVER);
+ }
+ });
+ d.add (b);
+ d.pack ();
+ d.show ();
+ System.out.println ("hello world");
+// System.out.println ("action listener on wb called");
+// Clipboard clip = Toolkit.getDefaultToolkit ().getSystemClipboard ();
+// StringSelection ss = new StringSelection("123456789");
+// clip.setContents (ss, ss);
+// Transferable t = clip.getContents (this);
+// try {
+// System.out.println (t.getTransferData (DataFlavor.stringFlavor));
+// } catch (Exception ex) {
+// ex.printStackTrace ();
+// }
+// System.exit (0);
+ }
+ });
+
+ wb.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ System.out.println("mouse pressed wb");
+ xs++;
+ ys++;
+ ch.repaint ();
+ }
+ public void mouseReleased(MouseEvent e) {
+ System.out.println("mouse released wb");
+ }
+ public void mouseClicked(MouseEvent e) {
+ System.out.println("mouse clicked wb");
+ }
+ public void mouseEntered(MouseEvent e) {
+ System.out.println("mouse entered wb");
+ }
+ public void mouseExited(MouseEvent e) {
+ System.out.println("mouse exited wb");
+ }
+ });
+
+ f.add(wb,"West");
+
+ f.pack();
+ f.show();
+
+ sp.setScrollPosition (10,0);
+
+ Toolkit t = Toolkit.getDefaultToolkit();
+ /* t.beep(); */
+ System.out.println("screen size: " + t.getScreenSize());
+ System.out.println("resolution : " + t.getScreenResolution());
+// try {
+// Thread.sleep (5000);
+// } catch (InterruptedException e) {}
+// f.setSize(500,500);
+
+ System.out.println ("background of canvas: " + ch.getBackground ());
+ System.out.println ("foreground of canvas: " + ch.getForeground ());
+
+ System.out.println("done");
+ }
+}
+
+
+
diff --git a/libjava/gnu/java/awt/peer/gtk/TestAWT.java b/libjava/gnu/java/awt/peer/gtk/TestAWT.java
new file mode 100644
index 0000000..48cdce1
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/TestAWT.java
@@ -0,0 +1,571 @@
+/* TestAWT.java -- Tests the AWT like testgtk
+ Copyright (C) 1998, 1999, 2002 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. */
+
+import java.awt.List;
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.peer.*;
+
+class TestAWT
+{
+ public static void main(String args[])
+ {
+ if (args.length==0)
+ {
+ Properties prop = System.getProperties ();
+ prop.put ("awt.toolkit", "gnu.java.awt.peer.gtk.GtkToolkit");
+ }
+ MainWindow f = new MainWindow();
+ System.out.println(f.isDisplayable());
+ f.show();
+ System.out.println(f.isDisplayable());
+ }
+}
+
+interface SubWindow
+{
+ public void init ();
+}
+
+class PrettyPanel extends Panel
+{
+ Insets myInsets;
+
+ public PrettyPanel ()
+ {
+ myInsets = new Insets (10, 10, 10, 10);
+ }
+ public Insets getInsets ()
+ {
+ return myInsets;
+ }
+}
+
+abstract class PrettyFrame extends Frame
+{
+ public PrettyFrame ()
+ {
+ ((BorderLayout) getLayout ()).setHgap (5);
+ ((BorderLayout) getLayout ()).setVgap (5);
+ }
+
+// public Insets getInsets()
+// {
+// Insets oldInsets = super.getInsets ();
+// return new Insets (oldInsets.top+10,
+// oldInsets.left+10,
+// oldInsets.bottom+10,
+// oldInsets.right+10);
+// }
+}
+
+abstract class SubFrame extends PrettyFrame implements SubWindow
+{
+ boolean initted = false;
+
+ public void setVisible (boolean visible)
+ {
+ if (!initted && visible)
+ init();
+ super.setVisible (visible);
+ }
+}
+
+class MainWindow extends PrettyFrame implements ActionListener
+{
+ Button closeButton;
+
+ Hashtable windows;
+ Vector buttons;
+
+ void addSubWindow (String name, SubWindow w)
+ {
+ Button b = new Button (name);
+ b.addActionListener (this);
+
+ buttons.addElement (b);
+ windows.put (b, w);
+ }
+
+ MainWindow ()
+ {
+ MenuBar mb = new MenuBar ();
+ Menu menu = new Menu ("File");
+ Menu submenu = new Menu ("Testing");
+ submenu.add (new CheckboxMenuItem ("Foobar"));
+ menu.add (submenu);
+ mb.add (menu);
+
+ setMenuBar (mb);
+
+ add (new Label ("Classpath v0.0.0"), "North");
+
+ closeButton = new Button ("Close");
+ closeButton.addActionListener (this);
+ closeButton.setFont (new Font ("Serif", Font.BOLD | Font.ITALIC, 18));
+ add (closeButton, "South");
+
+ windows = new Hashtable ();
+ buttons = new Vector ();
+
+ addSubWindow ("Buttons", new ButtonsWindow ());
+ addSubWindow ("Cursors", new CursorsWindow ());
+ addSubWindow ("Dialog", new DialogWindow (this));
+ addSubWindow ("File", new FileWindow (this));
+ addSubWindow ("Labels", new LabelWindow ());
+ addSubWindow ("List", new ListWindow ());
+ addSubWindow ("Radio Buttons", new RadioWindow ());
+ addSubWindow ("TextField", new TextFieldWindow ());
+
+ Panel sp = new Panel();
+ PrettyPanel p = new PrettyPanel();
+ p.setLayout (new GridLayout (windows.size(), 1));
+
+ for (Enumeration e = buttons.elements (); e.hasMoreElements (); )
+ {
+ p.add ((Button) e.nextElement ());
+ }
+
+ sp.add (p);
+ add (sp, "Center");
+
+ setSize (200, 86 + (windows.size ()*22));
+ setTitle ("TestAWT");
+ }
+
+ public void actionPerformed (ActionEvent evt)
+ {
+ Button source = (Button) evt.getSource ();
+
+ if (source==closeButton)
+ {
+ System.getProperties ().list (System.out);
+ dispose();
+ System.exit (0);
+ }
+
+ Window w = (Window) windows.get (source);
+ if (w.isVisible ())
+ w.dispose ();
+ else
+ {
+ w.setVisible (true);
+ w.show();
+ }
+ }
+}
+
+class ButtonsWindow extends SubFrame implements ActionListener
+{
+ Button b[] = new Button [9];
+
+ public void init ()
+ {
+ initted = true;
+ Panel p = new Panel ();
+ p.setLayout (new GridLayout (0, 3, 5, 5));
+
+ for (int i=0; i<9; i++)
+ {
+ b[i]=new Button ("button" + (i+1));
+ b[i].addActionListener (this);
+ }
+
+ p.add (b[0]);
+ p.add (b[6]);
+ p.add (b[4]);
+ p.add (b[8]);
+ p.add (b[1]);
+ p.add (b[7]);
+ p.add (b[3]);
+ p.add (b[5]);
+ p.add (b[2]);
+
+ add (p, "North");
+
+ Button cb = new Button ("close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+ add (cb, "South");
+ setTitle ("Buttons");
+ }
+
+ public void actionPerformed (ActionEvent evt)
+ {
+ Button source = (Button) evt.getSource ();
+
+ for (int i=0; i<9; i++)
+ {
+ if (source == b[i])
+ {
+ int i2=((i+1)==9)?0:(i+1);
+ if (b[i2].isVisible())
+ b[i2].setVisible(false);
+ else
+ b[i2].setVisible(true);
+ }
+ }
+ }
+}
+
+
+class DialogWindow extends Dialog implements SubWindow
+{
+ Label text;
+ boolean initted = false;
+
+ public DialogWindow (Frame f)
+ {
+ super (f, true);
+ }
+
+ public void setVisible (boolean visible)
+ {
+ if (!initted && visible)
+ init();
+ super.setVisible (visible);
+ }
+
+ public void init ()
+ {
+ text = new Label ("Dialog Test");
+ text.setAlignment (Label.CENTER);
+
+ add (text, "North");
+ text.setVisible (false);
+
+ Panel p = new PrettyPanel();
+
+ Button cb = new Button ("OK");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e)
+ {
+ dispose();
+ }
+ });
+
+ p.setLayout (new GridLayout (1, 2));
+ ((GridLayout) p.getLayout ()).setHgap (5);
+ ((GridLayout) p.getLayout ()).setVgap (5);
+ p.add (cb);
+
+ Button toggle = new Button ("Toggle");
+ p.add (toggle);
+
+ toggle.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e)
+ {
+ if (text.isVisible ())
+ text.setVisible (false);
+ else
+ text.setVisible (true);
+ doLayout();
+ }
+ });
+
+ add (p, "South");
+ setTitle ("Dialog");
+ setSize (130, 70);
+ }
+}
+
+class CursorsWindow extends SubFrame implements ItemListener
+{
+ Choice cursorChoice;
+ Canvas cursorCanvas;
+
+ public void init ()
+ {
+ cursorChoice = new Choice();
+ cursorChoice.add ("Default");
+ cursorChoice.add ("Crosshair");
+ cursorChoice.add ("Text");
+ cursorChoice.add ("Wait");
+ cursorChoice.add ("Southwest Resize");
+ cursorChoice.add ("Southeast Resize");
+ cursorChoice.add ("Northwest Resize");
+ cursorChoice.add ("Northeast Resize");
+ cursorChoice.add ("North Resize");
+ cursorChoice.add ("South Resize");
+ cursorChoice.add ("West Resize");
+ cursorChoice.add ("East Resize");
+ cursorChoice.add ("Hand");
+ cursorChoice.add ("Move");
+
+ cursorChoice.addItemListener(this);
+
+ add (cursorChoice, "North");
+
+ cursorCanvas = new Canvas ()
+ {
+ public void paint (Graphics g)
+ {
+ Dimension d = this.getSize();
+ g.setColor (Color.white);
+ g.fillRect (0, 0, d.width, d.height/2);
+ g.setColor (Color.black);
+ g.fillRect (0, d.height/2, d.width, d.height/2);
+ g.setColor (this.getBackground());
+ g.fillRect (d.width/3, d.height/3, d.width/3,
+ d.height/3);
+ }
+ };
+
+ cursorCanvas.setSize (80,80);
+
+ add (cursorCanvas, "Center");
+
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("Cursors");
+ setSize (160, 180);
+ }
+
+ public void itemStateChanged (ItemEvent e)
+ {
+ cursorCanvas.setCursor (Cursor.getPredefinedCursor (cursorChoice.getSelectedIndex()));
+ }
+}
+
+class TextFieldWindow extends SubFrame implements ItemListener
+{
+ Checkbox editable, visible, sensitive;
+ TextField text;
+
+ public void init ()
+ {
+ initted = true;
+ text = new TextField ("hello world");
+ add (text, "North");
+
+ Panel p = new Panel();
+ p.setLayout (new GridLayout (3, 1));
+ ((GridLayout) p.getLayout ()).setHgap (5);
+ ((GridLayout) p.getLayout ()).setVgap (5);
+
+ editable = new Checkbox("Editable", true);
+ p.add (editable);
+ editable.addItemListener (this);
+
+ visible = new Checkbox("Visible", true);
+ p.add (visible);
+ visible.addItemListener (this);
+
+ sensitive = new Checkbox("Sensitive", true);
+ p.add (sensitive);
+ sensitive.addItemListener (this);
+
+ add (p, "Center");
+
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("TextField");
+ setSize (160, 180);
+ }
+
+ public void itemStateChanged (ItemEvent e)
+ {
+ boolean on=true;
+
+ if (e.getStateChange () == ItemEvent.DESELECTED)
+ on=false;
+ if (e.getSource() == editable)
+ text.setEditable (on);
+ if (e.getSource() == visible)
+ if (on)
+ text.setEchoChar ((char) 0);
+ else
+ text.setEchoChar ('*');
+ if (e.getSource() == sensitive)
+ text.setEnabled (on);
+
+ }
+}
+
+class FileWindow extends FileDialog implements SubWindow
+{
+ boolean initted = false;
+
+ public FileWindow (MainWindow mw)
+ {
+ super (mw);
+ }
+
+ public void setVisible (boolean visible)
+ {
+ if (!initted && visible)
+ init();
+ super.setVisible (visible);
+ }
+
+ public void init()
+ {
+ initted = true;
+ }
+}
+
+class LabelWindow extends SubFrame
+{
+ public void init ()
+ {
+ initted = true;
+
+ Panel p = new Panel();
+ p.setLayout (new GridLayout (3, 1));
+ ((GridLayout) p.getLayout ()).setHgap (5);
+ ((GridLayout) p.getLayout ()).setVgap (5);
+
+ p.add (new Label ("left justified label", Label.LEFT));
+ p.add (new Label ("center justified label", Label.CENTER));
+ p.add (new Label ("right justified label", Label.RIGHT));
+
+ add (p, "Center");
+
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("Labels");
+ setSize (160, 180);
+ }
+}
+
+class ListWindow extends SubFrame
+{
+ public void init ()
+ {
+ initted = true;
+
+ Panel p = new Panel ();
+ p.setLayout (new GridLayout (3, 1));
+
+ List l = new List (5, true);
+ for (int i = 0; i < 10; i++)
+ l.add ("added item " + i);
+
+ p.add (l);
+
+ add (p, "Center");
+
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("List");
+ setSize (85, 167);
+ }
+}
+
+
+class RadioWindow extends SubFrame
+{
+ public void init ()
+ {
+ initted = true;
+
+ Panel p = new Panel();
+ p.setLayout (new GridLayout (3, 1));
+ ((GridLayout) p.getLayout ()).setHgap (5);
+ ((GridLayout) p.getLayout ()).setVgap (5);
+
+ final CheckboxGroup cg = new CheckboxGroup();
+ final Checkbox[] boxes = new Checkbox[3];
+ for (int i = 0; i < 3; ++i)
+ {
+ boxes[i] = new Checkbox("button" + i, cg, i == 0);
+ p.add(boxes[i]);
+ }
+
+ add (p, "North");
+
+ p = new Panel();
+ p.setLayout (new GridLayout (1, 3));
+ ((GridLayout) p.getLayout ()).setHgap (5);
+ ((GridLayout) p.getLayout ()).setVgap (5);
+
+ for (int i = 0; i < 3; ++i)
+ {
+ final int val = i;
+ Button tweak = new Button ("Set " + i);
+ tweak.addActionListener(new ActionListener ()
+ {
+ public void actionPerformed (ActionEvent e)
+ {
+ cg.setSelectedCheckbox(boxes[val]);
+ }
+ });
+ p.add(tweak);
+ }
+
+ add (p, "Center");
+
+ Button cb = new Button ("Close");
+ cb.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ add (cb, "South");
+ setTitle ("Radio Buttons");
+ setSize (85, 167);
+ }
+}