diff options
author | (no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-22 18:30:20 +0000 |
---|---|---|
committer | (no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-22 18:30:20 +0000 |
commit | 73216045948b04c125f1455f9ff88d6c0621fb03 (patch) | |
tree | 3a49a11487b68fb02f4291663456f4fffbe926be | |
parent | 08684909fc45c4fe9758da38fa2608d8489d6461 (diff) |
This commit was manufactured by cvs2svn to create tagrtlopt-merge-20030222
'rtlopt-merge-20030222'.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/tags/rtlopt-merge-20030222@63294 138bc75d-0d04-0410-961f-82ee72b054a4
99 files changed, 0 insertions, 16101 deletions
diff --git a/gcc/config/i386/scodbx.h b/gcc/config/i386/scodbx.h deleted file mode 100644 index 7da93053256..00000000000 --- a/gcc/config/i386/scodbx.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Definitions for Intel 386 running SCO Unix System V, - using dbx-in-coff encapsulation. - Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "i386/svr3dbx.h" - -/* Overridden defines for SCO systems from sco.h. */ - -/* By default, target has a 80387, uses IEEE compatible arithmetic, - and returns float values in the 387, ie, - (TARGET_80387 | TARGET_FLOAT_RETURNS_IN_80387) - - SCO's software emulation of a 387 fails to handle the `fucomp' - opcode. fucomp is only used when generating IEEE compliant code. - So don't make TARGET_IEEE_FP default for SCO. */ - -#undef TARGET_SUBTARGET_DEFAULT -#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_FLOAT_RETURNS) - -/* Use crt1.o as a startup file and crtn.o as a closing file. */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{!r:%{!z:svr3.ifile%s}%{z:svr3z.ifile%s}}\ - %{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}" - -/* Library spec, including SCO international language support. */ - -#undef LIB_SPEC -#define LIB_SPEC \ - "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} %{scointl:libintl.a%s} -lc" - -/* Specify predefined symbols in preprocessor. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dunix -DM_UNIX -DM_I386 -DM_COFF -DM_WORDSWAP -Asystem=svr3" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) %{scointl:-DM_INTERNAT}" - -/* This spec is used for telling cpp whether char is signed or not. */ - -#undef SIGNED_CHAR_SPEC -#if DEFAULT_SIGNED_CHAR -#define SIGNED_CHAR_SPEC \ - "%{funsigned-char:-D__CHAR_UNSIGNED__ -D_CHAR_UNSIGNED}" -#else -#define SIGNED_CHAR_SPEC \ - "%{!fsigned-char:-D__CHAR_UNSIGNED__ -D_CHAR_UNSIGNED}" -#endif - -/* caller has to pop the extra argument passed to functions that return - structures. */ - -#undef RETURN_POPS_ARGS -#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ - ((FUNDECL) && TREE_CODE (FUNDECL) == IDENTIFIER_NODE ? 0 \ - : (TARGET_RTD \ - && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ - || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ - == void_type_node))) ? (SIZE) \ - : 0) -/* On other 386 systems, the last line looks like this: - : (aggregate_value_p (TREE_TYPE (FUNTYPE))) ? GET_MODE_SIZE (Pmode) : 0) */ - -/* Handle #pragma pack. */ -#define HANDLE_SYSV_PRAGMA diff --git a/gcc/config/i386/xm-dgux.h b/gcc/config/i386/xm-dgux.h deleted file mode 100644 index 881c5c7be9d..00000000000 --- a/gcc/config/i386/xm-dgux.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Configuration for GCC for Intel i386 running DG/ux */ - -/* looks just like sysv4 for now */ -#include "xm-svr4.h" diff --git a/gcc/config/i386/xm-sun.h b/gcc/config/i386/xm-sun.h deleted file mode 100644 index 6c0f0a25630..00000000000 --- a/gcc/config/i386/xm-sun.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Configuration for GNU C-compiler for Intel 80386 running SunOS 4.0. - Copyright (C) 1988, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#define USG diff --git a/gcc/config/i386/xm-sysv3.h b/gcc/config/i386/xm-sysv3.h deleted file mode 100644 index 9a655443ff5..00000000000 --- a/gcc/config/i386/xm-sysv3.h +++ /dev/null @@ -1,3 +0,0 @@ -/* Configuration for GCC for Intel i386 running System V Release 3. */ - -#include "xm-svr3.h" diff --git a/gcc/fixinc/tests/base/internal/sgimacros.h b/gcc/fixinc/tests/base/internal/sgimacros.h deleted file mode 100644 index fc725697498..00000000000 --- a/gcc/fixinc/tests/base/internal/sgimacros.h +++ /dev/null @@ -1,17 +0,0 @@ -/* DO NOT EDIT THIS FILE. - - It has been auto-edited by fixincludes from: - - "fixinc/tests/inc/internals/sgimacros.h" - - This had to be done to correct non-standard usages in the - original, manufacturer supplied header file. */ - - - -#if defined( IRIX___RESTRICT_CHECK ) -#ifdef __c99 -# ifndef __cplusplus -# define __restrict restrict -# endif -#endif /* IRIX___RESTRICT_CHECK */ diff --git a/gcc/fixinc/tests/base/internal/wchar_core.h b/gcc/fixinc/tests/base/internal/wchar_core.h deleted file mode 100644 index 57951c64603..00000000000 --- a/gcc/fixinc/tests/base/internal/wchar_core.h +++ /dev/null @@ -1,15 +0,0 @@ -/* DO NOT EDIT THIS FILE. - - It has been auto-edited by fixincludes from: - - "fixinc/tests/inc/internals/wchar_core.h" - - This had to be done to correct non-standard usages in the - original, manufacturer supplied header file. */ - - - -#if defined( IRIX_WCSFTIME_CHECK ) -#if _NO_XOPEN5 && !defined(__c99) -extern size_t wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *); -#endif /* IRIX_WCSFTIME_CHECK */ diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C deleted file mode 100644 index c27aa8d2df7..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C +++ /dev/null @@ -1,19 +0,0 @@ -//Build don't link: -#include <vector> -#include <algorithm> - -template <class T> class Expr -{ -public : -Expr(){}; -Expr(const T&){}; -}; - -template <class T > -inline bool compare(const Expr<T> a, const Expr<T> b){ return true; }; - -int main() -{ - std::vector<int> a(3); - std::sort( a.begin(), a.end(), compare ); // ERROR - no matching function -} diff --git a/gcc/testsuite/gcc.dg/cpp/inc/foo.h b/gcc/testsuite/gcc.dg/cpp/inc/foo.h deleted file mode 100644 index ec770476c21..00000000000 --- a/gcc/testsuite/gcc.dg/cpp/inc/foo.h +++ /dev/null @@ -1 +0,0 @@ -extern int a; diff --git a/libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java b/libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java deleted file mode 100644 index 45690b06669..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GdkFontMetrics.java +++ /dev/null @@ -1,108 +0,0 @@ -/* 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 deleted file mode 100644 index 24ea252d4dc..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java +++ /dev/null @@ -1,328 +0,0 @@ -/* 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.*; -import java.text.AttributedCharacterIterator; - -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 drawString (AttributedCharacterIterator ci, int x, int y) - { - throw new Error ("not implemented"); - } - - 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 deleted file mode 100644 index 0491856849c..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkArg.java +++ /dev/null @@ -1,61 +0,0 @@ -/* 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 deleted file mode 100644 index c7770472e7e..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkArgList.java +++ /dev/null @@ -1,75 +0,0 @@ -/* 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 deleted file mode 100644 index a609f7ad818..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java +++ /dev/null @@ -1,96 +0,0 @@ -/* 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 (); - - native void gtkSetFont(String xlfd, int size); - - 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 ()); - } - - public void setFont (Font f) - { - gtkSetFont(((GtkFontPeer)f.getPeer()).getXLFD(), f.getSize()); - } -} diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java deleted file mode 100644 index 59c28f9fd5f..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java +++ /dev/null @@ -1,92 +0,0 @@ -/* 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 deleted file mode 100644 index 9903c310425..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java +++ /dev/null @@ -1,86 +0,0 @@ -/* 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 deleted file mode 100644 index 1bff7069602..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* 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 deleted file mode 100644 index 48f8804007d..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* 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 deleted file mode 100644 index 19e1a56d2e1..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* 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 deleted file mode 100644 index d2587d970a1..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkClipboard.java +++ /dev/null @@ -1,167 +0,0 @@ -/* 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 deleted file mode 100644 index b3a4525314e..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java +++ /dev/null @@ -1,397 +0,0 @@ -/* 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.getFont() != null) - setFont(awtComponent.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) - { - // FIXME: This should really affect the widget tree below me. - // Currently this is only handled if the call is made directly on - // a text widget, which implements setFont() itself. - } - - 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); - - if (p != null) - 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 deleted file mode 100644 index fef88cd6a39..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java +++ /dev/null @@ -1,125 +0,0 @@ -/* 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 deleted file mode 100644 index b47956d4f21..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java +++ /dev/null @@ -1,76 +0,0 @@ -/* 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 deleted file mode 100644 index 3376787d2e5..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java +++ /dev/null @@ -1,70 +0,0 @@ -/* 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 deleted file mode 100644 index d3130a905e9..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java +++ /dev/null @@ -1,94 +0,0 @@ -/* 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; // uses %d for font size. - - public GtkFontPeer (String name, int style) - { - if (bundle != null) - Xname = bundle.getString (name.toLowerCase () + "." + style); - else - { - String weight; - String slant; - String spacing; - - if (style == Font.ITALIC || (style == (Font.BOLD+Font.ITALIC))) - slant = "i"; - else - slant = "r"; - if (style == Font.BOLD || (style == (Font.BOLD+Font.ITALIC))) - weight = "bold"; - else - weight = "medium"; - if (name.equals("Serif") || name.equals("SansSerif") - || name.equals("Helvetica") || name.equals("Times")) - spacing = "p"; - else - spacing = "c"; - - Xname = "-*-*-" + weight + "-" + slant + "-normal-*-%d-*-*-*-" + spacing + "-*-*-*"; - } - } - - 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 deleted file mode 100644 index e16a570938e..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java +++ /dev/null @@ -1,132 +0,0 @@ -/* 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 deleted file mode 100644 index 914b7a6cdeb..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkGenericPeer.java +++ /dev/null @@ -1,84 +0,0 @@ -/* 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 deleted file mode 100644 index f0c8bf410ef..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkImage.java +++ /dev/null @@ -1,286 +0,0 @@ -/* 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 deleted file mode 100644 index 3ea22cd25af..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkImagePainter.java +++ /dev/null @@ -1,239 +0,0 @@ -/* 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 deleted file mode 100644 index 5cd3fb7b327..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkLabelPeer.java +++ /dev/null @@ -1,88 +0,0 @@ -/* 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 deleted file mode 100644 index 6686457ba42..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java +++ /dev/null @@ -1,126 +0,0 @@ -/* 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 deleted file mode 100644 index 6efa8410197..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 deleted file mode 100644 index 6ceb8641481..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* 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 deleted file mode 100644 index e04ce999324..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java +++ /dev/null @@ -1,54 +0,0 @@ -/* 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 deleted file mode 100644 index 1428011133b..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java +++ /dev/null @@ -1,92 +0,0 @@ -/* 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 deleted file mode 100644 index 51733a6f0b6..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java +++ /dev/null @@ -1,99 +0,0 @@ -/* 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 deleted file mode 100644 index 135fbf627c3..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java +++ /dev/null @@ -1,87 +0,0 @@ -/* 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 deleted file mode 100644 index 168e075b28b..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkPanelPeer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* 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 deleted file mode 100644 index c7a645a7cf4..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkPopupMenuPeer.java +++ /dev/null @@ -1,65 +0,0 @@ -/* 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 deleted file mode 100644 index 9abde2ae44b..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java +++ /dev/null @@ -1,91 +0,0 @@ -/* 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 deleted file mode 100644 index 07aee679158..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* 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 deleted file mode 100644 index ad83008cb8a..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java +++ /dev/null @@ -1,109 +0,0 @@ -/* 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); - - native void gtkSetFont(String xlfd, int size); - - 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); - } - - public void setFont (Font f) - { - gtkSetFont(((GtkFontPeer)f.getPeer()).getXLFD(), f.getSize()); - } -} diff --git a/libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java deleted file mode 100644 index b9205cc46ca..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkTextComponentPeer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* 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 deleted file mode 100644 index 628cdd627ae..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java +++ /dev/null @@ -1,105 +0,0 @@ -/* 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[]); - - native void gtkSetFont(String xlfd, int size); - - 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); - } - - public void setFont (Font f) - { - gtkSetFont(((GtkFontPeer)f.getPeer()).getXLFD(), f.getSize()); - } -} diff --git a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java deleted file mode 100644 index ffdc910e8a2..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java +++ /dev/null @@ -1,329 +0,0 @@ -/* 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 deleted file mode 100644 index 7ef667e50ea..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java +++ /dev/null @@ -1,111 +0,0 @@ -/* 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 deleted file mode 100644 index 7ecb593f125..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/Test.java +++ /dev/null @@ -1,299 +0,0 @@ -/* 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 deleted file mode 100644 index 48cdce1a1fe..00000000000 --- a/libjava/gnu/java/awt/peer/gtk/TestAWT.java +++ /dev/null @@ -1,571 +0,0 @@ -/* 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); - } -} diff --git a/libjava/gnu/java/util/prefs/FileBasedFactory.java b/libjava/gnu/java/util/prefs/FileBasedFactory.java deleted file mode 100644 index fc6085feeb5..00000000000 --- a/libjava/gnu/java/util/prefs/FileBasedFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* FileBasedFactory - Default Classpath implementation of a PreferencesFactory - Copyright (C) 2001 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.util.prefs; - -import java.util.prefs.*; - -/** - * Default Classpath implementation of a PreferencesFactory. - * Returns system and user root Preferences nodes that are read from files. - * - * @author Mark Wielaard (mark@klomp.org) - */ -public class FileBasedFactory implements PreferencesFactory { - - public Preferences systemRoot() { - return null; - } - - public Preferences userRoot() { - return null; - } -} diff --git a/libjava/gnu/java/util/prefs/MemoryBasedFactory.java b/libjava/gnu/java/util/prefs/MemoryBasedFactory.java deleted file mode 100644 index ff21066d393..00000000000 --- a/libjava/gnu/java/util/prefs/MemoryBasedFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* MemoryBasedFactory - Memory based PreferencesFactory usefull for testing - Copyright (C) 2001 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.util.prefs; - -import java.util.prefs.*; - -/** - * Memory based PreferencesFactory usefull for testing. - * Returns completely empty Preferences for system and user roots. - * All changes are only backed by the current instances in memory. - * - * @author Mark Wielaard (mark@klomp.org) - */ -public class MemoryBasedFactory implements PreferencesFactory { - - // Static fields containing the preferences root nodes - private static final Preferences systemPreferences - = new MemoryBasedPreferences(null, "", false); - private static final Preferences userPreferences - = new MemoryBasedPreferences(null, "", true); - - public Preferences systemRoot() { - return systemPreferences; - } - - public Preferences userRoot() { - return userPreferences; - } -} diff --git a/libjava/gnu/java/util/prefs/MemoryBasedPreferences.java b/libjava/gnu/java/util/prefs/MemoryBasedPreferences.java deleted file mode 100644 index c1d59c7b1c9..00000000000 --- a/libjava/gnu/java/util/prefs/MemoryBasedPreferences.java +++ /dev/null @@ -1,144 +0,0 @@ -/* MemoryBasedPreferences - A Preference node which holds all entries in memory - Copyright (C) 2001 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.util.prefs; - -import java.util.HashMap; - -import java.util.prefs.*; - -/** - * A Preference node which holds all entries in memory - * - * @author Mark Wielaard (mark@klomp.org) - */ -public class MemoryBasedPreferences extends AbstractPreferences { - - /** True if this is a preference node in the user tree, false otherwise. */ - private final boolean isUser; - - /** Contains all the preference entries of this node. */ - private HashMap entries = new HashMap(); - - /** - * Creates a new preferences node with the given name and parent. - * When isUser is true it will be user node otherwise it will be a system - * node. It will always set the <code>newNode</code> field to true - * since there is no real backing store, so all nodes are new. - */ - public MemoryBasedPreferences(MemoryBasedPreferences parent, - String name, - boolean isUser) { - super(parent, name); - this.isUser = isUser; - - // Since we do not have a real backing store all nodes are new - newNode = true; - } - - /** - * Returns true if this node was created as a user node. - */ - public boolean isUserNode() { - return isUser; - } - - /** - * Returns an empty array since all children names are always already - * chached. - */ - protected String[] childrenNamesSpi() throws BackingStoreException { - return new String[0]; - } - - /** - * Returns a new node with the given name with as parent this node and - * with the <code>isUser</code> flag set to the same value as this node. - */ - protected AbstractPreferences childSpi(String childName) { - return new MemoryBasedPreferences(this, childName, isUser); - } - - /** - * Returns a (possibly empty) array of keys of the preferences entries of - * this node. - */ - protected String[] keysSpi() throws BackingStoreException { - return (String[]) entries.keySet().toArray(new String[entries.size()]); - } - - /** - * Returns the associated value from this nodes preferences entries or - * null when the key has not been set. - */ - protected String getSpi(String key) { - return (String) entries.get(key); - } - - /** - * Sets the value for the given key. - */ - protected void putSpi(String key, String value) { - entries.put(key, value); - } - - /** - * Removes the entry with the given key. - */ - protected void removeSpi(String key) { - entries.remove(key); - } - - /** - * Does nothing since we do not have any backing store. - */ - protected void flushSpi() { - } - - /** - * Does nothing since we do not have any backing store. - */ - protected void syncSpi() { - } - - /** - * Just removes the entries map of this node. - */ - protected void removeNodeSpi() { - entries = null; - } -} diff --git a/libjava/gnu/java/util/prefs/NodeReader.java b/libjava/gnu/java/util/prefs/NodeReader.java deleted file mode 100644 index 6c9fdc9ec06..00000000000 --- a/libjava/gnu/java/util/prefs/NodeReader.java +++ /dev/null @@ -1,223 +0,0 @@ -/* NodeReader - Reads and imports preferences nodes from files - Copyright (C) 2001 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.util.prefs; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.InputStream; -import java.io.IOException; -import java.io.Reader; - -import java.util.prefs.*; - -/** - * Reads and imports preferences nodes from files. - * - * @author Mark Wielaard (mark@klomp.org) - */ -public class NodeReader { - - private final BufferedReader br; - private String line = ""; - - private final PreferencesFactory factory; - - public NodeReader(Reader r, PreferencesFactory factory) { - if(r instanceof BufferedReader) { - br = (BufferedReader) r; - } else { - br = new BufferedReader(r); - } - this.factory = factory; - } - - public NodeReader(InputStream is, PreferencesFactory factory) { - this(new InputStreamReader(is), factory); - } - - public void importPreferences() - throws InvalidPreferencesFormatException, IOException - { - readPreferences(); - } - - private void readPreferences() - throws InvalidPreferencesFormatException, IOException - { - // Begin starting tag - skipTill("<preferences"); - - readRoot(); - - // Ending tag - skipTill("</preferences>"); - } - - private void readRoot() - throws InvalidPreferencesFormatException, IOException - { - // Begin starting tag - skipTill("<root"); - - // type attribute - skipTill("type=\""); - String type = readTill("\""); - Preferences root; - if ("user".equals(type)) { - root = factory.userRoot(); - } else if ("system".equals(type)) { - root = factory.systemRoot(); - } else { - throw new InvalidPreferencesFormatException("Unknown type: " - + type); - } - - // Read root map and subnodes - readMap(root); - readNodes(root); - - // Ending tag - skipTill("</root>"); - } - - private void readNodes(Preferences node) - throws InvalidPreferencesFormatException, IOException - { - while ("node".equals(nextTag())) { - skipTill("<node"); - skipTill("name=\""); - String name = readTill("\""); - Preferences subnode = node.node(name); - System.out.println("Found subnode: " + subnode.absolutePath()); - readMap(subnode); - readNodes(subnode); - skipTill("</node>"); - } - - } - - private void readMap(Preferences node) - throws InvalidPreferencesFormatException, IOException - { - // Begin map tag - skipTill("<map"); - - // Empty map? - if (line.startsWith("/>")) { - line = line.substring(2); - return; - } - - // Map entries - readEntries(node); - - // Ending tag - skipTill("</map>"); - } - - private void readEntries(Preferences node) - throws InvalidPreferencesFormatException, IOException - { - while ("entry".equals(nextTag())) { - skipTill("<entry"); - skipTill("key=\""); - String key = readTill("\""); - skipTill("value=\""); - String value = readTill("\""); - System.out.println("Key: " + key + " Value: " + value); - node.put(key, value); - } - } - - private void skipTill(String s) - throws InvalidPreferencesFormatException, IOException - { - while(true) { - if (line == null) - throw new InvalidPreferencesFormatException(s + " not found"); - - int index = line.indexOf(s); - if (index == -1) { - line = br.readLine(); - } else { - line = line.substring(index+s.length()); - return; - } - } - } - - private String readTill(String s) - throws InvalidPreferencesFormatException - { - int index = line.indexOf(s); - if (index == -1) - throw new InvalidPreferencesFormatException(s + " not found"); - - String read = line.substring(0, index); - line = line.substring(index+s.length()); - - return read; - } - - private String nextTag() - throws InvalidPreferencesFormatException, IOException - { - while(true) { - if (line == null) - throw new InvalidPreferencesFormatException("unexpected EOF"); - - int start = line.indexOf("<"); - if (start == -1) { - line = br.readLine(); - } else { - // Find end of tag - int end = start+1; - while (end != line.length() - && " \t\r\n".indexOf(line.charAt(end)) == -1) { - end++; - } - // Line now starts at the found tag - String tag = line.substring(start+1,end); - line = line.substring(start); - return tag; - } - } - } - -} diff --git a/libjava/gnu/java/util/prefs/NodeWriter.java b/libjava/gnu/java/util/prefs/NodeWriter.java deleted file mode 100644 index d570d99af60..00000000000 --- a/libjava/gnu/java/util/prefs/NodeWriter.java +++ /dev/null @@ -1,315 +0,0 @@ -/* NodeWriter - Writes and exports preferences nodes to files - Copyright (C) 2001 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.util.prefs; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; - -import java.util.StringTokenizer; - -import java.util.prefs.*; - -/** - * Writes and exports preferences nodes to files - * - * @author Mark Wielaard (mark@klomp.org) - */ -public class NodeWriter { - - /** The Preferences node to write. */ - private final Preferences prefs; - - /** The bufferedWriter to write the node to. */ - private final BufferedWriter bw; - - /** - * True if the complete sub tree should be written, - * false if only the node should be written. - */ - private boolean subtree; - - /** - * Creates a new NodeWriter for the given preferences node and writer. - */ - public NodeWriter(Preferences prefs, Writer w) { - this.prefs = prefs; - if (w instanceof BufferedWriter) { - this.bw = (BufferedWriter) w; - } else { - this.bw = new BufferedWriter(w); - } - } - - /** - * Creates a new NodeWriter for the given preferences node and - * outputstream. Creates a new OutputStreamWriter. - */ - public NodeWriter(Preferences prefs, OutputStream os) { - this(prefs, new OutputStreamWriter(os)); - } - - /** - * Writes the preference node plus the complete subtree. - */ - public void writePrefsTree() throws BackingStoreException, IOException { - subtree = true; - writeHeader(); - writePreferences(); - bw.flush(); - } - - /** - * Writes only the preference node. - */ - public void writePrefs() throws BackingStoreException, IOException { - subtree = false; - writeHeader(); - writePreferences(); - bw.flush(); - } - - /** - * Writes the standard header. - */ - private void writeHeader() throws BackingStoreException, IOException { - bw.write("<?xml version=\"1.0\"?>"); - bw.newLine(); - bw.newLine(); - bw.write("<!-- GNU Classpath java.util.prefs Preferences "); - - if (prefs.isUserNode()) { - bw.write("user"); - } else { - bw.write("system"); - } - - // root node? - if (prefs.parent() == null) { - bw.write(" root"); - } - - if (subtree) { - bw.write(" tree"); - } else { - bw.write(" node"); - } - - // no root? - if (prefs.parent() != null) { - bw.newLine(); - bw.write(" '"); - bw.write(prefs.absolutePath()); - bw.write('\''); - bw.newLine(); - } - bw.write(" -->"); - bw.newLine(); - bw.newLine(); - } - - /** - * Write the preferences tag and the root. - */ - private void writePreferences() throws BackingStoreException, IOException { - bw.write("<preferences>"); - bw.newLine(); - writeRoot(); - bw.write("</preferences>"); - bw.newLine(); - } - - private void writeRoot() throws BackingStoreException, IOException { - bw.write(" <root type=\""); - if (prefs.isUserNode()) { - bw.write("user"); - } else { - bw.write("system"); - } - bw.write("\"/>"); - - writeRootMap(); - writeNode(); - - bw.write(" </root>"); - bw.newLine(); - } - - private void writeRootMap() throws BackingStoreException, IOException { - // Is it a root node? - if(prefs.parent() == null && prefs.keys().length > 0) { - bw.newLine(); - writeMap(prefs, 2); - } else { - bw.write("<map/>"); - bw.newLine(); - } - } - - /** - * Writes all the parents of the preferences node without any entries. - * Returns the number of parents written, which has to be used as - * argument to <code>writeCloseParents()</code> after writing the node - * itself. - */ - private int writeParents() throws IOException { - int parents; - String path = prefs.absolutePath(); - int lastslash = path.lastIndexOf("/"); - if (lastslash > 0) { - path = path.substring(1, lastslash); - StringTokenizer st = new StringTokenizer(path); - parents = st.countTokens(); - - System.out.println("path: " + path); - System.out.println("parents: " + parents); - - for (int i=0; i<parents; i++) { - String name = st.nextToken(); - indent(i+2); - bw.write("<node name=\"" + name + "\">"); - bw.write("<map/>"); - bw.write("</node>"); - bw.newLine(); - } - } else { - parents = 0; - } - - return parents; - } - - private void writeCloseParents(int parents) throws IOException { - while(parents > 0) { - indent(parents+1); - bw.write("</node>"); - bw.newLine(); - parents--; - } - } - - private void writeNode() throws BackingStoreException, IOException { - int parents = writeParents(); - // root? - int indent; - if (prefs.parent() == null) { - indent = parents+1; - } else { - indent = parents+2; - } - writeNode(prefs, indent); - writeCloseParents(parents); - } - - private void writeNode(Preferences node, int indent) - throws BackingStoreException, IOException - { - // not root? - if (node.parent() != null) { - indent(indent); - bw.write("<node name=\"" + node.name() + "\">"); - if (node.keys().length > 0) { - bw.newLine(); - } - writeMap(node, indent+1); - } - - if (subtree) { - String[] children = node.childrenNames(); - for (int i=0; i<children.length; i++) { - Preferences child = node.node(children[i]); - writeNode(child, indent+1); - } - } - - // not root? - if (node.parent() != null) { - indent(indent); - bw.write("</node>"); - bw.newLine(); - } - } - - private void writeMap(Preferences node, int indent) - throws BackingStoreException, IOException - { - // construct String used for indentation - StringBuffer indentBuffer = new StringBuffer(2*indent); - for (int i=0; i < indent; i++) - indentBuffer.append(" "); - String indentString = indentBuffer.toString(); - - if (node.keys().length > 0) { - bw.write(indentString); - bw.write("<map>"); - bw.newLine(); - writeEntries(node, indentString + " "); - bw.write(indentString); - bw.write("</map>"); - } else { - bw.write("<map/>"); - } - bw.newLine(); - } - - private void writeEntries(Preferences node, String indent) - throws BackingStoreException, IOException - { - String[] keys = node.keys(); - for(int i = 0; i < keys.length; i++) { - String value = node.get(keys[i], null); - if (value == null) { - throw new BackingStoreException("null value for key '" - + keys[i] + "'"); - } - - bw.write(indent); - bw.write("<entry key=\"" + keys[i] + "\"" - + " value=\"" + value + "\"/>"); - bw.newLine(); - } - } - - private void indent(int x) throws IOException { - for (int i=0; i<x; i++) { - bw.write(" "); - } - } -} diff --git a/libjava/java/util/prefs/AbstractPreferences.java b/libjava/java/util/prefs/AbstractPreferences.java deleted file mode 100644 index 98e87ebc83a..00000000000 --- a/libjava/java/util/prefs/AbstractPreferences.java +++ /dev/null @@ -1,1258 +0,0 @@ -/* AbstractPreferences - Partial implementation of a Preference node - Copyright (C) 2001 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 java.util.prefs; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import java.util.Iterator; -import java.util.HashMap; -import java.util.TreeSet; - -import gnu.java.util.prefs.NodeWriter; - -/** - * Partial implementation of a Preference node. - * - * Methods that still need to be implemented are <code>isUserNode(), XXX - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public abstract class AbstractPreferences extends Preferences { - - // protected fields - - /** - * Object used to lock this preference node. Any thread only locks nodes - * downwards when it has the lock on the current node. No method should - * synchronize on the lock of any of its parent nodes while holding the - * lock on the current node. - */ - protected final Object lock = new Object(); - - /** - * Set to true in the contructor if the node did not exist in the backing - * store when this preference node object was created. Should be set in - * the contructor of a subclass. Defaults to false. Used to fire node - * changed events. - */ - protected boolean newNode = false; - - // private fields - - /** - * The parent preferences node or null when this is the root node. - */ - private final AbstractPreferences parent; - - /** - * The name of this node. - * Only when this is a root node (parent == null) the name is empty. - * It has a maximum of 80 characters and cannot contain any '/' characters. - */ - private final String name; - - /** True when this node has been remove, false otherwise. */ - private boolean removed = false; - - /** - * Holds all the child names and nodes of this node that have been - * accessed by earlier <code>getChild()</code> or <code>childSpi()</code> - * invocations and that have not been removed. - */ - private HashMap childCache = new HashMap(); - - // constructor - - /** - * Creates a new AbstractPreferences node with the given parent and name. - * - * @param parent the parent of this node or null when this is the root node - * @param name the name of this node, can not be null, only 80 characters - * maximum, must be empty when parent is null and cannot - * contain any '/' characters - * @exception IllegalArgumentException when name is null, greater then 80 - * characters, not the empty string but parent is null or - * contains a '/' character - */ - protected AbstractPreferences(AbstractPreferences parent, String name) { - if ( (name == null) // name should be given - || (name.length() > MAX_NAME_LENGTH) // 80 characters max - || (parent == null && name.length() != 0) // root has no name - || (parent != null && name.length() == 0) // all other nodes do - || (name.indexOf('/') != -1)) // must not contain '/' - throw new IllegalArgumentException("Illegal name argument '" - + name - + "' (parent is " - + parent == null ? "" : "not " - + "null)"); - this.parent = parent; - this.name = name; - } - - // identification methods - - /** - * Returns the absolute path name of this preference node. - * The absolute path name of a node is the path name of its parent node - * plus a '/' plus its own name. If the node is the root node and has no - * parent then its path name is "" and its absolute path name is "/". - */ - public String absolutePath() { - if (parent == null) - return "/"; - else - return parent.path() + '/' + name; - } - - /** - * Private helper method for absolutePath. Returns the empty string for a - * root node and otherwise the parentPath of its parent plus a '/'. - */ - private String path() { - if (parent == null) - return ""; - else - return parent.path() + '/' + name; - } - - /** - * Returns true if this node comes from the user preferences tree, false - * if it comes from the system preferences tree. - */ - abstract public boolean isUserNode(); - - /** - * Returns the name of this preferences node. The name of the node cannot - * be null, can be mostly 80 characters and cannot contain any '/' - * characters. The root node has as name "". - */ - public String name() { - return name; - } - - /** - * Returns the String given by - * <code> - * (isUserNode() ? "User":"System") + " Preference Node: " + absolutePath() - * </code> - */ - public String toString() { - return (isUserNode() ? "User":"System") - + " Preference Node: " - + absolutePath(); - } - - /** - * Returns all the direct sub nodes of this preferences node. - * Needs access to the backing store to give a meaningfull answer. - * <p> - * This implementation locks this node, checks if the node has not yet - * been removed and throws an <code>IllegalStateException</code> when it - * has been. Then it creates a new <code>TreeSet</code> and adds any - * already cached child nodes names. To get any uncached names it calls - * <code>childrenNamesSpi()</code> and adds the result to the set. Finally - * it calls <code>toArray()</code> on the created set. When the call to - * <code>childrenNamesSpi</code> thows an <code>BackingStoreException</code> - * this method will not catch that exception but propagate the exception - * to the caller. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException when this node has been removed - */ - public String[] childrenNames() throws BackingStoreException { - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - TreeSet childrenNames = new TreeSet(); - - // First get all cached node names - childrenNames.addAll(childCache.keySet()); - - // Then add any others - String names[] = childrenNamesSpi(); - for (int i = 0; i < names.length; i++) { - childrenNames.add(names[i]); - } - - // And return the array of names - String[] children = new String[childrenNames.size()]; - childrenNames.toArray(children); - return children; - - } - } - - /** - * Returns a sub node of this preferences node if the given path is - * relative (does not start with a '/') or a sub node of the root - * if the path is absolute (does start with a '/'). - * <p> - * This method first locks this node and checks if the node has not been - * removed, if it has been removed it throws an exception. Then if the - * path is relative (does not start with a '/') it checks if the path is - * legal (does not end with a '/' and has no consecutive '/' characters). - * Then it recursively gets a name from the path, gets the child node - * from the child-cache of this node or calls the <code>childSpi()</code> - * method to create a new child sub node. This is done recursively on the - * newly created sub node with the rest of the path till the path is empty. - * If the path is absolute (starts with a '/') the lock on this node is - * droped and this method is called on the root of the preferences tree - * with as argument the complete path minus the first '/'. - * - * @exception IllegalStateException if this node has been removed - * @exception IllegalArgumentException if the path contains two or more - * consecutive '/' characters, ends with a '/' charactor and is not the - * string "/" (indicating the root node) or any name on the path is more - * then 80 characters long - */ - public Preferences node(String path) { - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - // Is it a relative path? - if (!path.startsWith("/")) { - - // Check if it is a valid path - if (path.indexOf("//") != -1 || path.endsWith("/")) - throw new IllegalArgumentException(path); - - return getNode(path); - } - } - - // path started with a '/' so it is absolute - // we drop the lock and start from the root (omitting the first '/') - Preferences root = isUserNode() ? userRoot() : systemRoot(); - return root.node(path.substring(1)); - - } - - /** - * Private helper method for <code>node()</code>. Called with this node - * locked. Returns this node when path is the empty string, if it is not - * empty the next node name is taken from the path (all chars till the - * next '/' or end of path string) and the node is either taken from the - * child-cache of this node or the <code>childSpi()</code> method is called - * on this node with the name as argument. Then this method is called - * recursively on the just constructed child node with the rest of the - * path. - * - * @param path should not end with a '/' character and should not contain - * consecutive '/' characters - * @exception IllegalArgumentException if path begins with a name that is - * larger then 80 characters. - */ - private Preferences getNode(String path) { - // if mark is dom then goto end - - // Empty String "" indicates this node - if (path.length() == 0) - return this; - - // Calculate child name and rest of path - String childName; - String childPath; - int nextSlash = path.indexOf('/'); - if (nextSlash == -1) { - childName = path; - childPath = ""; - } else { - childName = path.substring(0, nextSlash); - childPath = path.substring(nextSlash+1); - } - - // Get the child node - AbstractPreferences child; - child = (AbstractPreferences)childCache.get(childName); - if (child == null) { - - if (childName.length() > MAX_NAME_LENGTH) - throw new IllegalArgumentException(childName); - - // Not in childCache yet so create a new sub node - child = childSpi(childName); - // XXX - check if node is new - childCache.put(childName, child); - } - - // Lock the child and go down - synchronized(child.lock) { - return child.getNode(childPath); - } - } - - /** - * Returns true if the node that the path points to exists in memory or - * in the backing store. Otherwise it returns false or an exception is - * thrown. When this node is removed the only valid parameter is the - * empty string (indicating this node), the return value in that case - * will be false. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - * and the path is not the empty string (indicating this node) - * @exception IllegalArgumentException if the path contains two or more - * consecutive '/' characters, ends with a '/' charactor and is not the - * string "/" (indicating the root node) or any name on the path is more - * then 80 characters long - */ - public boolean nodeExists(String path) throws BackingStoreException { - synchronized(lock) { - if (isRemoved() && path.length() != 0) - throw new IllegalStateException("Node removed"); - - // Is it a relative path? - if (!path.startsWith("/")) { - - // Check if it is a valid path - if (path.indexOf("//") != -1 || path.endsWith("/")) - throw new IllegalArgumentException(path); - - return existsNode(path); - } - } - - // path started with a '/' so it is absolute - // we drop the lock and start from the root (omitting the first '/') - Preferences root = isUserNode() ? userRoot() : systemRoot(); - return root.nodeExists(path.substring(1)); - - } - - private boolean existsNode(String path) throws BackingStoreException { - - // Empty String "" indicates this node - if (path.length() == 0) - return(!isRemoved()); - - // Calculate child name and rest of path - String childName; - String childPath; - int nextSlash = path.indexOf('/'); - if (nextSlash == -1) { - childName = path; - childPath = ""; - } else { - childName = path.substring(0, nextSlash); - childPath = path.substring(nextSlash+1); - } - - // Get the child node - AbstractPreferences child; - child = (AbstractPreferences)childCache.get(childName); - if (child == null) { - - if (childName.length() > MAX_NAME_LENGTH) - throw new IllegalArgumentException(childName); - - // Not in childCache yet so create a new sub node - child = getChild(childName); - - if (child == null) - return false; - - childCache.put(childName, child); - } - - // Lock the child and go down - synchronized(child.lock) { - return child.existsNode(childPath); - } - } - - /** - * Returns the child sub node if it exists in the backing store or null - * if it does not exist. Called (indirectly) by <code>nodeExists()</code> - * when a child node name can not be found in the cache. - * <p> - * Gets the lock on this node, calls <code>childrenNamesSpi()</code> to - * get an array of all (possibly uncached) children and compares the - * given name with the names in the array. If the name is found in the - * array <code>childSpi()</code> is called to get an instance, otherwise - * null is returned. - * - * @exception BackingStoreException when the backing store cannot be - * reached - */ - protected AbstractPreferences getChild(String name) - throws BackingStoreException - { - synchronized(lock) { - // Get all the names (not yet in the cache) - String[] names = childrenNamesSpi(); - for (int i=0; i < names.length; i++) - if (name.equals(names[i])) - return childSpi(name); - - // No child with that name found - return null; - } - } - - /** - * Returns true if this node has been removed with the - * <code>removeNode()</code> method, false otherwise. - * <p> - * Gets the lock on this node and then returns a boolean field set by - * <code>removeNode</code> methods. - */ - protected boolean isRemoved() { - synchronized(lock) { - return removed; - } - } - - /** - * Returns the parent preferences node of this node or null if this is - * the root of the preferences tree. - * <p> - * Gets the lock on this node, checks that the node has not been removed - * and returns the parent given to the constructor. - * - * @exception IllegalStateException if this node has been removed - */ - public Preferences parent() { - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - return parent; - } - } - - // export methods - - /** - * XXX - */ - public void exportNode(OutputStream os) - throws BackingStoreException, - IOException - { - NodeWriter nodeWriter = new NodeWriter(this, os); - nodeWriter.writePrefs(); - } - - /** - * XXX - */ - public void exportSubtree(OutputStream os) - throws BackingStoreException, - IOException - { - NodeWriter nodeWriter = new NodeWriter(this, os); - nodeWriter.writePrefsTree(); - } - - // preference entry manipulation methods - - /** - * Returns an (possibly empty) array with all the keys of the preference - * entries of this node. - * <p> - * This method locks this node and checks if the node has not been - * removed, if it has been removed it throws an exception, then it returns - * the result of calling <code>keysSpi()</code>. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - public String[] keys() throws BackingStoreException { - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - return keysSpi(); - } - } - - - /** - * Returns the value associated with the key in this preferences node. If - * the default value of the key cannot be found in the preferences node - * entries or something goes wrong with the backing store the supplied - * default value is returned. - * <p> - * Checks that key is not null and not larger then 80 characters, - * locks this node, and checks that the node has not been removed. - * Then it calls <code>keySpi()</code> and returns - * the result of that method or the given default value if it returned - * null or throwed an exception. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public String get(String key, String defaultVal) { - if (key.length() > MAX_KEY_LENGTH) - throw new IllegalArgumentException(key); - - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - String value; - try { - value = getSpi(key); - } catch (Throwable t) { - value = null; - } - - if (value != null) { - return value; - } else { - return defaultVal; - } - } - } - - /** - * Convenience method for getting the given entry as a boolean. - * When the string representation of the requested entry is either - * "true" or "false" (ignoring case) then that value is returned, - * otherwise the given default boolean value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public boolean getBoolean(String key, boolean defaultVal) { - String value = get(key, null); - - if ("true".equalsIgnoreCase(value)) - return true; - - if ("false".equalsIgnoreCase(value)) - return false; - - return defaultVal; - } - - /** - * Convenience method for getting the given entry as a byte array. - * When the string representation of the requested entry is a valid - * Base64 encoded string (without any other characters, such as newlines) - * then the decoded Base64 string is returned as byte array, - * otherwise the given default byte array value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public byte[] getByteArray(String key, byte[] defaultVal) { - String value = get(key, null); - - byte[] b = null; - if (value != null) { - b = decode64(value); - } - - if (b != null) - return b; - else - return defaultVal; - } - - /** - * Helper method for decoding a Base64 string as an byte array. - * Returns null on encoding error. This method does not allow any other - * characters present in the string then the 65 special base64 chars. - */ - private static byte[] decode64(String s) { - ByteArrayOutputStream bs = new ByteArrayOutputStream((s.length()/4)*3); - char[] c = new char[s.length()]; - s.getChars(0, s.length(), c, 0); - - // Convert from base64 chars - int endchar = -1; - for(int j = 0; j < c.length && endchar == -1; j++) { - if (c[j] >= 'A' && c[j] <= 'Z') { - c[j] -= 'A'; - } else if (c[j] >= 'a' && c[j] <= 'z') { - c[j] = (char) (c[j] + 26 - 'a'); - } else if (c[j] >= '0' && c[j] <= '9') { - c[j] = (char) (c[j] + 52 - '0'); - } else if (c[j] == '+') { - c[j] = 62; - } else if (c[j] == '/') { - c[j] = 63; - } else if (c[j] == '=') { - endchar = j; - } else { - return null; // encoding exception - } - } - - int remaining = endchar == -1 ? c.length : endchar; - int i = 0; - while (remaining > 0) { - // Four input chars (6 bits) are decoded as three bytes as - // 000000 001111 111122 222222 - - byte b0 = (byte) (c[i] << 2); - if (remaining >= 2) { - b0 += (c[i+1] & 0x30) >> 4; - } - bs.write(b0); - - if (remaining >= 3) { - byte b1 = (byte) ((c[i+1] & 0x0F) << 4); - b1 += (byte) ((c[i+2] & 0x3C) >> 2); - bs.write(b1); - } - - if (remaining >= 4) { - byte b2 = (byte) ((c[i+2] & 0x03) << 6); - b2 += c[i+3]; - bs.write(b2); - } - - i += 4; - remaining -= 4; - } - - return bs.toByteArray(); - } - - /** - * Convenience method for getting the given entry as a double. - * When the string representation of the requested entry can be decoded - * with <code>Double.parseDouble()</code> then that double is returned, - * otherwise the given default double value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public double getDouble(String key, double defaultVal) { - String value = get(key, null); - - if (value != null) { - try { - return Double.parseDouble(value); - } catch (NumberFormatException nfe) { /* ignore */ } - } - - return defaultVal; - } - - /** - * Convenience method for getting the given entry as a float. - * When the string representation of the requested entry can be decoded - * with <code>Float.parseFloat()</code> then that float is returned, - * otherwise the given default float value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public float getFloat(String key, float defaultVal) { - String value = get(key, null); - - if (value != null) { - try { - return Float.parseFloat(value); - } catch (NumberFormatException nfe) { /* ignore */ } - } - - return defaultVal; - } - - /** - * Convenience method for getting the given entry as an integer. - * When the string representation of the requested entry can be decoded - * with <code>Integer.parseInt()</code> then that integer is returned, - * otherwise the given default integer value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public int getInt(String key, int defaultVal) { - String value = get(key, null); - - if (value != null) { - try { - return Integer.parseInt(value); - } catch (NumberFormatException nfe) { /* ignore */ } - } - - return defaultVal; - } - - /** - * Convenience method for getting the given entry as a long. - * When the string representation of the requested entry can be decoded - * with <code>Long.parseLong()</code> then that long is returned, - * otherwise the given default long value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - public long getLong(String key, long defaultVal) { - String value = get(key, null); - - if (value != null) { - try { - return Long.parseLong(value); - } catch (NumberFormatException nfe) { /* ignore */ } - } - - return defaultVal; - } - - /** - * Sets the value of the given preferences entry for this node. - * Key and value cannot be null, the key cannot exceed 80 characters - * and the value cannot exceed 8192 characters. - * <p> - * The result will be immediatly visible in this VM, but may not be - * immediatly written to the backing store. - * <p> - * Checks that key and value are valid, locks this node, and checks that - * the node has not been removed. Then it calls <code>putSpi()</code>. - * - * @exception NullPointerException if either key or value are null - * @exception IllegalArgumentException if either key or value are to large - * @exception IllegalStateException when this node has been removed - */ - public void put(String key, String value) { - if (key.length() > MAX_KEY_LENGTH - || value.length() > MAX_VALUE_LENGTH) - throw new IllegalArgumentException("key (" - + key.length() + ")" - + " or value (" - + value.length() + ")" - + " to large"); - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - putSpi(key, value); - - // XXX - fire events - } - - } - - /** - * Convenience method for setting the given entry as a boolean. - * The boolean is converted with <code>Boolean.toString(value)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - public void putBoolean(String key, boolean value) { - put(key, String.valueOf(value)); - // XXX - Use when using 1.4 compatible Boolean - // put(key, Boolean.toString(value)); - } - - /** - * Convenience method for setting the given entry as an array of bytes. - * The byte array is converted to a Base64 encoded string - * and then stored in the preference entry as that string. - * <p> - * Note that a byte array encoded as a Base64 string will be about 1.3 - * times larger then the original length of the byte array, which means - * that the byte array may not be larger about 6 KB. - * - * @exception NullPointerException if either key or value are null - * @exception IllegalArgumentException if either key or value are to large - * @exception IllegalStateException when this node has been removed - */ - public void putByteArray(String key, byte[] value) { - put(key, encode64(value)); - } - - /** - * Helper method for encoding an array of bytes as a Base64 String. - */ - private static String encode64(byte[] b) { - StringBuffer sb = new StringBuffer((b.length/3)*4); - - int i = 0; - int remaining = b.length; - char c[] = new char[4]; - while (remaining > 0) { - // Three input bytes are encoded as four chars (6 bits) as - // 00000011 11112222 22333333 - - c[0] = (char) ((b[i] & 0xFC) >> 2); - c[1] = (char) ((b[i] & 0x03) << 4); - if (remaining >= 2) { - c[1] += (char) ((b[i+1] & 0xF0) >> 4); - c[2] = (char) ((b[i+1] & 0x0F) << 2); - if (remaining >= 3) { - c[2] += (char) ((b[i+2] & 0xC0) >> 6); - c[3] = (char) (b[i+2] & 0x3F); - } else { - c[3] = 64; - } - } else { - c[2] = 64; - c[3] = 64; - } - - // Convert to base64 chars - for(int j = 0; j < 4; j++) { - if (c[j] < 26) { - c[j] += 'A'; - } else if (c[j] < 52) { - c[j] = (char) (c[j] - 26 + 'a'); - } else if (c[j] < 62) { - c[j] = (char) (c[j] - 52 + '0'); - } else if (c[j] == 62) { - c[j] = '+'; - } else if (c[j] == 63) { - c[j] = '/'; - } else { - c[j] = '='; - } - } - - sb.append(c); - i += 3; - remaining -= 3; - } - - return sb.toString(); - } - - /** - * Convenience method for setting the given entry as a double. - * The double is converted with <code>Double.toString(double)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - public void putDouble(String key, double value) { - put(key, Double.toString(value)); - } - - /** - * Convenience method for setting the given entry as a float. - * The float is converted with <code>Float.toString(float)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - public void putFloat(String key, float value) { - put(key, Float.toString(value)); - } - - /** - * Convenience method for setting the given entry as an integer. - * The integer is converted with <code>Integer.toString(int)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - public void putInt(String key, int value) { - put(key, Integer.toString(value)); - } - - /** - * Convenience method for setting the given entry as a long. - * The long is converted with <code>Long.toString(long)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - public void putLong(String key, long value) { - put(key, Long.toString(value)); - } - - /** - * Removes the preferences entry from this preferences node. - * <p> - * The result will be immediatly visible in this VM, but may not be - * immediatly written to the backing store. - * <p> - * This implementation checks that the key is not larger then 80 - * characters, gets the lock of this node, checks that the node has - * not been removed and calls <code>removeSpi</code> with the given key. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - public void remove(String key) { - if (key.length() > MAX_KEY_LENGTH) - throw new IllegalArgumentException(key); - - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node removed"); - - removeSpi(key); - } - } - - /** - * Removes all entries from this preferences node. May need access to the - * backing store to get and clear all entries. - * <p> - * The result will be immediatly visible in this VM, but may not be - * immediatly written to the backing store. - * <p> - * This implementation locks this node, checks that the node has not been - * removed and calls <code>keys()</code> to get a complete array of keys - * for this node. For every key found <code>removeSpi()</code> is called. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - public void clear() throws BackingStoreException { - synchronized(lock) { - if (isRemoved()) - throw new IllegalStateException("Node Removed"); - - String[] keys = keys(); - for (int i = 0; i < keys.length; i++) { - removeSpi(keys[i]); - } - } - } - - /** - * Writes all preference changes on this and any subnode that have not - * yet been written to the backing store. This has no effect on the - * preference entries in this VM, but it makes sure that all changes - * are visible to other programs (other VMs might need to call the - * <code>sync()</code> method to actually see the changes to the backing - * store. - * <p> - * Locks this node, calls the <code>flushSpi()</code> method, gets all - * the (cached - already existing in this VM) subnodes and then calls - * <code>flushSpi()</code> on every subnode with this node unlocked and - * only that particular subnode locked. - * - * @exception BackingStoreException when the backing store cannot be - * reached - */ - public void flush() throws BackingStoreException { - flushNode(false); - } - - /** - * Writes and reads all preference changes to and from this and any - * subnodes. This makes sure that all local changes are written to the - * backing store and that all changes to the backing store are visible - * in this preference node (and all subnodes). - * <p> - * Checks that this node is not removed, locks this node, calls the - * <code>syncSpi()</code> method, gets all the subnodes and then calls - * <code>syncSpi()</code> on every subnode with this node unlocked and - * only that particular subnode locked. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - public void sync() throws BackingStoreException { - flushNode(true); - } - - - /** - * Private helper method that locks this node and calls either - * <code>flushSpi()</code> if <code>sync</code> is false, or - * <code>flushSpi()</code> if <code>sync</code> is true. Then it gets all - * the currently cached subnodes. For every subnode it calls this method - * recursively with this node no longer locked. - * <p> - * Called by either <code>flush()</code> or <code>sync()</code> - */ - private void flushNode(boolean sync) throws BackingStoreException { - String[] keys = null; - synchronized(lock) { - if (sync) { - syncSpi(); - } else { - flushSpi(); - } - keys = (String[]) childCache.keySet().toArray(); - } - - if (keys != null) { - for (int i = 0; i < keys.length; i++) { - // Have to lock this node again to access the childCache - AbstractPreferences subNode; - synchronized(this) { - subNode = (AbstractPreferences) childCache.get(keys[i]); - } - - // The child could already have been removed from the cache - if (subNode != null) { - subNode.flushNode(sync); - } - } - } - } - - /** - * Removes this and all subnodes from the backing store and clears all - * entries. After removal this instance will not be useable (except for - * a few methods that don't throw a <code>InvalidStateException</code>), - * even when a new node with the same path name is created this instance - * will not be usable again. - * <p> - * Checks that this is not a root node. If not it locks the parent node, - * then locks this node and checks that the node has not yet been removed. - * Then it makes sure that all subnodes of this node are in the child cache, - * by calling <code>childSpi()</code> on any children not yet in the cache. - * Then for all children it locks the subnode and removes it. After all - * subnodes have been purged the child cache is cleared, this nodes removed - * flag is set and any listeners are called. Finally this node is removed - * from the child cache of the parent node. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has already been removed - * @exception UnsupportedOperationException if this is a root node - */ - public void removeNode() throws BackingStoreException { - // Check if it is a root node - if (parent == null) - throw new UnsupportedOperationException("Cannot remove root node"); - - synchronized(parent) { - synchronized(this) { - if (isRemoved()) - throw new IllegalStateException("Node Removed"); - - purge(); - } - parent.childCache.remove(name); - } - } - - /** - * Private helper method used to completely remove this node. - * Called by <code>removeNode</code> with the parent node and this node - * locked. - * <p> - * Makes sure that all subnodes of this node are in the child cache, - * by calling <code>childSpi()</code> on any children not yet in the - * cache. Then for all children it locks the subnode and calls this method - * on that node. After all subnodes have been purged the child cache is - * cleared, this nodes removed flag is set and any listeners are called. - */ - private void purge() throws BackingStoreException - { - // Make sure all children have an AbstractPreferences node in cache - String children[] = childrenNamesSpi(); - for (int i = 0; i < children.length; i++) { - if (childCache.get(children[i]) == null) - childCache.put(children[i], childSpi(children[i])); - } - - // purge all children - Iterator i = childCache.values().iterator(); - while (i.hasNext()) { - AbstractPreferences node = (AbstractPreferences) i.next(); - synchronized(node) { - node.purge(); - } - } - - // Cache is empty now - childCache.clear(); - - // remove this node - removeNodeSpi(); - removed = true; - - // XXX - check for listeners - } - - // listener methods - - /** - * XXX - */ - public void addNodeChangeListener(NodeChangeListener listener) { - // XXX - } - - public void addPreferenceChangeListener(PreferenceChangeListener listener) { - // XXX - } - - public void removeNodeChangeListener(NodeChangeListener listener) { - // XXX - } - - public void removePreferenceChangeListener - (PreferenceChangeListener listener) - { - // XXX - } - - // abstract spi methods - - /** - * Returns the names of the sub nodes of this preference node. - * This method only has to return any not yet cached child names, - * but may return all names if that is easier. It must not return - * null when there are no children, it has to return an empty array - * in that case. Since this method must consult the backing store to - * get all the sub node names it may throw a BackingStoreException. - * <p> - * Called by <code>childrenNames()</code> with this node locked. - */ - protected abstract String[] childrenNamesSpi() throws BackingStoreException; - - /** - * Returns a child note with the given name. - * This method is called by the <code>node()</code> method (indirectly - * through the <code>getNode()</code> helper method) with this node locked - * if a sub node with this name does not already exist in the child cache. - * If the child node did not aleady exist in the backing store the boolean - * field <code>newNode</code> of the returned node should be set. - * <p> - * Note that this method should even return a non-null child node if the - * backing store is not available since it may not throw a - * <code>BackingStoreException</code>. - */ - protected abstract AbstractPreferences childSpi(String name); - - /** - * Returns an (possibly empty) array with all the keys of the preference - * entries of this node. - * <p> - * Called by <code>keys()</code> with this node locked if this node has - * not been removed. May throw an exception when the backing store cannot - * be accessed. - * - * @exception BackingStoreException when the backing store cannot be - * reached - */ - abstract protected String[] keysSpi() throws BackingStoreException; - - /** - * Returns the value associated with the key in this preferences node or - * null when the key does not exist in this preferences node. - * <p> - * Called by <code>key()</code> with this node locked after checking that - * key is valid, not null and that the node has not been removed. - * <code>key()</code> will catch any exceptions that this method throws. - */ - abstract protected String getSpi(String key); - - /** - * Sets the value of the given preferences entry for this node. - * The implementation is not required to propagate the change to the - * backing store immediatly. It may not throw an exception when it tries - * to write to the backing store and that operation fails, the failure - * should be registered so a later invocation of <code>flush()</code> - * or <code>sync()</code> can signal the failure. - * <p> - * Called by <code>put()</code> with this node locked after checking that - * key and value are valid and non-null. - */ - abstract protected void putSpi(String key, String value); - - /** - * Removes the given key entry from this preferences node. - * The implementation is not required to propagate the change to the - * backing store immediatly. It may not throw an exception when it tries - * to write to the backing store and that operation fails, the failure - * should be registered so a later invocation of <code>flush()</code> - * or <code>sync()</code> can signal the failure. - * <p> - * Called by <code>remove()</code> with this node locked after checking - * that the key is valid and non-null. - */ - abstract protected void removeSpi(String key); - - /** - * Writes all entries of this preferences node that have not yet been - * written to the backing store and possibly creates this node in the - * backing store, if it does not yet exist. Should only write changes to - * this node and not write changes to any subnodes. - * Note that the node can be already removed in this VM. To check if - * that is the case the implementation can call <code>isRemoved()</code>. - * <p> - * Called (indirectly) by <code>flush()</code> with this node locked. - */ - abstract protected void flushSpi() throws BackingStoreException; - - /** - * Writes all entries of this preferences node that have not yet been - * written to the backing store and reads any entries that have changed - * in the backing store but that are not yet visible in this VM. - * Should only sync this node and not change any of the subnodes. - * Note that the node can be already removed in this VM. To check if - * that is the case the implementation can call <code>isRemoved()</code>. - * <p> - * Called (indirectly) by <code>sync()</code> with this node locked. - */ - abstract protected void syncSpi() throws BackingStoreException; - - /** - * Clears this node from this VM and removes it from the backing store. - * After this method has been called the node is marked as removed. - * <p> - * Called (indirectly) by <code>removeNode()</code> with this node locked - * after all the sub nodes of this node have already been removed. - */ - abstract protected void removeNodeSpi() throws BackingStoreException; -} diff --git a/libjava/java/util/prefs/BackingStoreException.java b/libjava/java/util/prefs/BackingStoreException.java deleted file mode 100644 index f2c6b4c8b31..00000000000 --- a/libjava/java/util/prefs/BackingStoreException.java +++ /dev/null @@ -1,104 +0,0 @@ -/* BackingStoreException.java - chained exception thrown when backing store - fails - Copyright (C) 2001, 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 java.util.prefs; - -import java.io.ObjectOutputStream; -import java.io.ObjectInputStream; -import java.io.NotSerializableException; - -/** - * Chained exception thrown when backing store fails. This exception is - * only thrown from methods that actually have to access the backing store, - * such as <code>clear(), keys(), childrenNames(), nodeExists(), removeNode(), - * flush(), sync(), exportNode(), exportSubTree()</code>; normal operations - * do not throw BackingStoreExceptions. - * - * <p>Note that although this class inherits the Serializable interface, an - * attempt to serialize will fail with a <code>NotSerializableException</code>. - * - * @author Mark Wielaard <mark@klomp.org> - * @since 1.4 - * @status updated to 1.4 - */ -public class BackingStoreException extends Exception -{ - static final long serialVersionUID = 859796500401108469L; - - /** - * Creates a new exception with a descriptive message. - * - * @param message the message - */ - public BackingStoreException(String message) - { - super(message); - } - - /** - * Create a new exception with the given cause. - * - * @param cause the cause - */ - public BackingStoreException(Throwable cause) - { - super(cause); - } - - /** - * This class should not be serialized. - * - * @param o the output stream - */ - private void writeObject(ObjectOutputStream o) throws NotSerializableException - { - throw new NotSerializableException - ("java.util.prefs.BackingStoreException"); - } - - /** - * This class should not be serialized. - * - * @param i the input stream - */ - private void readObject(ObjectInputStream i) throws NotSerializableException - { - throw new NotSerializableException - ("java.util.prefs.BackingStoreException"); - } -} diff --git a/libjava/java/util/prefs/InvalidPreferencesFormatException.java b/libjava/java/util/prefs/InvalidPreferencesFormatException.java deleted file mode 100644 index e375db7ab1f..00000000000 --- a/libjava/java/util/prefs/InvalidPreferencesFormatException.java +++ /dev/null @@ -1,115 +0,0 @@ -/* InvalidPreferencesFormatException - indicates reading prefs from stream - failed - Copyright (C) 2001, 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 java.util.prefs; - -import java.io.ObjectOutputStream; -import java.io.ObjectInputStream; -import java.io.NotSerializableException; - -/** - * Indicates reading prefs from stream failed. Thrown by the - * <code>importPreferences()</code> method when the supplied input stream - * could not be read because it was not in the correct XML format. - * - * <p>Note that although this class inherits the Serializable interface, an - * attempt to serialize will fail with a <code>NotSerializableException</code>. - * - * @author Mark Wielaard <mark@klomp.org> - * @see Preferences - * @since 1.4 - * @status updated to 1.4 - */ -public class InvalidPreferencesFormatException extends Exception -{ - static final long serialVersionUID = -791715184232119669L; - - /** - * Creates a new exception with a descriptive message. The cause remains - * uninitialized. - * - * @param message the message - */ - public InvalidPreferencesFormatException(String message) - { - super(message); - } - - /** - * Creates a new exception with the given cause. - * - * @param cause the cause - */ - public InvalidPreferencesFormatException(Throwable cause) - { - super(cause); - } - - /** - * Creates a new exception with a descriptive message and a cause. - * - * @param message the message - * @param cause the cause - */ - public InvalidPreferencesFormatException(String message, Throwable cause) - { - super(message, cause); - } - - /** - * This class should not be serialized. - * - * @param o the output stream - */ - private void writeObject(ObjectOutputStream o) throws NotSerializableException - { - throw new NotSerializableException - ("java.util.prefs.InvalidPreferencesFormatException"); - } - - /** - * This class should not be serialized. - * - * @param i the input stream - */ - private void readObject(ObjectInputStream i) throws NotSerializableException - { - throw new NotSerializableException - ("java.util.prefs.InvalidPreferencesFormatException"); - } -} diff --git a/libjava/java/util/prefs/NodeChangeEvent.java b/libjava/java/util/prefs/NodeChangeEvent.java deleted file mode 100644 index a919c464ab2..00000000000 --- a/libjava/java/util/prefs/NodeChangeEvent.java +++ /dev/null @@ -1,91 +0,0 @@ -/* NodeChangeEvent - ObjectEvent fired when a Preference node is added/removed - Copyright (C) 2001 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 java.util.prefs; - -import java.util.EventObject; - -/** - * ObjectEvent fired when a Preference node is added/removed. - * This event is only generated when a new subnode is added or a subnode is - * removed from a preference node. Changes in the entries of a preference node - * are indicated with a <code>PreferenceChangeEvent</code>. - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public class NodeChangeEvent extends EventObject { - - private static final long serialVersionUID =8068949086596572957L; - - /** - * The sub node that was added or removed. - * Defined transient just like <code>EventObject.source</code> since - * this object should be serializable, but Preferences is in general not - * serializable. - */ - private final transient Preferences child; - - /** - * Creates a new NodeChangeEvent. - * - * @param parentNode The source preference node from which a subnode was - * added or removed - * @param childNode The preference node that was added or removed - */ - public NodeChangeEvent(Preferences parentNode, Preferences childNode) { - super(parentNode); - child = childNode; - } - - /** - * Returns the source parent preference node from which a subnode was - * added or removed. - */ - public Preferences getParent() { - return (Preferences) source; - } - - /** - * Returns the child preference subnode that was added or removed. - * To see wether it is still a valid preference node one has to call - * <code>event.getChild().nodeExists("")</code>. - */ - public Preferences getChild() { - return child; - } -} diff --git a/libjava/java/util/prefs/NodeChangeListener.java b/libjava/java/util/prefs/NodeChangeListener.java deleted file mode 100644 index 04e8dc1412e..00000000000 --- a/libjava/java/util/prefs/NodeChangeListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/* NodeChangeListener - EventListener for Preferences node addition/removal - Copyright (C) 2001 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 java.util.prefs; - -import java.util.EventListener; - -/** - * EventListener for Preferences node addition/removal. - * <p> - * Note that these events are only generated for the addition and removal - * of sub nodes from the preference node. Entry changes in the preference - * node can be monitored with a <code>PreferenceChangeListener</code>. - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public interface NodeChangeListener extends EventListener { - - /** - * Fired when a sub node is added to the preference node. - */ - void childAdded(NodeChangeEvent event); - - /** - * Fired when a sub node is removed from the preference node. - */ - void childRemoved(NodeChangeEvent event); - -} diff --git a/libjava/java/util/prefs/PreferenceChangeEvent.java b/libjava/java/util/prefs/PreferenceChangeEvent.java deleted file mode 100644 index de98dbb3181..00000000000 --- a/libjava/java/util/prefs/PreferenceChangeEvent.java +++ /dev/null @@ -1,105 +0,0 @@ -/* PreferenceChangeEvent - ObjectEvent fired when a Preferences entry changes - Copyright (C) 2001 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 java.util.prefs; - -import java.util.EventObject; - -/** - * ObjectEvent fired when a Preferences entry changes. - * This event is generated when a entry is added, changed or removed. - * When an entry is removed then <code>getNewValue</code> will return null. - * <p> - * Preference change events are only generated for entries in one particular - * preference node. Notification of subnode addition/removal is given by a - * <code>NodeChangeEvent</code>. - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public class PreferenceChangeEvent extends EventObject { - - private static final long serialVersionUID = 793724513368024975L; - - /** - * The key of the changed entry. - */ - private final String key; - - /** - * The new value of the changed entry, or null when the entry was removed. - */ - private final String newValue; - - /** - * Creates a new PreferenceChangeEvent. - * - * @param node The source preference node for which an entry was added, - * changed or removed - * @param key The key of the entry that was added, changed or removed - * @param value The new value of the entry that was added or changed, or - * null when the entry was removed - */ - public PreferenceChangeEvent(Preferences node, String key, String value) { - super(node); - this.key = key; - this.newValue = value; - } - - /** - * Returns the source Preference node from which an entry was added, - * changed or removed. - */ - public Preferences getNode() { - return (Preferences) source; - } - - /** - * Returns the key of the entry that was added, changed or removed. - */ - public String getKey() { - return key; - } - - /** - * Returns the new value of the entry that was added or changed, or - * returns null when the entry was removed. - */ - public String getNewValue() { - return newValue; - } -} diff --git a/libjava/java/util/prefs/PreferenceChangeListener.java b/libjava/java/util/prefs/PreferenceChangeListener.java deleted file mode 100644 index 26e17274cb7..00000000000 --- a/libjava/java/util/prefs/PreferenceChangeListener.java +++ /dev/null @@ -1,60 +0,0 @@ -/* PreferenceChangeListener - EventListener for Preferences entry changes - Copyright (C) 2001 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 java.util.prefs; - -import java.util.EventListener; - -/** - * EventListener for Preferences entry addition, change or removal. - * <p> - * Preference change events are only generated for entries in one particular - * preference node. Notification of subnode addition/removal can be monitored - * with a <code>NodeChangeListener</code>. - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public interface PreferenceChangeListener extends EventListener { - - /** - * Fired when a entry has been added, changed or removed from the - * preference node. - */ - void preferenceChange(PreferenceChangeEvent event); - -} diff --git a/libjava/java/util/prefs/Preferences.java b/libjava/java/util/prefs/Preferences.java deleted file mode 100644 index 8705b77191c..00000000000 --- a/libjava/java/util/prefs/Preferences.java +++ /dev/null @@ -1,665 +0,0 @@ -/* Preferences - Preference node containing key value entries and subnodes - Copyright (C) 2001 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 java.util.prefs; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - -import java.security.AccessController; -import java.security.Permission; -import java.security.PrivilegedAction; - -import gnu.java.util.prefs.*; - -/** - * Preference node containing key value entries and subnodes. - * <p> - * There are two preference node trees, a system tree which can be accessed - * by calling <code>systemRoot()</code> containing system preferences usefull - * for all users, and a user tree that can be accessed by calling - * <code>userRoot()</code> containing preferences that can differ between - * different users. How different users are identified is implementation - * depended. It can be determined by Thread, Access Control Context or Subject. - * <p> - * This implementation uses the "java.util.prefs.PreferencesFactory" system - * property to find a class that implement <code>PreferencesFactory</code> - * and initialized that class (if it has a public no arguments contructor) - * to get at the actual system or user root. If the system property is not set, - * or the class cannot be initialized it uses the default implementation - * <code>gnu.java.util.prefs.FileBasedFactory</code>. - * <p> - * Besides the two static method above to get the roots of the system and user - * preference node trees there are also two convenience methods to access the - * default preference node for a particular package an object is in. These are - * <code>userNodeForPackage()</code> and <code>systemNodeForPackage()</code>. - * Both methods take an Object as an argument so accessing preferences values - * can be as easy as calling <code>Preferences.userNodeForPackage(this)</code>. - * <p> - * Note that if a security manager is installed all static methods check for - * <code>RuntimePermission("preferences")</code>. But if this permission is - * given to the code then it can access and change all (user) preference nodes - * and entries. So you should be carefull not to store to sensitive information - * or make security decissions based on preference values since there is no - * more fine grained control over what preference values can be changed once - * code has been given the correct runtime permission. - * <p> - * XXX - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public abstract class Preferences { - - // Static Fields - - /** - * Default PreferencesFactory class used when the system property - * "java.util.prefs.PreferencesFactory" is not set. - * <p> - * XXX - Currently set to MemoryBasedPreferencesFactory, should be changed - * when FileBasedPreferences backend works. - */ - private static final String defaultFactoryClass - = "gnu.java.util.prefs.MemoryBasedPreferencesFactory"; - - /** Permission needed to access system or user root. */ - private static final Permission prefsPermission - = new RuntimePermission("preferences"); - - /** - * The preferences factory object that supplies the system and user root. - * Set and returned by the getFactory() method. - */ - private static PreferencesFactory factory; - - /** Maximum node name length. 80 characters. */ - public static final int MAX_NAME_LENGTH = 80; - - /** Maximum entry key length. 80 characters. */ - public static final int MAX_KEY_LENGTH = 80; - - /** Maximum entry value length. 8192 characters. */ - public static final int MAX_VALUE_LENGTH = 8192; - - // Constructors - - /** - * Creates a new Preferences node. Can only be used by subclasses. - * Empty implementation. - */ - protected Preferences() {} - - // Static methods - - /** - * Returns the system preferences root node containing usefull preferences - * for all users. It is save to cache this value since it should always - * return the same preference node. - * - * @return the root system preference node - * @exception SecurityException when a security manager is installed and - * the caller does not have <code>RuntimePermission("preferences")</code>. - */ - public static Preferences systemRoot() throws SecurityException { - // Get the preferences factory and check for permission - PreferencesFactory factory = getFactory(); - - return factory.systemRoot(); - } - - /** - * Returns the user preferences root node containing preferences for the - * the current user. How different users are identified is implementation - * depended. It can be determined by Thread, Access Control Context or - * Subject. - * - * @return the root user preference node - * @exception SecurityException when a security manager is installed and - * the caller does not have <code>RuntimePermission("preferences")</code>. - */ - public static Preferences userRoot() throws SecurityException { - // Get the preferences factory and check for permission - PreferencesFactory factory = getFactory(); - return factory.userRoot(); - } - - /** - * Private helper method for <code>systemRoot()</code> and - * <code>userRoot()</code>. Checks security permission and instantiates the - * correct factory if it has not yet been set. - * <p> - * When the preferences factory has not yet been set this method first - * tries to get the system propery "java.util.prefs.PreferencesFactory" - * and tries to initializes that class. If the system property is not set - * or initialization fails it returns an instance of the default factory - * <code>gnu.java.util.prefs.FileBasedPreferencesFactory</code>. - * - * @return the preferences factory to use - * @exception SecurityException when a security manager is installed and - * the caller does not have <code>RuntimePermission("preferences")</code>. - */ - private static PreferencesFactory getFactory() throws SecurityException { - - // First check for permission - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(prefsPermission); - } - - // Get the factory - if (factory == null) { - // Caller might not have enough permissions - factory = (PreferencesFactory) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - PreferencesFactory pf = null; - String className = System.getProperty - ("java.util.prefs.PreferencesFactory"); - if (className != null) { - try { - Class fc = Class.forName(className); - Object o = fc.newInstance(); - pf = (PreferencesFactory) o; - } catch (ClassNotFoundException cnfe) - {/*ignore*/} - catch (InstantiationException ie) - {/*ignore*/} - catch (IllegalAccessException iae) - {/*ignore*/} - catch (ClassCastException cce) - {/*ignore*/} - } - return pf; - } - }); - - // Still no factory? Use our default. - if (factory == null) { - try { - Object o = Class.forName(defaultFactoryClass); - factory = (PreferencesFactory) o; - } catch (ClassNotFoundException cnfe) { - throw new RuntimeException("Couldn't load default factory" - + " '"+ defaultFactoryClass +"'"); - // XXX - when using 1.4 compatible throwables add cause - } - } - - } - return factory; - } - - /** - * Returns the system preferences node for the package of an object. - * The package node name of the object is determined by dropping the - * class name of the object of the fully quallified class name and - * replacing all '.' to '/' in the package name. If the class of the - * object has no package then the package node name is "<unnamed>". - * The returened node is <code>systemRoot().node(packageNodeName)</code>. - * - * @param o Object whose default system preference node is requested - * @returns system preferences node that should be used by object o - * @exception SecurityException when a security manager is installed and - * the caller does not have <code>RuntimePermission("preferences")</code>. - */ - public static Preferences systemNodeForPackage(Object o) - throws SecurityException - { - return nodeForPackage(o, systemRoot()); - } - - /** - * Returns the user preferences node for the package of an object. - * The package node name of the object is determined by dropping the - * class name of the object of the fully quallified class name and - * replacing all '.' to '/' in the package name. If the class of the - * object has no package then the package node name is "<unnamed>". - * The returened node is <code>userRoot().node(packageNodeName)</code>. - * - * @param o Object whose default user preference node is requested - * @returns user preferences node that should be used by object o - * @exception SecurityException when a security manager is installed and - * the caller does not have <code>RuntimePermission("preferences")</code>. - */ - public static Preferences userNodeForPackage(Object o) - throws SecurityException - { - return nodeForPackage(o, userRoot()); - } - - /** - * Private helper method for <code>systemNodeForPackage()</code> and - * <code>userNodeForPackage()</code>. Given the correct system or user - * root it returns the correct Preference node for the package node name - * of the given object. - */ - private static Preferences nodeForPackage(Object o, Preferences root) { - // Get the package path - String className = o.getClass().getName(); - String packagePath; - int index = className.lastIndexOf('.'); - if(index == -1) { - packagePath = "<unnamed>"; - } else { - packagePath = className.substring(0,index).replace('.','/'); - } - - return root.node(packagePath); - } - - /** - * XXX - */ - public static void importPreferences(InputStream is) - throws InvalidPreferencesFormatException, - IOException - { - PreferencesFactory factory = getFactory(); - NodeReader reader = new NodeReader(is, factory); - reader.importPreferences(); - } - - // abstract methods (identification) - - /** - * Returns the absolute path name of this preference node. - * The absolute path name of a node is the path name of its parent node - * plus a '/' plus its own name. If the node is the root node and has no - * parent then its name is "" and its absolute path name is "/". - */ - abstract public String absolutePath(); - - /** - * Returns true if this node comes from the user preferences tree, false - * if it comes from the system preferences tree. - */ - abstract public boolean isUserNode(); - - /** - * Returns the name of this preferences node. The name of the node cannot - * be null, can be mostly 80 characters and cannot contain any '/' - * characters. The root node has as name "". - */ - abstract public String name(); - - /** - * Returns the String given by - * <code> - * (isUserNode() ? "User":"System") + " Preference Node: " + absolutePath() - * </code> - */ - abstract public String toString(); - - // abstract methods (navigation) - - /** - * Returns all the direct sub nodes of this preferences node. - * Needs access to the backing store to give a meaningfull answer. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException when this node has been removed - */ - abstract public String[] childrenNames() throws BackingStoreException; - - /** - * Returns a sub node of this preferences node if the given path is - * relative (does not start with a '/') or a sub node of the root - * if the path is absolute (does start with a '/'). - * - * @exception IllegalStateException if this node has been removed - * @exception IllegalArgumentException if the path contains two or more - * consecutive '/' characters, ends with a '/' charactor and is not the - * string "/" (indicating the root node) or any name on the path is more - * then 80 characters long - */ - abstract public Preferences node(String path); - - /** - * Returns true if the node that the path points to exists in memory or - * in the backing store. Otherwise it returns false or an exception is - * thrown. When this node is removed the only valid parameter is the - * empty string (indicating this node), the return value in that case - * will be false. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - * and the path is not the empty string (indicating this node) - * @exception IllegalArgumentException if the path contains two or more - * consecutive '/' characters, ends with a '/' charactor and is not the - * string "/" (indicating the root node) or any name on the path is more - * then 80 characters long - */ - abstract public boolean nodeExists(String path) - throws BackingStoreException; - - /** - * Returns the parent preferences node of this node or null if this is - * the root of the preferences tree. - * - * @exception IllegalStateException if this node has been removed - */ - abstract public Preferences parent(); - - // abstract methods (export) - - /** - * XXX - */ - abstract public void exportNode(OutputStream os) - throws BackingStoreException, - IOException; - - /** - * XXX - */ - abstract public void exportSubtree(OutputStream os) - throws BackingStoreException, - IOException; - - // abstract methods (preference entry manipulation) - - /** - * Returns an (possibly empty) array with all the keys of the preference - * entries of this node. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - abstract public String[] keys() throws BackingStoreException; - - /** - * Returns the value associated with the key in this preferences node. If - * the default value of the key cannot be found in the preferences node - * entries or something goes wrong with the backing store the supplied - * default value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public String get(String key, String defaultVal); - - /** - * Convenience method for getting the given entry as a boolean. - * When the string representation of the requested entry is either - * "true" or "false" (ignoring case) then that value is returned, - * otherwise the given default boolean value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public boolean getBoolean(String key, boolean defaultVal); - - /** - * Convenience method for getting the given entry as a byte array. - * When the string representation of the requested entry is a valid - * Base64 encoded string (without any other characters, such as newlines) - * then the decoded Base64 string is returned as byte array, - * otherwise the given default byte array value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public byte[] getByteArray(String key, byte[] defaultVal); - - /** - * Convenience method for getting the given entry as a double. - * When the string representation of the requested entry can be decoded - * with <code>Double.parseDouble()</code> then that double is returned, - * otherwise the given default double value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public double getDouble(String key, double defaultVal); - - /** - * Convenience method for getting the given entry as a float. - * When the string representation of the requested entry can be decoded - * with <code>Float.parseFloat()</code> then that float is returned, - * otherwise the given default float value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public float getFloat(String key, float defaultVal); - - /** - * Convenience method for getting the given entry as an integer. - * When the string representation of the requested entry can be decoded - * with <code>Integer.parseInt()</code> then that integer is returned, - * otherwise the given default integer value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public int getInt(String key, int defaultVal); - - /** - * Convenience method for getting the given entry as a long. - * When the string representation of the requested entry can be decoded - * with <code>Long.parseLong()</code> then that long is returned, - * otherwise the given default long value is returned. - * - * @exception IllegalArgumentException if key is larger then 80 characters - * @exception IllegalStateException if this node has been removed - * @exception NullPointerException if key is null - */ - abstract public long getLong(String key, long defaultVal); - - /** - * Sets the value of the given preferences entry for this node. - * Key and value cannot be null, the key cannot exceed 80 characters - * and the value cannot exceed 8192 characters. - * <p> - * The result will be immediatly visible in this VM, but may not be - * immediatly written to the backing store. - * - * @exception NullPointerException if either key or value are null - * @exception IllegalArgumentException if either key or value are to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void put(String key, String value); - - /** - * Convenience method for setting the given entry as a boolean. - * The boolean is converted with <code>Boolean.toString(value)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void putBoolean(String key, boolean value); - - /** - * Convenience method for setting the given entry as an array of bytes. - * The byte array is converted to a Base64 encoded string - * and then stored in the preference entry as that string. - * <p> - * Note that a byte array encoded as a Base64 string will be about 1.3 - * times larger then the original length of the byte array, which means - * that the byte array may not be larger about 6 KB. - * - * @exception NullPointerException if either key or value are null - * @exception IllegalArgumentException if either key or value are to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void putByteArray(String key, byte[] value); - - /** - * Convenience method for setting the given entry as a double. - * The double is converted with <code>Double.toString(double)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void putDouble(String key, double value); - - /** - * Convenience method for setting the given entry as a float. - * The float is converted with <code>Float.toString(float)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void putFloat(String key, float value); - - /** - * Convenience method for setting the given entry as an integer. - * The integer is converted with <code>Integer.toString(int)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void putInt(String key, int value); - - /** - * Convenience method for setting the given entry as a long. - * The long is converted with <code>Long.toString(long)</code> - * and then stored in the preference entry as that string. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void putLong(String key, long value); - - /** - * Removes the preferences entry from this preferences node. - * <p> - * The result will be immediatly visible in this VM, but may not be - * immediatly written to the backing store. - * - * @exception NullPointerException if the key is null - * @exception IllegalArgumentException if the key length is to large - * @exception IllegalStateException when this node has been removed - */ - abstract public void remove(String key); - - // abstract methods (preference node manipulation) - - /** - * Removes all entries from this preferences node. May need access to the - * backing store to get and clear all entries. - * <p> - * The result will be immediatly visible in this VM, but may not be - * immediatly written to the backing store. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - abstract public void clear() throws BackingStoreException; - - /** - * Writes all preference changes on this and any subnode that have not - * yet been written to the backing store. This has no effect on the - * preference entries in this VM, but it makes sure that all changes - * are visible to other programs (other VMs might need to call the - * <code>sync()</code> method to actually see the changes to the backing - * store. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - abstract public void flush() throws BackingStoreException; - - /** - * Writes and reads all preference changes to and from this and any - * subnodes. This makes sure that all local changes are written to the - * backing store and that all changes to the backing store are visible - * in this preference node (and all subnodes). - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has been removed - */ - abstract public void sync() throws BackingStoreException; - - /** - * Removes this and all subnodes from the backing store and clears all - * entries. After removal this instance will not be useable (except for - * a few methods that don't throw a <code>InvalidStateException</code>), - * even when a new node with the same path name is created this instance - * will not be usable again. The root (system or user) may never be removed. - * <p> - * Note that according to the specification an implementation may delay - * removal of the node from the backing store till the <code>flush()</code> - * method is called. But the <code>flush()</code> method may throw a - * <code>IllegalStateException</code> when the node has been removed. - * So most implementations will actually remove the node and any subnodes - * from the backing store immediatly. - * - * @exception BackingStoreException when the backing store cannot be - * reached - * @exception IllegalStateException if this node has already been removed - * @exception UnsupportedOperationException if this is a root node - */ - abstract public void removeNode() throws BackingStoreException; - - // abstract methods (listeners) - - abstract public void addNodeChangeListener(NodeChangeListener listener); - - abstract public void addPreferenceChangeListener - (PreferenceChangeListener listener); - - abstract public void removeNodeChangeListener(NodeChangeListener listener); - - abstract public void removePreferenceChangeListener - (PreferenceChangeListener listener); - -} - diff --git a/libjava/java/util/prefs/PreferencesFactory.java b/libjava/java/util/prefs/PreferencesFactory.java deleted file mode 100644 index f43497894f1..00000000000 --- a/libjava/java/util/prefs/PreferencesFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* PreferencesFactory - Preferences system and user root factory interface - Copyright (C) 2001 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 java.util.prefs; - -import java.util.EventListener; - -/** - * Preferences system and user root factory interface. Defines how to get - * to the system and user root preferences objects. Should be implemented by - * new preferences backends. - * - * @since 1.4 - * @author Mark Wielaard (mark@klomp.org) - */ -public interface PreferencesFactory { - - /** - * Returns the system root preferences node. Should always return the - * same object. - */ - Preferences systemRoot(); - - /** - * Returns the user root preferences node. May return different objects - * depending on the user that called this method. The user may for example - * be determined by the current Thread or the Subject associated with the - * current AccessControllContext. - */ - Preferences userRoot(); - -} diff --git a/libjava/jni/classpath/jcl.c b/libjava/jni/classpath/jcl.c deleted file mode 100644 index 66c756e0ffd..00000000000 --- a/libjava/jni/classpath/jcl.c +++ /dev/null @@ -1,134 +0,0 @@ -/* jcl.c - Copyright (C) 1998 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. */ - -#include <stdio.h> -#include <jcl.h> -#include <malloc.h> - -static char errstr[4098]; // this way the memory is pre-allocated, so that we do not have to worry if we are out of memory. - -JNIEXPORT void JNICALL JCL_ThrowException(JNIEnv * env, char * className, char * errMsg) { - jclass excClass; - if((*env)->ExceptionOccurred(env)) { - (*env)->ExceptionClear(env); - } - excClass = (*env)->FindClass(env, className); - if(excClass == NULL) { - jclass errExcClass; - errExcClass = (*env)->FindClass(env, "java/lang/ClassNotFoundException"); - if(errExcClass == NULL) { - errExcClass = (*env)->FindClass(env, "java/lang/InternalError"); - if(errExcClass == NULL) { - sprintf(errstr,"JCL: Utterly failed to throw exeption %s with message %s.",className,errMsg); - fprintf(stderr, errstr); - return; - } - } - sprintf(errstr,"JCL: Failed to throw exception %s with message %s: could not find exception class.", className, errMsg); - (*env)->ThrowNew(env, errExcClass, errstr); - } - (*env)->ThrowNew(env, excClass, errMsg); -} - -JNIEXPORT void * JNICALL JCL_malloc(JNIEnv * env, size_t size) { - void * mem = malloc(size); - if(mem == NULL) { - JCL_ThrowException(env, "java/lang/OutOfMemoryError", "malloc() failed."); - return NULL; - } - return mem; -} - -JNIEXPORT void * JNICALL JCL_realloc(JNIEnv *env, void *ptr, size_t size) -{ - ptr = realloc(ptr, size); - if (ptr == 0) - { - JCL_ThrowException(env, "java/lang/OutOfMemoryError", - "malloc() failed."); - return NULL; - } - return(ptr); -} - -JNIEXPORT void JNICALL JCL_free(JNIEnv * env, void * p) { - if(p != NULL) { - free(p); - } -} - -JNIEXPORT char * JNICALL JCL_jstring_to_cstring(JNIEnv * env, jstring s) { - char* cstr; - if(s == NULL) { - JCL_ThrowException(env, "java/lang/NullPointerException","Null string"); - return NULL; - } - cstr = (char*)(*env)->GetStringUTFChars(env, s, NULL); - if(cstr == NULL) { - JCL_ThrowException(env, "java/lang/InternalError", "GetStringUTFChars() failed."); - return NULL; - } - return cstr; -} - -JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv * env, jstring s, char * cstr) { - (*env)->ReleaseStringUTFChars(env, s, cstr); -} - -JNIEXPORT jint JNICALL JCL_MonitorEnter(JNIEnv * env, jobject o) { - jint retval = (*env)->MonitorEnter(env,o); - if(retval != 0) { - JCL_ThrowException(env, "java/lang/InternalError", "MonitorEnter() failed."); - } - return retval; -} - -JNIEXPORT jint JNICALL JCL_MonitorExit(JNIEnv * env, jobject o) { - jint retval = (*env)->MonitorExit(env,o); - if(retval != 0) { - JCL_ThrowException(env, "java/lang/InternalError", "MonitorExit() failed."); - } - return retval; -} - -JNIEXPORT jclass JNICALL JCL_FindClass(JNIEnv * env, char * className) { - jclass retval = (*env)->FindClass(env,className); - if(retval == NULL) { - JCL_ThrowException(env, "java/lang/ClassNotFoundException", className); - } - return retval; -} diff --git a/libjava/jni/classpath/jcl.h b/libjava/jni/classpath/jcl.h deleted file mode 100644 index a7d00b47cd3..00000000000 --- a/libjava/jni/classpath/jcl.h +++ /dev/null @@ -1,64 +0,0 @@ -/* jcl.h - Copyright (C) 1998 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. */ - -#ifndef __JCL_H__ -#define __JCL_H__ - -#include <stddef.h> -#include <jni.h> -#include <config.h> - -JNIEXPORT jclass JNICALL JCL_FindClass(JNIEnv * env, char * className); -JNIEXPORT void JNICALL JCL_ThrowException(JNIEnv * env, char * className, char * errMsg); -JNIEXPORT void * JNICALL JCL_malloc(JNIEnv *env, size_t size); -JNIEXPORT void * JNICALL JCL_realloc(JNIEnv *env, void *ptr, size_t size); -JNIEXPORT void JNICALL JCL_free(JNIEnv *env, void * p); -JNIEXPORT char * JNICALL JCL_jstring_to_cstring(JNIEnv *env, jstring s); -JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv *env, jstring s, char * cstr); -JNIEXPORT jint JNICALL JCL_MonitorEnter(JNIEnv *env, jobject o); -JNIEXPORT jint JNICALL JCL_MonitorExit(JNIEnv *env, jobject o); - -#define JCL_RETHROW_EXCEPTION(env) if((*(env))->ExceptionOccurred((env)) != NULL) return NULL; - -/* Simple debug macro */ -#ifdef DEBUG -#define DBG(x) fprintf(stderr, (x)); -#else -#define DBG(x) -#endif - -#endif diff --git a/libjava/jni/classpath/jnilink.c b/libjava/jni/classpath/jnilink.c deleted file mode 100644 index 0c244f285af..00000000000 --- a/libjava/jni/classpath/jnilink.c +++ /dev/null @@ -1,117 +0,0 @@ -/* JNILINK 1.1: JNI version. - Copyright (C) 1998 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. */ - - -#include "jnilink.h" -#include <string.h> -#include <jcl.h> - -#include <malloc.h> - -#define GETCLASS(c) *(jclass*)(c) - -JNIEXPORT jclass JNICALL -LINK_RelinkClass (JNIEnv * env, linkedClass * c, char * name) { - jclass found; - LINK_UnlinkClass(env,*c); - - found = (*env)->FindClass(env,name); - if(found == NULL) - return NULL; - - *c = JCL_malloc(env,sizeof(jclass)); - if(*c == NULL) - return NULL; - - GETCLASS(*c) = (*env)->NewGlobalRef(env,found); - return GETCLASS(*c); -} - -JNIEXPORT jclass JNICALL -LINK_RelinkKnownClass(JNIEnv * env, linkedClass * c, jclass newClass) { - LINK_UnlinkClass(env,*c); - - *c = JCL_malloc(env,sizeof(jclass)); - if(*c == NULL) - return NULL; - - GETCLASS(*c) = (*env)->NewGlobalRef(env,newClass); - return newClass; -} - -JNIEXPORT jmethodID JNICALL -LINK_RelinkMethod (JNIEnv * env, jmethodID * m, linkedClass c, - char * name, char * sig) { - *m = (*env)->GetMethodID(env,GETCLASS(c),name,sig); - return *m; -} - -JNIEXPORT jmethodID JNICALL -LINK_RelinkStaticMethod(JNIEnv * env, jmethodID * m, linkedClass c, - char * name, char * sig) { - *m = (*env)->GetStaticMethodID(env,GETCLASS(c),name,sig); - return *m; -} - -JNIEXPORT jfieldID JNICALL -LINK_RelinkField (JNIEnv * env, jfieldID * f, linkedClass c, - char * name, char * sig) { - *f = (*env)->GetFieldID(env,GETCLASS(c),name,sig); - return *f; -} - -JNIEXPORT jfieldID JNICALL -LINK_RelinkStaticField (JNIEnv * env, jfieldID * f, linkedClass c, - char * name, char * sig) { - *f = (*env)->GetStaticFieldID(env,GETCLASS(c),name,sig); - return *f; -} - - -/* These are for when the class referencing the symbols is unloaded; it -destroys any object references - * the linker might have kept around. - */ -JNIEXPORT void JNICALL LINK_UnlinkClass (JNIEnv * env, linkedClass * c) { - if(*c != NULL) { - if(GETCLASS(*c) != NULL) - (*env)->DeleteGlobalRef(env,GETCLASS(*c)); - JCL_free(env,*c); - *c = NULL; - } -} - diff --git a/libjava/jni/classpath/jnilink.h b/libjava/jni/classpath/jnilink.h deleted file mode 100644 index 448e2b5dfdd..00000000000 --- a/libjava/jni/classpath/jnilink.h +++ /dev/null @@ -1,86 +0,0 @@ -/* JNILINK 1.1: JNI version. - Copyright (C) 1998 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. */ - - -#ifndef __JNILINK_H__ -#define __JNILINK_H__ - -#include <jni.h> - -typedef void* linkedClass; - -#define LINK_LinkClass(env,c,name) ((c)==NULL ? LINK_ReallyLinkClass((env),&(c),(name)) : (c)) -#define LINK_LinkKnownClass(env,c,newClass) ((c)==NULL ? LINK_ReallyLinkKnownClass((env),&(c),(newClass)) : (c)) -#define LINK_LinkMethod(env,m,c,name,sig) ((m)==NULL ? LINK_RelinkMethod((env),&(m),(c),(name),(sig)) : (m)) -#define LINK_LinkStaticMethod(env,m,c,name,sig) ((m)==NULL ? LINK_RelinkStaticMethod((env),&(m),(c),(name),(sig)) : (m)) -#define LINK_LinkField(env,f,c,name,sig) ((m)==NULL ? LINK_RelinkField((env),&(f),(c),(name),(sig)) : (f)) -#define LINK_LinkStaticField(env,f,c,name,sig) ((m)==NULL ? LINK_RelinkStaticField((env),&(f),(c),(name),(sig)) : (f)) - -#define LINK_LinkConstructor(env,m,c,sig) ((m)==NULL ? LINK_RelinkMethod((env),&(m),(c),"<init>",(sig)) : (m)) - -JNIEXPORT jclass JNICALL -LINK_ReallyLinkClass (JNIEnv * env, linkedClass * c, - char * name); -JNIEXPORT jclass JNICALL -LINK_ReallyLinkKnownClass(JNIEnv * env, linkedClass * c, - jclass newClass); -JNIEXPORT jclass JNICALL -LINK_RelinkClass (JNIEnv * env, linkedClass * c, - char * name); -JNIEXPORT jclass JNICALL -LINK_RelinkKnownClass (JNIEnv * env, linkedClass * c, - jclass newClass); -JNIEXPORT jmethodID JNICALL -LINK_RelinkMethod (JNIEnv * env, jmethodID * m, linkedClass c, - char * name, char * sig); -JNIEXPORT jmethodID JNICALL -LINK_RelinkStaticMethod(JNIEnv * env, jmethodID * m, linkedClass c, - char * name, char * sig); -JNIEXPORT jfieldID JNICALL -LINK_RelinkField (JNIEnv * env, jfieldID * f, linkedClass c, - char * name, char * sig); -JNIEXPORT jfieldID JNICALL -LINK_RelinkStaticField (JNIEnv * env, jfieldID * f, linkedClass c, - char * name, char * sig); - -/* These are for when the class referencing the symbols is unloaded; it -destroys any object references - * the linker might have kept around. - */ -JNIEXPORT void JNICALL LINK_UnlinkClass (JNIEnv * env, linkedClass * c); - -#endif diff --git a/libjava/jni/classpath/native_state.c b/libjava/jni/classpath/native_state.c deleted file mode 100644 index 746686edd97..00000000000 --- a/libjava/jni/classpath/native_state.c +++ /dev/null @@ -1,247 +0,0 @@ -/* Magical NSA API -- Associate a C ptr with an instance of an object - Copyright (C) 1998, 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. */ - -#include <stdlib.h> -#include <jni.h> -#include "native_state.h" - -#define DEFAULT_TABLE_SIZE 97 - -struct state_table * -init_state_table_with_size (JNIEnv *env, jclass clazz, jint size) -{ - struct state_table *table; - jfieldID hash; - jclass clazz_g; - - hash = (*env)->GetFieldID (env, clazz, "native_state", "I"); - if (hash == NULL) - return NULL; - - clazz_g = (*env)->NewGlobalRef (env, clazz); - if (clazz_g == NULL) - return NULL; - - table = (struct state_table *) malloc (sizeof (struct state_table)); - table->size = size; - table->head = (struct state_node **) calloc (sizeof (struct state_node *), - table->size); - table->hash = hash; - table->clazz = clazz_g; - - return table; -} - -struct state_table * -init_state_table (JNIEnv *env, jclass clazz) -{ - return init_state_table_with_size (env, clazz, DEFAULT_TABLE_SIZE); -} - -static void * -remove_node (struct state_node **head, jint obj_id) -{ - struct state_node *back_ptr = NULL; - struct state_node *node = *head; - - while (node != NULL) - { - if (node->key == obj_id) - { - void *return_value; - if (back_ptr == NULL) - *head = node->next; - else - back_ptr->next = node->next; - return_value = node->c_state; - free (node); - return return_value; - } - back_ptr = node; - node = node->next; - } - - return NULL; -} - -static void * -get_node (struct state_node **head, jint obj_id) -{ - struct state_node *back_ptr = NULL; - struct state_node *node = *head; - - while (node != NULL) - { - if (node->key == obj_id) - { - /* Move the node we found to the front of the list. */ - if (back_ptr != NULL) - { - back_ptr->next = node->next; - node->next = *head; - *head = node; - } - - /* Return the match. */ - return node->c_state; - } - - back_ptr = node; - node = node->next; - } - - return NULL; -} - -static void -add_node (struct state_node **head, jint obj_id, void *state) -{ - struct state_node *node = *head; - struct state_node *back_ptr = NULL; - - struct state_node *new_node; - - if (node != NULL) - { - while (node->next != NULL && obj_id != node->key) - { - back_ptr = node; - node = node->next; - } - - if (node->key == obj_id) - { - /* If we're updating a node, move it to the front of the - list. */ - if (back_ptr != NULL) - { - back_ptr->next = node->next; - node->next = *head; - } - node->c_state = state; - return; - } - } - - new_node = (struct state_node *) malloc (sizeof (struct state_node)); - new_node->key = obj_id; - new_node->c_state = state; - new_node->next = *head; - *head = new_node; -} - -void -set_state_oid (JNIEnv *env, jobject lock, struct state_table *table, - jint obj_id, void *state) -{ - jint hash; - - hash = obj_id % table->size; - - (*env)->MonitorEnter (env, lock); - add_node (&table->head[hash], obj_id, state); - (*env)->MonitorExit (env, lock); -} - -void * -get_state_oid (JNIEnv *env, jobject lock, struct state_table *table, - jint obj_id) -{ - jint hash; - void *return_value; - - hash = obj_id % table->size; - - (*env)->MonitorEnter (env, lock); - return_value = get_node (&table->head[hash], obj_id); - (*env)->MonitorExit (env, lock); - - return return_value; -} - -void * -remove_state_oid (JNIEnv *env, jobject lock, struct state_table *table, - jint obj_id) -{ - jint hash; - void *return_value; - - hash = obj_id % table->size; - - (*env)->MonitorEnter (env, lock); - return_value = remove_node (&table->head[hash], obj_id); - (*env)->MonitorExit (env, lock); - - return return_value; -} - -int -set_state (JNIEnv *env, jobject obj, struct state_table *table, void *state) -{ - jint obj_id; - obj_id = (*env)->GetIntField (env, obj, table->hash); - - if ((*env)->ExceptionOccurred (env) != NULL) - return -1; - - set_state_oid (env, table->clazz, table, obj_id, state); - return 0; -} - -void * -get_state (JNIEnv *env, jobject obj, struct state_table *table) -{ - jint obj_id; - obj_id = (*env)->GetIntField (env, obj, table->hash); - - if ((*env)->ExceptionOccurred (env) != NULL) - return NULL; - - return get_state_oid (env, table->clazz, table, obj_id); -} - -void * -remove_state_slot (JNIEnv *env, jobject obj, struct state_table *table) -{ - jint obj_id; - obj_id = (*env)->GetIntField (env, obj, table->hash); - - if ((*env)->ExceptionOccurred (env) != NULL) - return NULL; - - return remove_state_oid (env, table->clazz, table, obj_id); -} diff --git a/libjava/jni/classpath/native_state.h b/libjava/jni/classpath/native_state.h deleted file mode 100644 index 25ef6b546f1..00000000000 --- a/libjava/jni/classpath/native_state.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Magical NSA API -- Associate a C ptr with an instance of an object - Copyright (C) 1998 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. */ - -#ifndef JCL_NATIVE_STATE -#define JCL_NATIVE_STATE - -#include <jni.h> - -struct state_table -{ - jint size; /* number of slots, should be prime */ - jfieldID hash; /* field containing System.identityHashCode(this) */ - jclass clazz; /* lock aquired for reading/writing nodes */ - struct state_node **head; -}; - -struct state_node -{ - jint key; - void *c_state; - struct state_node *next; -}; - -struct state_table * init_state_table_with_size (JNIEnv *, jclass, jint); -struct state_table * init_state_table (JNIEnv *, jclass); - -/* lowlevel api */ -void set_state_oid (JNIEnv *, jobject, struct state_table *, jint, void *); -void * get_state_oid (JNIEnv *, jobject, struct state_table *, jint); -void * remove_state_oid (JNIEnv *, jobject, struct state_table *, jint); - -/* highlevel api */ -int set_state (JNIEnv *, jobject, struct state_table *, void *); -void * get_state (JNIEnv *, jobject, struct state_table *); -void * remove_state_slot (JNIEnv *, jobject, struct state_table *); - -#endif diff --git a/libjava/jni/classpath/primlib.c b/libjava/jni/classpath/primlib.c deleted file mode 100644 index c7396e2a9a7..00000000000 --- a/libjava/jni/classpath/primlib.c +++ /dev/null @@ -1,463 +0,0 @@ -/* primlib.c - Copyright (C) 1998 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. */ - -#include <jnilink.h> -#include <primlib.h> -#include <jcl.h> - -static jclass nativeWrapClass[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL, - NULL,NULL,NULL, NULL,NULL,NULL}; - -static jclass nativeTypeClass[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL, - NULL,NULL,NULL, NULL,NULL,NULL}; - -static jmethodID nativeWrapClassConstructor[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL, - NULL,NULL,NULL, NULL,NULL,NULL}; - -static jmethodID nativeWrapClassAccessor[PRIMLIB_NUMTYPES] = {NULL,NULL,NULL, NULL,NULL,NULL, - NULL,NULL,NULL, NULL,NULL,NULL}; - -static char * nativeWrapClassName[PRIMLIB_NUMTYPES] = { - NULL, - NULL, - "java/lang/Boolean", - "java/lang/Byte", - "java/lang/Character", - "java/lang/Short", - "java/lang/Integer", - "java/lang/Long", - "java/lang/Float", - "java/lang/Double", - "java/lang/Void", - NULL - }; - -static char * nativeWrapClassConstructorSig[PRIMLIB_NUMTYPES] = { - NULL, - NULL, - "(Z)V", - "(B)V", - "(C)V", - "(S)V", - "(I)V", - "(J)V", - "(F)V", - "(D)V", - "()V", - NULL - }; - -static char * nativeWrapClassAccessorName[PRIMLIB_NUMTYPES] = { - NULL, - NULL, - "booleanValue", - "byteValue", - "charValue", - "shortValue", - "intValue", - "longValue", - "floatValue", - "doubleValue", - NULL, - NULL -}; - -static char * nativeWrapClassAccessorSig[PRIMLIB_NUMTYPES] = { - NULL, - NULL, - "()Z", - "()B", - "()C", - "()S", - "()I", - "()J", - "()F", - "()D", - NULL, - NULL -}; - - -JNIEXPORT jclass JNICALL PRIMLIB_GetNativeWrapClass(JNIEnv * env, int reflectType) { - return LINK_LinkClass(env,nativeWrapClass[reflectType],nativeWrapClassName[reflectType]); -} - -static jclass ActuallyGetNativeTypeClass(JNIEnv * env, int reflectType) { - jclass wrapClass; - jfieldID typeField; - - wrapClass = PRIMLIB_GetNativeWrapClass(env, reflectType); - if(wrapClass == NULL) - return NULL; - typeField = (*env)->GetStaticFieldID(env, wrapClass, "TYPE", "Ljava/lang/Class"); - if(typeField == NULL) - return NULL; - return (*env)->GetStaticObjectField(env, wrapClass, typeField); -} - -JNIEXPORT jclass JNICALL PRIMLIB_GetNativeTypeClass(JNIEnv * env, int reflectType) { - return LINK_LinkKnownClass(env, nativeTypeClass[reflectType], ActuallyGetNativeTypeClass(env,reflectType)); -} - -JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassConstructor(JNIEnv * env, int reflectType) { - PRIMLIB_GetNativeWrapClass(env,reflectType); - return LINK_LinkConstructor(env, nativeWrapClassConstructor[reflectType], nativeWrapClass[reflectType], nativeWrapClassConstructorSig[reflectType]); -} - -JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassAccessor(JNIEnv * env, int reflectType) { - PRIMLIB_GetNativeWrapClass(env,reflectType); - return LINK_LinkMethod(env, nativeWrapClassAccessor[reflectType], nativeWrapClass[reflectType], nativeWrapClassAccessorName[reflectType], nativeWrapClassAccessorSig[reflectType]); -} - - - -JNIEXPORT jobject JNICALL PRIMLIB_WrapBoolean(JNIEnv * env, jboolean b) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_BOOLEAN); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BOOLEAN), construct, b); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapByte (JNIEnv * env, jbyte b) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_BYTE); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE), construct, b); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapChar (JNIEnv * env, jchar c) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_CHAR); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR), construct, c); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapShort (JNIEnv * env, jshort s) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_SHORT); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT), construct, s); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapInt (JNIEnv * env, jint i) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_INT); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT), construct, i); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapLong (JNIEnv * env, jlong l) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_LONG); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG), construct, l); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapFloat (JNIEnv * env, jfloat f) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_FLOAT); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT), construct, f); -} - -JNIEXPORT jobject JNICALL PRIMLIB_WrapDouble (JNIEnv * env, jdouble d) { - jmethodID construct = PRIMLIB_GetNativeWrapClassConstructor(env, PRIMLIB_DOUBLE); - JCL_RETHROW_EXCEPTION(env); - return (*env)->NewObject(env, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_DOUBLE), construct, d); -} - - -JNIEXPORT jboolean JNICALL PRIMLIB_UnwrapBoolean(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BOOLEAN))) { - return PRIMLIB_GetBooleanObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return JNI_FALSE; - } -} - -JNIEXPORT jbyte JNICALL PRIMLIB_UnwrapByte(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) { - return PRIMLIB_GetByteObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jshort JNICALL PRIMLIB_UnwrapShort(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) { - return PRIMLIB_GetShortObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) { - return (jshort)PRIMLIB_GetByteObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jchar JNICALL PRIMLIB_UnwrapChar(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) { - return PRIMLIB_GetCharObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jint JNICALL PRIMLIB_UnwrapInt(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) { - return PRIMLIB_GetIntObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) { - return (jint)PRIMLIB_GetShortObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) { - return (jint)PRIMLIB_GetCharObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) { - return (jint)PRIMLIB_GetByteObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jlong JNICALL PRIMLIB_UnwrapLong(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG))) { - return PRIMLIB_GetLongObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) { - return (jlong)PRIMLIB_GetIntObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) { - return (jlong)PRIMLIB_GetShortObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) { - return (jlong)PRIMLIB_GetCharObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) { - return (jlong)PRIMLIB_GetByteObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jfloat JNICALL PRIMLIB_UnwrapFloat(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT))) { - return PRIMLIB_GetFloatObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG))) { - return (jfloat)PRIMLIB_GetLongObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) { - return (jfloat)PRIMLIB_GetIntObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) { - return (jfloat)PRIMLIB_GetShortObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) { - return (jfloat)PRIMLIB_GetCharObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) { - return (jfloat)PRIMLIB_GetByteObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jdouble JNICALL PRIMLIB_UnwrapDouble(JNIEnv * env, jobject obj) { - if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_DOUBLE))) { - return PRIMLIB_GetDoubleObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT))) { - return (jdouble)PRIMLIB_GetFloatObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG))) { - return (jdouble)PRIMLIB_GetLongObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT))) { - return (jdouble)PRIMLIB_GetIntObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT))) { - return (jdouble)PRIMLIB_GetShortObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR))) { - return (jdouble)PRIMLIB_GetCharObjectValue(env, obj); - } else if((*env)->IsInstanceOf(env, obj, PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE))) { - return (jdouble)PRIMLIB_GetByteObjectValue(env, obj); - } else { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct type."); - return 0; - } -} - -JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveWrapperType(JNIEnv * env, jobject obj) { - jclass typeClass; - if(obj == NULL) { - return PRIMLIB_NULL; - } - - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_DOUBLE); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_DOUBLE; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_FLOAT); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_FLOAT; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_LONG); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_LONG; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_INT); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_INT; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_CHAR); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_CHAR; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_SHORT); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_SHORT; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BYTE); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_BYTE; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_BOOLEAN); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_BOOLEAN; - } - typeClass = PRIMLIB_GetNativeWrapClass(env, PRIMLIB_VOID); - if((*env)->IsInstanceOf(env, obj, typeClass)) { - return PRIMLIB_VOID; - } - return PRIMLIB_OBJECT; -} - -JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveType(JNIEnv * env, jclass returnType) { - jclass typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_DOUBLE); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_DOUBLE; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_FLOAT); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_FLOAT; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_LONG); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_LONG; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_INT); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_INT; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_CHAR); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_CHAR; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_SHORT); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_SHORT; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_BYTE); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_BYTE; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_BOOLEAN); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_BOOLEAN; - } - typeClass = PRIMLIB_GetNativeTypeClass(env, PRIMLIB_VOID); - if((*env)->IsAssignableFrom(env, returnType, typeClass)) { - return PRIMLIB_VOID; - } - return PRIMLIB_OBJECT; -} - - -JNIEXPORT jboolean JNICALL PRIMLIB_GetBooleanObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_BOOLEAN); - return (*env)->CallBooleanMethod(env, obj, acc); -} - -JNIEXPORT jbyte JNICALL PRIMLIB_GetByteObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_BYTE); - return (*env)->CallByteMethod(env, obj, acc); -} - -JNIEXPORT jshort JNICALL PRIMLIB_GetShortObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_SHORT); - return (*env)->CallShortMethod(env, obj, acc); -} - -JNIEXPORT jchar JNICALL PRIMLIB_GetCharObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_CHAR); - return (*env)->CallCharMethod(env, obj, acc); -} - -JNIEXPORT jint JNICALL PRIMLIB_GetIntObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_INT); - return (*env)->CallIntMethod(env, obj, acc); -} - -JNIEXPORT jlong JNICALL PRIMLIB_GetLongObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_LONG); - return (*env)->CallLongMethod(env, obj, acc); -} - -JNIEXPORT jfloat JNICALL PRIMLIB_GetFloatObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_FLOAT); - return (*env)->CallFloatMethod(env, obj, acc); -} - -JNIEXPORT jdouble JNICALL PRIMLIB_GetDoubleObjectValue(JNIEnv * env, jobject obj) { - jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor(env, PRIMLIB_DOUBLE); - return (*env)->CallDoubleMethod(env, obj, acc); -} - - - -JNIEXPORT jvalue JNICALL PRIMLIB_UnwrapJValue(JNIEnv* env, jobject obj, jclass classType) { - jvalue retval; - jint objType = PRIMLIB_GetReflectiveType(env, classType); - if(objType == PRIMLIB_BOOLEAN) { - retval.z = PRIMLIB_UnwrapBoolean(env,obj); - } else if(objType == PRIMLIB_BYTE) { - retval.b = PRIMLIB_UnwrapByte(env,obj); - } else if(objType == PRIMLIB_CHAR) { - retval.c = PRIMLIB_UnwrapChar(env,obj); - } else if(objType == PRIMLIB_SHORT) { - retval.s = PRIMLIB_UnwrapShort(env,obj); - } else if(objType == PRIMLIB_INT) { - retval.i = PRIMLIB_UnwrapInt(env,obj); - } else if(objType == PRIMLIB_LONG) { - retval.j = PRIMLIB_UnwrapLong(env,obj); - } else if(objType == PRIMLIB_FLOAT) { - retval.f = PRIMLIB_UnwrapFloat(env,obj); - } else if(objType == PRIMLIB_DOUBLE) { - retval.d = PRIMLIB_UnwrapDouble(env,obj); - } else { - if(obj != NULL && !(*env)->IsInstanceOf(env, obj, classType)) { - JCL_ThrowException(env, "java/lang/IllegalArgumentException", "Argument not of correct object type."); - return retval; - } - retval.l = obj; - } - return retval; -} - diff --git a/libjava/jni/classpath/primlib.h b/libjava/jni/classpath/primlib.h deleted file mode 100644 index 12f3bae9185..00000000000 --- a/libjava/jni/classpath/primlib.h +++ /dev/null @@ -1,102 +0,0 @@ -/* primlib.h - Copyright (C) 1998 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. */ - -#ifndef __PRIMLIB_H__ -#define __PRIMLIB_H__ - -#include <jni.h> - -#define PRIMLIB_UNKNOWN 0 -#define PRIMLIB_OBJECT 1 -#define PRIMLIB_BOOLEAN 2 -#define PRIMLIB_BYTE 3 -#define PRIMLIB_CHAR 4 -#define PRIMLIB_SHORT 5 -#define PRIMLIB_INT 6 -#define PRIMLIB_LONG 7 -#define PRIMLIB_FLOAT 8 -#define PRIMLIB_DOUBLE 9 -#define PRIMLIB_VOID 10 -#define PRIMLIB_NULL 11 -#define PRIMLIB_NUMTYPES 12 - -/* Low-level primitive class accessor functions. */ -JNIEXPORT jclass JNICALL PRIMLIB_GetNativeWrapClass(JNIEnv * env, int reflectType); -JNIEXPORT jclass JNICALL PRIMLIB_GetNativeTypeClass(JNIEnv * env, int reflectType); -JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassConstructor(JNIEnv * env, int reflectType); -JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassAccessor(JNIEnv * env, int reflectType); - -/* Type discovery functions: WrapperType finds out j.l.Boolean/Byte/etc., and - Type finds out j.l.Boolean.TYPE, etc. -*/ -JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveWrapperType(JNIEnv * env, jobject obj); -JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveType(JNIEnv * env, jclass returnType); - -/* Constructor functions. */ -JNIEXPORT jobject JNICALL PRIMLIB_WrapBoolean(JNIEnv * env, jboolean b); -JNIEXPORT jobject JNICALL PRIMLIB_WrapByte (JNIEnv * env, jbyte b); -JNIEXPORT jobject JNICALL PRIMLIB_WrapChar (JNIEnv * env, jchar c); -JNIEXPORT jobject JNICALL PRIMLIB_WrapShort (JNIEnv * env, jshort s); -JNIEXPORT jobject JNICALL PRIMLIB_WrapInt (JNIEnv * env, jint i); -JNIEXPORT jobject JNICALL PRIMLIB_WrapLong (JNIEnv * env, jlong l); -JNIEXPORT jobject JNICALL PRIMLIB_WrapFloat (JNIEnv * env, jfloat f); -JNIEXPORT jobject JNICALL PRIMLIB_WrapDouble (JNIEnv * env, jdouble d); - -/* Widening conversion unwrapping functions. */ -JNIEXPORT jboolean JNICALL PRIMLIB_UnwrapBoolean(JNIEnv * env, jobject obj); -JNIEXPORT jbyte JNICALL PRIMLIB_UnwrapByte (JNIEnv * env, jobject obj); -JNIEXPORT jshort JNICALL PRIMLIB_UnwrapShort (JNIEnv * env, jobject obj); -JNIEXPORT jchar JNICALL PRIMLIB_UnwrapChar (JNIEnv * env, jobject obj); -JNIEXPORT jint JNICALL PRIMLIB_UnwrapInt (JNIEnv * env, jobject obj); -JNIEXPORT jlong JNICALL PRIMLIB_UnwrapLong (JNIEnv * env, jobject obj); -JNIEXPORT jfloat JNICALL PRIMLIB_UnwrapFloat (JNIEnv * env, jobject obj); -JNIEXPORT jdouble JNICALL PRIMLIB_UnwrapDouble (JNIEnv * env, jobject obj); - -/* Simple unwrapping functions. Objects *must* be of correct type. */ -JNIEXPORT jboolean JNICALL PRIMLIB_GetBooleanObjectValue(JNIEnv * env, jobject obj); -JNIEXPORT jbyte JNICALL PRIMLIB_GetByteObjectValue (JNIEnv * env, jobject obj); -JNIEXPORT jshort JNICALL PRIMLIB_GetShortObjectValue (JNIEnv * env, jobject obj); -JNIEXPORT jchar JNICALL PRIMLIB_GetCharObjectValue (JNIEnv * env, jobject obj); -JNIEXPORT jint JNICALL PRIMLIB_GetIntObjectValue (JNIEnv * env, jobject obj); -JNIEXPORT jlong JNICALL PRIMLIB_GetLongObjectValue (JNIEnv * env, jobject obj); -JNIEXPORT jfloat JNICALL PRIMLIB_GetFloatObjectValue (JNIEnv * env, jobject obj); -JNIEXPORT jdouble JNICALL PRIMLIB_GetDoubleObjectValue (JNIEnv * env, jobject obj); - -/* jvalue conversion: Unwrap obj to the type of classType, with widening conversion. */ -JNIEXPORT jvalue JNICALL PRIMLIB_UnwrapJValue(JNIEnv* env, jobject obj, jclass classType); - -#endif diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c deleted file mode 100644 index 03c1e4925d7..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c +++ /dev/null @@ -1,102 +0,0 @@ -/* gdkfontmetrics.c - Copyright (C) 1999, 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. */ - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GdkFontMetrics.h" -#include <gdk/gdkx.h> - -#define ASCENT 0 -#define MAX_ASCENT 1 -#define DESCENT 2 -#define MAX_DESCENT 3 -#define MAX_ADVANCE 4 -#define NUM_METRICS 5 - -JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkFontMetrics_initState - (JNIEnv *env, jobject obj, jstring fname, jint size) -{ - jintArray array; - jint *metrics; - const char *cfname; - char *xlfd; - GdkFont *font; - XFontStruct *xfont; - - cfname = (*env)->GetStringUTFChars (env, fname, NULL); - xlfd = g_strdup_printf (cfname, (size * 10)); - (*env)->ReleaseStringUTFChars (env, fname, cfname); - - array = (*env)->NewIntArray (env, NUM_METRICS); - metrics = (*env)->GetIntArrayElements (env, array, NULL); - - gdk_threads_enter (); - font = gdk_font_load (xlfd); - xfont = GDK_FONT_XFONT (font); - - metrics[ASCENT] = font->ascent; - metrics[MAX_ASCENT] = xfont->max_bounds.ascent; - metrics[DESCENT] = font->descent; - metrics[MAX_DESCENT] = xfont->max_bounds.descent; - metrics[MAX_ADVANCE] = xfont->max_bounds.width; - gdk_threads_leave (); - - g_free (xlfd); - (*env)->ReleaseIntArrayElements (env, array, metrics, 0); - - NSA_SET_PTR (env, obj, font); - - return array; -} - -JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkFontMetrics_stringWidth - (JNIEnv *env, jobject obj, jstring str) -{ - GdkFont *font; - const char *cstr; - jint width; - - font = (GdkFont *) NSA_GET_PTR (env, obj); - cstr = (*env)->GetStringUTFChars (env, str, NULL); - - gdk_threads_enter (); - width = gdk_string_width (font, cstr); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, str, cstr); - - return width; -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c deleted file mode 100644 index 41e9db6b8fa..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c +++ /dev/null @@ -1,498 +0,0 @@ -/* gdkgraphics.c - Copyright (C) 1999, 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. */ - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GdkGraphics.h" -#include <gdk/gdkprivate.h> -#include <gdk/gdkx.h> - -#define GDK_STABLE_IS_PIXMAP(d) (((GdkWindowPrivate *)d)->window_type == GDK_WINDOW_PIXMAP) - -GdkPoint * -translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints, - jint npoints, jint x_offset, jint y_offset); - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState - (JNIEnv *env, jobject obj, jobject old) -{ - struct graphics *g, *g_old; - - g = (struct graphics *) malloc (sizeof (struct graphics)); - g_old = (struct graphics *) NSA_GET_PTR (env, old); - - *g = *g_old; - - gdk_threads_enter (); - - g->gc = gdk_gc_new (g->drawable); - gdk_gc_copy (g->gc, g_old->gc); - - if (GDK_STABLE_IS_PIXMAP (g->drawable)) - gdk_pixmap_ref (g->drawable); - else /* GDK_IS_WINDOW (g->drawable) */ - gdk_window_ref (g->drawable); - - gdk_colormap_ref (g->cm); - - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, g); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II - (JNIEnv *env, jobject obj, jint width, jint height) -{ - struct graphics *g; - - g = (struct graphics *) malloc (sizeof (struct graphics)); - g->x_offset = g->y_offset = 0; - - gdk_threads_enter (); - g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height, - gdk_rgb_get_visual ()->depth); - g->cm = gdk_rgb_get_cmap (); - gdk_colormap_ref (g->cm); - g->gc = gdk_gc_new (g->drawable); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, g); -} - -/* copy the native state of the peer (GtkWidget *) to the native state - of the graphics object */ -JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 - (JNIEnv *env, jobject obj, jobject peer) -{ - struct graphics *g = (struct graphics *) malloc (sizeof (struct graphics)); - void *ptr; - GtkWidget *widget; - GdkColor color; - jintArray array; - jint *rgb; - - ptr = NSA_GET_PTR (env, peer); - g->x_offset = g->y_offset = 0; - - gdk_threads_enter (); - - widget = GTK_WIDGET (ptr); - - if (GTK_IS_WINDOW (widget)) - { - g->drawable = find_gtk_layout (widget)->bin_window; - } - else if (GTK_IS_LAYOUT (widget)) - { - g->drawable = (GdkDrawable *) GTK_LAYOUT (widget)->bin_window; - } - else - { - g->drawable = (GdkDrawable *) widget->window; - } - - gdk_window_ref (g->drawable); - g->cm = gtk_widget_get_colormap (widget); - gdk_colormap_ref (g->cm); - g->gc = gdk_gc_new (g->drawable); - gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]); - color = widget->style->fg[GTK_STATE_NORMAL]; - - gdk_threads_leave (); - - array = (*env)->NewIntArray (env, 3); - rgb = (*env)->GetIntArrayElements (env, array, NULL); - rgb[0] = color.red >> 8; - rgb[1] = color.green >> 8; - rgb[2] = color.blue >> 8; - (*env)->ReleaseIntArrayElements (env, array, rgb, 0); - - NSA_SET_PTR (env, obj, g); - - return array; -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose - (JNIEnv *env, jobject obj) -{ - struct graphics *g; - - g = (struct graphics *) NSA_DEL_PTR (env, obj); - - if (!g) return; /* dispose has been called more than once */ - - gdk_threads_enter (); - XFlush (GDK_DISPLAY ()); - - gdk_gc_destroy (g->gc); - - if (GDK_STABLE_IS_PIXMAP (g->drawable)) - gdk_pixmap_unref (g->drawable); - else /* GDK_IS_WINDOW (g->drawable) */ - gdk_window_unref (g->drawable); - - gdk_colormap_unref (g->cm); - - gdk_threads_leave (); - - free (g); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative - (JNIEnv *env, jobject obj, jint x, jint y) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - g->x_offset += x; - g->y_offset += y; - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString - (JNIEnv *env, jobject obj, jstring str, jint x, jint y, - jstring fname, jint size) -{ - struct graphics *g; - const char *cfname, *cstr; - gchar *xlfd; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - cfname = (*env)->GetStringUTFChars (env, fname, NULL); - xlfd = g_strdup_printf (cfname, (size * 10)); - (*env)->ReleaseStringUTFChars (env, fname, cfname); - - cstr = (*env)->GetStringUTFChars (env, str, NULL); - - gdk_threads_enter (); - gdk_draw_string (g->drawable, gdk_font_load (xlfd), g->gc, - x + g->x_offset, y + g->y_offset, cstr); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, str, cstr); - g_free (xlfd); -} - - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine - (JNIEnv *env, jobject obj, jint x, jint y, jint x2, jint y2) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_line (g->drawable, g->gc, - x + g->x_offset, y + g->y_offset, - x2 + g->x_offset, y2 + g->y_offset); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_rectangle (g->drawable, g->gc, TRUE, - x + g->x_offset, y + g->y_offset, width, height); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_rectangle (g->drawable, g->gc, FALSE, - x + g->x_offset, y + g->y_offset, width, height); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea - (JNIEnv *env, jobject obj, jint x, jint y, - jint width, jint height, jint dx, jint dy) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_window_copy_area ((GdkWindow *)g->drawable, - g->gc, - x + g->x_offset + dx, y + g->y_offset + dy, - (GdkWindow *)g->drawable, - x + g->x_offset, y + g->y_offset, - width, height); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyPixmap - (JNIEnv *env, jobject obj, jobject offscreen, - jint x, jint y, jint width, jint height) -{ - struct graphics *g1, *g2; - - g1 = (struct graphics *) NSA_GET_PTR (env, obj); - g2 = (struct graphics *) NSA_GET_PTR (env, offscreen); - - gdk_threads_enter (); - gdk_window_copy_area ((GdkWindow *)g1->drawable, - g1->gc, - x + g1->x_offset, y + g1->y_offset, - (GdkWindow *)g2->drawable, - 0 + g2->x_offset, 0 + g2->y_offset, - width, height); - gdk_threads_leave (); -} - - - - - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_window_clear_area ((GdkWindow *)g->drawable, - x + g->x_offset, y + g->y_offset, width, height); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction - (JNIEnv *env, jobject obj, jint func) -{ - struct graphics *g; - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_gc_set_function (g->gc, func); - gdk_threads_leave (); -} - - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor - (JNIEnv *env, jobject obj, jint red, jint green, jint blue) -{ - GdkColor color; - struct graphics *g; - - color.red = red << 8; - color.green = green << 8; - color.blue = blue << 8; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_color_alloc (g->cm, &color); - gdk_gc_set_foreground (g->gc, &color); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, - jint angle1, jint angle2) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_arc (g->drawable, g->gc, FALSE, - x + g->x_offset, y + g->y_offset, - width, height, angle1 << 6, angle2 << 6); - gdk_threads_leave (); -} - -GdkPoint * -translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints, - jint npoints, jint x_offset, jint y_offset) -{ - GdkPoint *points; - jint *x, *y; - int i; - - /* allocate one more point than necessary, in case we need to tack - on an extra due to the semantics of Java polygons. */ - points = g_malloc (sizeof (GdkPoint) * (npoints + 1)); - - x = (*env)->GetIntArrayElements (env, xpoints, NULL); - y = (*env)->GetIntArrayElements (env, ypoints, NULL); - - for (i = 0; i < npoints; i++) - { - points[i].x = x[i] + x_offset; - points[i].y = y[i] + y_offset; - } - - (*env)->ReleaseIntArrayElements (env, xpoints, x, JNI_ABORT); - (*env)->ReleaseIntArrayElements (env, ypoints, y, JNI_ABORT); - - return points; -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline - (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, - jint npoints) -{ - struct graphics *g; - GdkPoint *points; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - points = translate_points (env, xpoints, ypoints, npoints, - g->x_offset, g->y_offset); - - gdk_threads_enter (); - gdk_draw_lines (g->drawable, g->gc, points, npoints); - gdk_threads_leave (); - - g_free (points); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon - (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, - jint npoints) -{ - struct graphics *g; - GdkPoint *points; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - points = translate_points (env, xpoints, ypoints, npoints, - g->x_offset, g->y_offset); - - /* make sure the polygon is closed, per Java semantics. - if it's not, we close it. */ - if (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y) - points[npoints++] = points[0]; - - gdk_threads_enter (); - gdk_draw_lines (g->drawable, g->gc, points, npoints); - gdk_threads_leave (); - - g_free (points); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon - (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, - jint npoints) -{ - struct graphics *g; - GdkPoint *points; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - points = translate_points (env, xpoints, ypoints, npoints, - g->x_offset, g->y_offset); - gdk_threads_enter (); - gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); - gdk_threads_leave (); - - g_free (points); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, - jint angle1, jint angle2) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_arc (g->drawable, g->gc, TRUE, - x + g->x_offset, y + g->y_offset, - width, height, angle1 << 6, angle2 << 6); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_arc (g->drawable, g->gc, FALSE, - x + g->x_offset, y + g->y_offset, - width, height, 0, 23040); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - struct graphics *g; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_draw_arc (g->drawable, g->gc, TRUE, - x + g->x_offset, y + g->y_offset, - width, height, 0, 23040); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - struct graphics *g; - GdkRectangle rectangle; - - g = (struct graphics *) NSA_GET_PTR (env, obj); - - rectangle.x = x + g->x_offset; - rectangle.y = y + g->y_offset; - rectangle.width = width; - rectangle.height = height; - - gdk_threads_enter (); - gdk_gc_set_clip_rectangle (g->gc, &rectangle); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c deleted file mode 100644 index e33aff046fc..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c +++ /dev/null @@ -1,88 +0,0 @@ -/* gtkbuttonpeer.c -- Native implementation of GtkButtonPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkButtonPeer.h" - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create - (JNIEnv *env, jobject obj) -{ - gpointer widget; - - gdk_threads_enter (); - widget = gtk_type_new (gtk_button_get_type ()); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetFont - (JNIEnv *env, jobject obj, jstring jname, jint size) -{ - const char *xlfd; -# define FBUFSZ 200 - char buf[FBUFSZ]; - void *ptr; - GdkFont * new_font; - GtkStyle * style; - GtkWidget * button; - GtkWidget * label; - - ptr = NSA_GET_PTR (env, obj); - button = GTK_WIDGET (ptr); - label = GTK_BIN(button)->child; - - if (label == NULL) return; - xlfd = (*env)->GetStringUTFChars (env, jname, NULL); - snprintf(buf, FBUFSZ, xlfd, size); - (*env)->ReleaseStringUTFChars (env, jname, xlfd); - gdk_threads_enter(); - new_font = gdk_font_load (buf); /* FIXME: deprecated. Replacement? */ - if (new_font == NULL) - { - /* Fail quietly for now. */ - gdk_threads_leave(); - return; - } - style = gtk_style_copy (gtk_widget_get_style (label)); - style -> font = new_font; - gtk_widget_set_style (label, style); - /* FIXME: Documentation varies as to whether we should unref style. */ - gdk_threads_leave(); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c deleted file mode 100644 index cc7cfb8fd30..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c +++ /dev/null @@ -1,54 +0,0 @@ -/* gtkcanvaspeer.c -- Native implementation of GtkCanvasPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkCanvasPeer.h" - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create - (JNIEnv *env, jobject obj) -{ - gpointer widget; - - gdk_threads_enter (); - widget = gtk_type_new (gtk_drawing_area_get_type ()); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, widget); -} - - diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c deleted file mode 100644 index 94b13666776..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c +++ /dev/null @@ -1,73 +0,0 @@ -/* gtkmenuitempeer.c -- Native implementation of GtkMenuItemPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkMenuItemPeer.h" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer_create - (JNIEnv *env, jobject obj, jstring label) -{ - GtkWidget *widget; - const char *str; - - str = (*env)->GetStringUTFChars (env, label, NULL); - - gdk_threads_enter (); - widget = gtk_check_menu_item_new_with_label (str); - gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (widget), 1); - gtk_widget_show (widget); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, label, str); - - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer_setState - (JNIEnv *env, jobject obj, jboolean state) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (ptr), state); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c deleted file mode 100644 index 09fa7ef21b5..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c +++ /dev/null @@ -1,175 +0,0 @@ -/* gtkcheckboxpeer.c -- Native implementation of GtkCheckboxPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkCheckboxPeer.h" -#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" - -static void item_toggled (GtkToggleButton *item, jobject peer); - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_dispose - (JNIEnv *env, jobject obj) -{ - /* The actual underlying widget is owned by a different class. So - we just clean up the hash table here. */ - NSA_DEL_PTR (env, obj); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove - (JNIEnv *env, jobject obj, jobject checkbox) -{ - GtkRadioButton *button; - void *ptr; - GSList *list; - - ptr = NSA_GET_PTR (env, checkbox); - gdk_threads_enter (); - button = GTK_RADIO_BUTTON (ptr); - - /* Update the group to point to some other widget in the group. We - have to do this because Gtk doesn't have a separate object to - represent a radio button's group. */ - for (list = gtk_radio_button_group (button); list != NULL; - list = list->next) - { - if (list->data != button) - break; - } - - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, list ? list->data : NULL); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate - (JNIEnv *env, jobject obj, jobject group) -{ - GtkWidget *button; - - gdk_threads_enter (); - - if (group == NULL) - button = gtk_check_button_new_with_label (""); - else - { - void *native_group = NSA_GET_PTR (env, group); - button = gtk_radio_button_new_with_label_from_widget (native_group, ""); - if (native_group == NULL) - { - /* Set the native group so we can use the correct value the - next time around. FIXME: this doesn't work! */ - NSA_SET_PTR (env, group, button); - } - } - - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, button); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr = NSA_GET_PTR (env, obj); - jobject peer; - - gdk_threads_enter (); - - peer = (*env)->NewGlobalRef (env, obj); - - /* FIXME: when the widget goes away, we should get rid of the global - reference. */ - gtk_signal_connect (GTK_OBJECT (ptr), "toggled", - GTK_SIGNAL_FUNC (item_toggled), peer); - - gdk_threads_leave (); - - /* Connect the superclass hooks. */ - Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks (env, obj); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup - (JNIEnv *env, jobject obj, jobject group) -{ - GtkRadioButton *button; - void *native_group, *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - /* FIXME: we can't yet switch between a checkbutton and a - radiobutton. However, AWT requires this. For now we just - crash. */ - - button = GTK_RADIO_BUTTON (ptr); - - native_group = NSA_GET_PTR (env, group); - if (native_group == NULL) - gtk_radio_button_set_group (button, NULL); - else - gtk_radio_button_set_group (button, - gtk_radio_button_group - (GTK_RADIO_BUTTON (native_group))); - - gdk_threads_leave (); - - /* If the native group wasn't set on the new CheckboxGroup, then set - it now so that the right thing will happen with the next - radiobutton. The native state for a CheckboxGroup is a pointer - to one of the widgets in the group. We are careful to keep this - always pointing at a live widget; whenever a widget is destroyed - (or otherwise removed from the group), the CheckboxGroup peer is - notified. */ - if (native_group == NULL) - NSA_SET_PTR (env, group, native_group); -} - -static void -item_toggled (GtkToggleButton *item, jobject peer) -{ - (*gdk_env)->CallVoidMethod (gdk_env, peer, - postItemEventID, - peer, - item->active ? - (jint) AWT_ITEM_SELECTED : - (jint) AWT_ITEM_DESELECTED); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c deleted file mode 100644 index b3eee27f4c6..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c +++ /dev/null @@ -1,204 +0,0 @@ -/* gtkchoicepeer.c -- Native implementation of GtkChoicePeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkChoicePeer.h" - -static void connect_choice_item_selectable_hook (JNIEnv *env, - jobject peer_obj, - GtkItem *item, - jobject item_obj); -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create - (JNIEnv *env, jobject obj) -{ - GtkWidget *menu; - GtkOptionMenu *option_menu; - GtkRequisition child_requisition; - - gdk_threads_enter (); - option_menu = GTK_OPTION_MENU (gtk_option_menu_new ()); - menu = gtk_menu_new (); - gtk_widget_show (menu); - - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); - - gtk_widget_size_request (gtk_menu_item_new_with_label (""), - &child_requisition); - option_menu->width = child_requisition.width; - option_menu->height = child_requisition.height; - - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, option_menu); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append - (JNIEnv *env, jobject obj, jobjectArray items) -{ - gpointer ptr; - GtkMenu *menu; - jsize count, i; - int need_set_history = 0; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - menu = GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr))); - - if (!gtk_container_children (GTK_CONTAINER (menu))) - need_set_history = 1; - - count = (*env)->GetArrayLength (env, items); - - for (i = 0; i < count; i++) - { - jobject item; - const char *label; - GtkWidget *menuitem; - - item = (*env)->GetObjectArrayElement (env, items, i); - label = (*env)->GetStringUTFChars (env, item, NULL); - - menuitem = gtk_menu_item_new_with_label (label); - - (*env)->ReleaseStringUTFChars (env, item, label); - - gtk_menu_append (menu, menuitem); - gtk_widget_show (menuitem); - - connect_choice_item_selectable_hook (env, obj, - GTK_ITEM (menuitem), item); - } - - if (need_set_history) - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_add - (JNIEnv *env, jobject obj, jstring item, jint index) -{ - void *ptr; - const char *label; - GtkWidget *menu, *menuitem; - int need_set_history = 0; - - ptr = NSA_GET_PTR (env, obj); - - label = (*env)->GetStringUTFChars (env, item, 0); - - gdk_threads_enter (); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr)); - - if (!gtk_container_children (GTK_CONTAINER (menu))) - need_set_history = 1; - - menuitem = gtk_menu_item_new_with_label (label); - gtk_menu_insert (GTK_MENU (menu), menuitem, index); - gtk_widget_show (menuitem); - connect_choice_item_selectable_hook (env, obj, GTK_ITEM (menuitem), item); - - if (need_set_history) - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0); - - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, item, label); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_remove - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - GtkContainer *menu; - GList *children; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - menu = GTK_CONTAINER (gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr))); - children = gtk_container_children (menu); - gtk_container_remove (menu, GTK_WIDGET (g_list_nth (children, index)->data)); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_select - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), index); - gdk_threads_leave (); -} - - -static void -item_activate (GtkItem *item, struct item_event_hook_info *ie) -{ - gdk_threads_leave (); - (*gdk_env)->CallVoidMethod (gdk_env, ie->peer_obj, - postItemEventID, - ie->item_obj, - (jint) AWT_ITEM_SELECTED); - gdk_threads_enter (); -} - -static void -connect_choice_item_selectable_hook (JNIEnv *env, jobject peer_obj, - GtkItem *item, jobject item_obj) -{ - struct item_event_hook_info *ie; - - ie = (struct item_event_hook_info *) - malloc (sizeof (struct item_event_hook_info)); - - ie->peer_obj = (*env)->NewGlobalRef (env, peer_obj); - ie->item_obj = (*env)->NewGlobalRef (env, item_obj); - - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (item_activate), ie); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c deleted file mode 100644 index 7c6beecf1b1..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c +++ /dev/null @@ -1,180 +0,0 @@ -/* gtkclipboard.c - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkClipboard.h" - -jmethodID stringSelectionReceivedID; -jmethodID stringSelectionHandlerID; -jmethodID selectionClearID; - -void selection_received (GtkWidget *, GtkSelectionData *, guint, gpointer); -void selection_get (GtkWidget *, GtkSelectionData *, guint, guint, gpointer); -gint selection_clear (GtkWidget *, GdkEventSelection *); - -GtkWidget *clipboard; -jobject cb_obj; - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, - jobject obj) -{ - if (!stringSelectionReceivedID) - { - jclass gtkclipboard; - - gtkclipboard = (*env)->FindClass (env, - "gnu/java/awt/peer/gtk/GtkClipboard"); - stringSelectionReceivedID = (*env)->GetMethodID (env, gtkclipboard, - "stringSelectionReceived", - "(Ljava/lang/String;)V"); - stringSelectionHandlerID = (*env)->GetMethodID (env, gtkclipboard, - "stringSelectionHandler", - "()Ljava/lang/String;"); - selectionClearID = (*env)->GetMethodID (env, gtkclipboard, - "selectionClear", "()V"); - } - - cb_obj = (*env)->NewGlobalRef (env, obj); - - gdk_threads_enter (); - clipboard = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_signal_connect (GTK_OBJECT(clipboard), "selection_received", - GTK_SIGNAL_FUNC (selection_received), NULL); - - gtk_signal_connect (GTK_OBJECT(clipboard), "selection_clear_event", - GTK_SIGNAL_FUNC (selection_clear), NULL); - - gtk_selection_add_target (clipboard, GDK_SELECTION_PRIMARY, - GDK_TARGET_STRING, GDK_TARGET_STRING); - - gtk_signal_connect (GTK_OBJECT(clipboard), "selection_get", - GTK_SIGNAL_FUNC (selection_get), NULL); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkClipboard_requestStringConversion (JNIEnv *env, - jclass clazz) -{ - gdk_threads_enter (); - gtk_selection_convert (clipboard, GDK_SELECTION_PRIMARY, - GDK_TARGET_STRING, GDK_CURRENT_TIME); - gdk_threads_leave (); -} - -void -selection_received (GtkWidget *widget, GtkSelectionData *selection_data, - guint time, gpointer data) -{ - /* Check to see if retrieval succeeded */ - if (selection_data->length < 0 - || selection_data->type != GDK_SELECTION_TYPE_STRING) - { - (*gdk_env)->CallVoidMethod (gdk_env, cb_obj, stringSelectionReceivedID, - NULL); - } - else - { - char *str = (char *) selection_data->data; - - (*gdk_env)->CallVoidMethod (gdk_env, cb_obj, stringSelectionReceivedID, - (*gdk_env)->NewStringUTF (gdk_env, str)); - } - - return; -} - -void -selection_get (GtkWidget *widget, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer data) -{ - jstring jstr; - const char *utf; - jsize utflen; - - jstr = (*gdk_env)->CallObjectMethod (gdk_env, cb_obj, - stringSelectionHandlerID); - - if (!jstr) - { - gtk_selection_data_set (selection_data, - GDK_TARGET_STRING, 8, NULL, 0); - return; - } - - utflen = (*gdk_env)->GetStringUTFLength (gdk_env, jstr); - utf = (*gdk_env)->GetStringUTFChars (gdk_env, jstr, NULL); - - gtk_selection_data_set (selection_data, GDK_TARGET_STRING, 8, - (char *)utf, utflen); - - (*gdk_env)->ReleaseStringUTFChars (gdk_env, jstr, utf); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkClipboard_selectionGet (JNIEnv *env, - jclass clazz) -{ - GdkWindow *owner; - - gdk_threads_enter (); - - /* if we already own the clipboard, we need to tell the old data object - that we're no longer going to be using him */ - owner = gdk_selection_owner_get (GDK_SELECTION_PRIMARY); - if (owner && owner == clipboard->window) - (*env)->CallVoidMethod (env, cb_obj, selectionClearID); - - gtk_selection_owner_set (clipboard, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME); - - gdk_threads_leave (); -} - -gint -selection_clear (GtkWidget *widget, GdkEventSelection *event) -{ - (*gdk_env)->CallVoidMethod (gdk_env, cb_obj, selectionClearID); - - return TRUE; -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c deleted file mode 100644 index 5522354e35d..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c +++ /dev/null @@ -1,649 +0,0 @@ -/* gtkcomponentpeer.c -- Native implementation of GtkComponentPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" -#include <gtk/gtkprivate.h> - -#define GTK_OBJECT_SETV(ptr, arg) \ - gdk_threads_enter (); \ - { \ - GtkArgInfo *info = NULL; \ - char *error; \ - \ - error = gtk_object_arg_get_info (GTK_OBJECT_TYPE (ptr), arg.name, &info); \ - if (error) \ - { \ - /* assume the argument is destined for the container's only child */ \ - ptr = gtk_container_children (GTK_CONTAINER (ptr))->data; \ - } \ - gtk_object_setv (GTK_OBJECT (ptr), 1, &arg); \ - } \ - gdk_threads_leave (); \ - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkGenericPeer_dispose - (JNIEnv *env, jobject obj) -{ - void *ptr; - - ptr = NSA_DEL_PTR (env, obj); - - /* For now the native state for any object must be a widget. - However, a subclass could override dispose() if required. */ - gdk_threads_enter (); - gtk_widget_destroy (GTK_WIDGET (ptr)); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor - (JNIEnv *env, jobject obj, jint type) -{ - void *ptr; - GtkWidget *widget; - GdkCursorType gdk_cursor_type; - GdkCursor *gdk_cursor; - - ptr = NSA_GET_PTR (env, obj); - - switch (type) - { - case AWT_CROSSHAIR_CURSOR: - gdk_cursor_type = GDK_CROSSHAIR; - break; - case AWT_TEXT_CURSOR: - gdk_cursor_type = GDK_XTERM; - break; - case AWT_WAIT_CURSOR: - gdk_cursor_type = GDK_WATCH; - break; - case AWT_SW_RESIZE_CURSOR: - gdk_cursor_type = GDK_BOTTOM_LEFT_CORNER; - break; - case AWT_SE_RESIZE_CURSOR: - gdk_cursor_type = GDK_BOTTOM_RIGHT_CORNER; - break; - case AWT_NW_RESIZE_CURSOR: - gdk_cursor_type = GDK_TOP_LEFT_CORNER; - break; - case AWT_NE_RESIZE_CURSOR: - gdk_cursor_type = GDK_TOP_RIGHT_CORNER; - break; - case AWT_N_RESIZE_CURSOR: - gdk_cursor_type = GDK_TOP_SIDE; - break; - case AWT_S_RESIZE_CURSOR: - gdk_cursor_type = GDK_BOTTOM_SIDE; - break; - case AWT_W_RESIZE_CURSOR: - gdk_cursor_type = GDK_LEFT_SIDE; - break; - case AWT_E_RESIZE_CURSOR: - gdk_cursor_type = GDK_RIGHT_SIDE; - break; - case AWT_HAND_CURSOR: - gdk_cursor_type = GDK_HAND2; - break; - case AWT_MOVE_CURSOR: - gdk_cursor_type = GDK_FLEUR; - break; - default: - gdk_cursor_type = GDK_LEFT_PTR; - } - - gdk_threads_enter (); - - widget = GTK_WIDGET(ptr); - - gdk_cursor = gdk_cursor_new (gdk_cursor_type); - gdk_window_set_cursor (widget->window, gdk_cursor); - gdk_cursor_destroy (gdk_cursor); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_requestFocus - (JNIEnv *env, jobject obj) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_grab_focus (GTK_WIDGET (ptr)); - gdk_threads_leave (); -} - - -/* - * Show a widget (NO LONGER USED) - */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setVisible - (JNIEnv *env, jobject obj, jboolean visible) -{ - GtkWidget *widget; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - widget = GTK_WIDGET (ptr); - - if (visible) - gtk_widget_show (widget); - else - gtk_widget_hide (widget); - - gdk_flush (); - gdk_threads_leave (); -} - -/* - * Find the origin of a widget's window. - */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen - (JNIEnv * env, jobject obj, jintArray jpoint) -{ - void *ptr; - jint *point; - - ptr = NSA_GET_PTR (env, obj); - point = (*env)->GetIntArrayElements (env, jpoint, 0); - - gdk_threads_enter (); - gdk_window_get_origin (GTK_WIDGET (ptr)->window, point, point+1); - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements(env, jpoint, point, 0); -} - -/* - * Find the preferred size of a widget. - */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetDimensions - (JNIEnv *env, jobject obj, jintArray jdims) -{ - void *ptr; - jint *dims; - GtkRequisition req; - - ptr = NSA_GET_PTR (env, obj); - dims = (*env)->GetIntArrayElements (env, jdims, 0); - - gdk_threads_enter (); - - gtk_signal_emit_by_name (GTK_OBJECT (ptr), "size_request", &req); - - dims[0] = req.width; - dims[1] = req.height; - - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements(env, jdims, dims, 0); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetUsize (JNIEnv *env, - jobject obj, jint w, jint h) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_set_usize (GTK_WIDGET (ptr), w, h); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkFixedNew (JNIEnv *env, - jobject obj, jint width, jint height, jboolean visible) -{ - GtkWidget *layout; - - gdk_threads_enter (); - layout = gtk_layout_new (NULL, NULL); - gtk_widget_realize (layout); - connect_awt_hook (env, obj, 1, GTK_LAYOUT (layout)->bin_window); - set_visible (layout, visible); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, layout); -} - -/* - * Place a widget on the layout widget. - */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkFixedPut - (JNIEnv *env, jobject obj, jobject container, jint x, jint y) -{ - GList *child; - GtkWidget *fix; - void *containerptr=NULL; - void *objptr=NULL; - - /* We hawe a container which, if it is a window, will have - this component added to its fixed. If it is a fixed, we add the - component to it. */ - - containerptr=NSA_GET_PTR (env, container); - objptr=NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - if (GTK_IS_WINDOW(GTK_OBJECT(containerptr))) - { - child=gtk_container_children (GTK_CONTAINER(containerptr)); - - while (child && !GTK_IS_FIXED(child->data)) - { - child=g_list_next(child); - } - - fix=GTK_WIDGET(child->data); - g_list_free(child); - } - else - if (GTK_IS_SCROLLED_WINDOW(GTK_OBJECT(containerptr))) - { - child=gtk_container_children (GTK_CONTAINER (GTK_BIN(containerptr)->child)); - - while (child && !GTK_IS_FIXED(child->data)) - { - child=g_list_next(child); - } - - fix=GTK_WIDGET(child->data); - - g_list_free(child); - } - else - { - fix=GTK_WIDGET(containerptr); - } - - gtk_fixed_put(GTK_FIXED(fix),GTK_WIDGET(objptr),x,y); - gtk_widget_realize (GTK_WIDGET (objptr)); - gtk_widget_show (GTK_WIDGET (objptr)); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkFixedMove (JNIEnv *env, - jobject obj, jint x, jint y) -{ - GtkWidget *widget; - void *ptr=NULL; - - /* For some reason, ScrolledWindow tries to scroll its contents - by moving them using this function. Since we want to use GTK's - nice fast scrolling, we try to second guess it here. This - might cause problems later. */ - - if (x >= 0 && y >= 0) - { - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - widget=GTK_WIDGET (ptr); - if (!GTK_IS_WINDOW (widget)) - gtk_fixed_move (GTK_FIXED (widget->parent), widget, x, y); - gdk_threads_leave (); - } -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - GtkWidget *widget; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - widget = GTK_WIDGET (ptr); - if (GTK_IS_VIEWPORT (widget->parent)) - { - gtk_widget_set_usize (widget, width, height); - } - else - { - gtk_widget_set_usize (widget, width, height); - gtk_layout_move (GTK_LAYOUT (widget->parent), widget, x, y); - } - - gdk_threads_leave (); -} - -JNIEXPORT jintArray JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetBackground - (JNIEnv *env, jobject obj) -{ - void *ptr; - jintArray array; - int *rgb; - GdkColor bg; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - bg = GTK_WIDGET (ptr)->style->bg[GTK_STATE_NORMAL]; - gdk_threads_leave (); - - array = (*env)->NewIntArray (env, 3); - rgb = (*env)->GetIntArrayElements (env, array, NULL); - /* convert color data from 16 bit values down to 8 bit values */ - rgb[0] = bg.red >> 8; - rgb[1] = bg.green >> 8; - rgb[2] = bg.blue >> 8; - (*env)->ReleaseIntArrayElements (env, array, rgb, 0); - - return array; -} - -JNIEXPORT jintArray JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetForeground - (JNIEnv *env, jobject obj) -{ - void *ptr; - jintArray array; - jint *rgb; - GdkColor fg; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - fg = GTK_WIDGET (ptr)->style->fg[GTK_STATE_NORMAL]; - gdk_threads_leave (); - - array = (*env)->NewIntArray (env, 3); - rgb = (*env)->GetIntArrayElements (env, array, NULL); - /* convert color data from 16 bit values down to 8 bit values */ - rgb[0] = fg.red >> 8; - rgb[1] = fg.green >> 8; - rgb[2] = fg.blue >> 8; - (*env)->ReleaseIntArrayElements (env, array, rgb, 0); - - return array; -} - -void -set_visible (GtkWidget *widget, jboolean visible) -{ - if (visible) - gtk_widget_show (widget); - else - gtk_widget_hide (widget); -} - -GtkLayout * -find_gtk_layout (GtkWidget *parent) -{ - if (GTK_IS_WINDOW (parent)) - { - GList *children = gtk_container_children - (GTK_CONTAINER (GTK_BIN (parent)->child)); - - if (GTK_IS_MENU_BAR (children->data)) - return GTK_LAYOUT (children->next->data); - else /* GTK_IS_LAYOUT (children->data) */ - return GTK_LAYOUT (children->data); - } - - return NULL; -} - -#define WIDGET_CLASS(w) GTK_WIDGET_CLASS (GTK_OBJECT (w)->klass) - -void -set_parent (GtkWidget *widget, GtkContainer *parent) -{ - if (GTK_IS_WINDOW (parent)) - { - GList *children = gtk_container_children - (GTK_CONTAINER (GTK_BIN (parent)->child)); - - if (GTK_IS_MENU_BAR (children->data)) - gtk_layout_put (GTK_LAYOUT (children->next->data), widget, 0, 0); - else /* GTK_IS_LAYOUT (children->data) */ - gtk_layout_put (GTK_LAYOUT (children->data), widget, 0, 0); - } - else - if (GTK_IS_SCROLLED_WINDOW (parent)) - { -/* if (WIDGET_CLASS (widget)->set_scroll_adjustments_signal) */ -/* gtk_container_add (GTK_CONTAINER (parent), widget); */ -/* else */ -/* { */ - gtk_scrolled_window_add_with_viewport - (GTK_SCROLLED_WINDOW (parent), widget); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (widget->parent), - GTK_SHADOW_NONE); -/* } */ - - } -/* gtk_layout_put */ -/* (GTK_LAYOUT (GTK_BIN (parent)->child), widget, 0, 0); */ - -/* if (GTK_IS_SCROLLED_WINDOW (parent)) */ -/* gtk_layout_put */ -/* (GTK_LAYOUT (GTK_BIN (GTK_BIN (parent)->child)->child), widget, 0, 0); */ - else - gtk_layout_put (GTK_LAYOUT (parent), widget, 0, 0); -} - -JNIEXPORT jboolean JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled - (JNIEnv *env, jobject obj) -{ - void *ptr; - jboolean ret_val; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - ret_val = GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (ptr)); - gdk_threads_leave (); - - return ret_val; -} - -JNIEXPORT jboolean JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_modalHasGrab - (JNIEnv *env, jclass clazz) -{ - GtkWidget *widget; - jboolean retval; - - gdk_threads_enter (); - widget = gtk_grab_get_current (); - retval = (widget && GTK_IS_WINDOW (widget) && GTK_WINDOW (widget)->modal); - gdk_threads_leave (); - - return retval; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_String_2 - (JNIEnv *env, jobject obj, jstring jname, jstring jvalue) -{ - const char *name; - const char *value; - void *ptr; - GtkArg arg; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - value = (*env)->GetStringUTFChars (env, jvalue, NULL); - - arg.type = GTK_TYPE_STRING; - arg.name = (char *) name; - GTK_VALUE_STRING (arg) = (char *) value; - - GTK_OBJECT_SETV (ptr, arg); - - (*env)->ReleaseStringUTFChars (env, jname, name); - (*env)->ReleaseStringUTFChars (env, jvalue, value); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Z - (JNIEnv *env, jobject obj, jstring jname, jboolean value) -{ - const char *name; - void *ptr; - GtkArg arg; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - - arg.type = GTK_TYPE_BOOL; - arg.name = (char *) name; - GTK_VALUE_BOOL (arg) = value; - - GTK_OBJECT_SETV (ptr, arg); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2I - (JNIEnv *env, jobject obj, jstring jname, jint value) -{ - const char *name; - void *ptr; - GtkArg arg; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - - arg.type = GTK_TYPE_INT; - arg.name = (char *) name; - GTK_VALUE_INT (arg) = value; - - GTK_OBJECT_SETV (ptr, arg); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2F - (JNIEnv *env, jobject obj, jstring jname, jfloat value) -{ - const char *name; - void *ptr; - GtkArg arg; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - - arg.type = GTK_TYPE_FLOAT; - arg.name = (char *) name; - GTK_VALUE_FLOAT (arg) = value; - - GTK_OBJECT_SETV (ptr, arg); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_Object_2 - (JNIEnv *env, jobject obj1, jstring jname, jobject obj2) -{ - const char *name; - void *ptr1, *ptr2; - GtkArg arg; - - ptr1 = NSA_GET_PTR (env, obj1); - ptr2 = NSA_GET_PTR (env, obj2); - - name = (*env)->GetStringUTFChars (env, jname, NULL); - - /* special case to catch where we need to set the parent */ - if (!strcmp (name, "parent")) - { - gdk_threads_enter (); - set_parent (GTK_WIDGET (ptr1), GTK_CONTAINER (ptr2)); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, jname, name); - return; - } - - arg.type = GTK_TYPE_OBJECT; - arg.name = (char *) name; - GTK_VALUE_OBJECT (arg) = GTK_OBJECT (ptr2); - - GTK_OBJECT_SETV (ptr1, arg); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_create - (JNIEnv *env, jobject obj, jstring jtypename) -{ - const char *typename; - gpointer widget; - - typename = (*env)->GetStringUTFChars (env, jtypename, NULL); - - gdk_threads_enter (); - gtk_button_get_type (); - widget = gtk_object_newv (gtk_type_from_name (typename), - 0, NULL); -/* widget = gtk_type_new (gtk_type_from_name (typename)); */ - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, jtypename, typename); - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_realize (GTK_WIDGET (ptr)); - connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c deleted file mode 100644 index 99ca0934c3d..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c +++ /dev/null @@ -1,552 +0,0 @@ -/* gtkevents.c -- GDK/GTK event handlers - 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. */ - - -#include "gtkpeer.h" -#include <X11/Xlib.h> -#include <gdk/gdkkeysyms.h> -#include <stdarg.h> -#include <assert.h> - -/* A widget can be composed of multipled windows, so we need to hook - events on all of them. */ -struct event_hook_info -{ - jobject *peer_obj; - int nwindows; - GdkWindow ***windows; /* array of pointers to (GdkWindow *) */ -}; - -static jint -button_to_awt_mods (int button) -{ - switch (button) - { - case 1: - return AWT_BUTTON1_MASK; - case 2: - return AWT_BUTTON2_MASK; - case 3: - return AWT_BUTTON3_MASK; - } - - return 0; -} - -static jint -state_to_awt_mods (int mods) -{ - jint result = 0; - - if (mods & (GDK_SHIFT_MASK | GDK_LOCK_MASK)) - result |= AWT_SHIFT_MASK; - if (mods & GDK_CONTROL_MASK) - result |= AWT_CTRL_MASK; - - return result; -} - -#ifdef __GNUC__ -__inline -#endif -static jint -keysym_to_awt_keycode (guint keyval) -{ - guint vk; - - vk = gdk_keyval_to_upper (keyval); - - if (vk <= 0x41 && vk <= 0x5A) /* VK_A through VK_Z */ - return vk; - - if (vk <= 0x30 && vk <= 39) /* VK_0 through VK_9 */ - return vk; - - switch (vk) - { - case GDK_Alt_L: - case GDK_Alt_R: - return VK_ALT; - case GDK_BackSpace: - return VK_BACK_SPACE; - case GDK_Cancel: - return VK_CANCEL; - case GDK_Caps_Lock: - return VK_CAPS_LOCK; - case GDK_Clear: - return VK_CLEAR; - case GDK_bracketright: - return VK_CLOSE_BRACKET; - case GDK_comma: - return VK_COMMA; - case GDK_Control_L: - case GDK_Control_R: - return VK_CONTROL; - case GDK_KP_Decimal: - return VK_DECIMAL; - case GDK_Delete: - return VK_DELETE; - case GDK_KP_Divide: - return VK_DIVIDE; - case GDK_Down: - return VK_DOWN; - case GDK_End: - return VK_END; - case GDK_Return: - return VK_ENTER; - case GDK_Escape: - return VK_ESCAPE; - case GDK_F1: - return VK_F1; - case GDK_F2: - return VK_F2; - case GDK_F3: - return VK_F3; - case GDK_F4: - return VK_F4; - case GDK_F5: - return VK_F5; - case GDK_F6: - return VK_F6; - case GDK_F7: - return VK_F7; - case GDK_F8: - return VK_F8; - case GDK_F9: - return VK_F9; - case GDK_F10: - return VK_F10; - case GDK_F11: - return VK_F11; - case GDK_F12: - return VK_F12; - case GDK_Help: - return VK_HELP; - case GDK_Home: - return VK_HOME; - case GDK_Insert: - return VK_INSERT; - case GDK_Kanji: - return VK_KANJI; - case GDK_Left: - return VK_LEFT; - case GDK_Meta_L: - case GDK_Meta_R: - return VK_META; - case GDK_KP_Multiply: - return VK_MULTIPLY; - case GDK_Num_Lock: - return VK_NUM_LOCK; - case GDK_KP_0: - return VK_NUMPAD0; - case GDK_KP_1: - return VK_NUMPAD1; - case GDK_KP_2: - return VK_NUMPAD2; - case GDK_KP_3: - return VK_NUMPAD3; - case GDK_KP_4: - return VK_NUMPAD4; - case GDK_KP_5: - return VK_NUMPAD5; - case GDK_KP_6: - return VK_NUMPAD6; - case GDK_KP_7: - return VK_NUMPAD7; - case GDK_KP_8: - return VK_NUMPAD8; - case GDK_KP_9: - return VK_NUMPAD9; - case GDK_bracketleft: - return VK_OPEN_BRACKET; - case GDK_Page_Down: - return VK_PAGE_DOWN; - case GDK_Page_Up: - return VK_PAGE_UP; - case GDK_Pause: - return VK_PAUSE; - case GDK_period: - return VK_PERIOD; - case GDK_Print: - return VK_PRINTSCREEN; - case GDK_quoteright: - return VK_QUOTE; - case GDK_Right: - return VK_RIGHT; - case GDK_Scroll_Lock: - return VK_SCROLL_LOCK; - case GDK_semicolon: - return VK_SEMICOLON; - case GDK_KP_Separator: - return VK_SEPARATOR; - case GDK_Shift_L: - case GDK_Shift_R: - return VK_SHIFT; - case GDK_slash: - return VK_SLASH; - case GDK_space: - return VK_SPACE; - case GDK_KP_Subtract: - return VK_SUBTRACT; - case GDK_Tab: - return VK_TAB; - case GDK_Up: - return VK_UP; - - default: - return VK_UNDEFINED; - } -} - -void -awt_event_handler (GdkEvent *event) -{ - jobject *obj_ptr; - static guint32 button_click_time = 0; - static GdkWindow *button_window = NULL; - static guint button_number = -1; - static jint click_count = 1; - - /* keep synthetic AWT events from being processed recursively */ - if (event->type & SYNTHETIC_EVENT_MASK && event->type != GDK_NOTHING) - { - event->type ^= SYNTHETIC_EVENT_MASK; - gtk_main_do_event (event); - return; - } - - /* keep track of clickCount ourselves, since the AWT allows more - than a triple click to occur */ - if (event->type == GDK_BUTTON_PRESS) - { - if ((event->button.time < (button_click_time + MULTI_CLICK_TIME)) - && (event->button.window == button_window) - && (event->button.button == button_number)) - click_count++; - else - click_count = 1; - - button_click_time = event->button.time; - button_window = event->button.window; - button_number = event->button.button; - } - - /* for all input events, which have a window with a jobject attached, - send the input event off to Java before GTK has a chance to process - the event */ - if ((event->type == GDK_BUTTON_PRESS - || event->type == GDK_BUTTON_RELEASE - || event->type == GDK_ENTER_NOTIFY - || event->type == GDK_LEAVE_NOTIFY - || event->type == GDK_CONFIGURE - || event->type == GDK_EXPOSE - || event->type == GDK_KEY_PRESS - || event->type == GDK_FOCUS_CHANGE - || event->type == GDK_MOTION_NOTIFY) - && gdk_property_get (event->any.window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&obj_ptr)) - { - switch (event->type) - { - case GDK_BUTTON_PRESS: - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_PRESSED, - (jlong)event->button.time, - state_to_awt_mods (event->button.state) | - button_to_awt_mods (event->button.button), - (jint)event->button.x, - (jint)event->button.y, - click_count, - (event->button.button == 3) ? JNI_TRUE : - JNI_FALSE); - - /* grab_counter++; - gdk_pointer_grab (event->any.window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK, - NULL, - NULL, - event->button.time);*/ - break; - case GDK_BUTTON_RELEASE: - { - int width, height; - - /* only ungrab if no other buttons are pressed down */ - /* if (--grab_counter == 0) - gdk_pointer_ungrab (event->button.time); - */ - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_RELEASED, - (jlong)event->button.time, - state_to_awt_mods (event->button.state) | - button_to_awt_mods (event->button.button), - (jint)event->button.x, - (jint)event->button.y, - click_count, JNI_FALSE); - - /* check to see if the release occured in the window it was pressed - in, and if so, generate an AWT click event */ - gdk_window_get_size (event->any.window, &width, &height); - if (event->button.x >= 0 - && event->button.y >= 0 - && event->button.x <= width - && event->button.y <= height) - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_CLICKED, - (jlong)event->button.time, - state_to_awt_mods (event->button.state) | - button_to_awt_mods (event->button.button), - (jint)event->button.x, - (jint)event->button.y, - click_count, JNI_FALSE); - - } - break; - case GDK_MOTION_NOTIFY: - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_MOVED, - (jlong)event->motion.time, - state_to_awt_mods (event->motion.state), - (jint)event->motion.x, - (jint)event->motion.y, - 0, JNI_FALSE); - - if (event->motion.state & (GDK_BUTTON1_MASK - | GDK_BUTTON2_MASK - | GDK_BUTTON3_MASK - | GDK_BUTTON4_MASK - | GDK_BUTTON5_MASK)) - { - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_DRAGGED, - (jlong)event->motion.time, - state_to_awt_mods (event->motion.state), - (jint)event->motion.x, - (jint)event->motion.y, - 0, JNI_FALSE); - } - break; - case GDK_ENTER_NOTIFY: - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_ENTERED, - (jlong)event->crossing.time, - state_to_awt_mods (event->crossing.state), - (jint)event->crossing.x, - (jint)event->crossing.y, - 0, JNI_FALSE); - break; - case GDK_LEAVE_NOTIFY: - if (event->crossing.mode == GDK_CROSSING_NORMAL) - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, postMouseEventID, - AWT_MOUSE_EXITED, - (jlong)event->crossing.time, - state_to_awt_mods (event->crossing.state), - (jint)event->crossing.x, - (jint)event->crossing.y, - 0, JNI_FALSE); - break; - case GDK_CONFIGURE: - { - GtkWidget *widget; - - gdk_window_get_user_data (event->any.window, (void **) &widget); - - if (widget && GTK_WIDGET_TOPLEVEL (widget)) - { - gint top, left, right, bottom; - gint x, y, w, h, wb, d; - - /* calculate our insets */ - gdk_window_get_root_geometry (event->any.window, - &x, &y, &w, &h, &wb, &d); - - /* We used to compute these based on the configure - event's fields. However, that gives strange and - apparently incorrect results. */ - top = left = bottom = right = 0; - - /* configure events are not posted to the AWT event queue, - and as such, gdk/gtk will be called back before - postConfigureEvent returns */ - gdk_threads_leave (); - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, - postConfigureEventID, - (jint)event->configure.x, - (jint)event->configure.y, - (jint)event->configure.width, - (jint)event->configure.height, - (jint)top, - (jint)left, - (jint)bottom, - (jint)right); - gdk_threads_enter (); - } - } - break; - case GDK_EXPOSE: - { - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, - postExposeEventID, - (jint)event->expose.area.x, - (jint)event->expose.area.y, - (jint)event->expose.area.width, - (jint)event->expose.area.height); - } - break; - - case GDK_KEY_PRESS: - { - GtkWidget *widget; - GtkWindow *window; - - gdk_window_get_user_data (event->any.window, (void **) &widget); - - window = GTK_WINDOW (gtk_widget_get_ancestor (widget, - GTK_TYPE_WINDOW)); - if (window - && GTK_WIDGET_IS_SENSITIVE (window) - && window->focus_widget - && GTK_WIDGET_IS_SENSITIVE (window->focus_widget) - && window->focus_widget->window) - { - gtk_widget_activate (window->focus_widget); - gdk_property_get (window->focus_widget->window, - gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE), - gdk_atom_intern ("CARDINAL", FALSE), - 0, - sizeof (jobject), - FALSE, - NULL, - NULL, - NULL, - (guchar **)&obj_ptr); - - /* if (grab && GTK_WIDGET_HAS_DEFAULT (widget) ) */ - /* { */ - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, - postKeyEventID, - (jint) AWT_KEY_PRESSED, - (jlong) event->key.time, - state_to_awt_mods (event->key.state), - keysym_to_awt_keycode (event->key.keyval), - (jchar) (event->key.length) ? - event->key.string[0] : - AWT_KEY_CHAR_UNDEFINED); - if (event->key.length) - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, - postKeyEventID, - (jint) AWT_KEY_TYPED, - (jlong) event->key.time, - state_to_awt_mods (event->key.state), - VK_UNDEFINED, - (jchar) event->key.string[0]); - } - } - break; - case GDK_FOCUS_CHANGE: - (*gdk_env)->CallVoidMethod (gdk_env, *obj_ptr, - postFocusEventID, - (jint) (event->focus_change.in) ? - AWT_FOCUS_GAINED : AWT_FOCUS_LOST, - JNI_FALSE); - break; - default: - } - g_free (obj_ptr); - } - - gtk_main_do_event (event); -} - -static void -attach_jobject (GdkWindow *window, jobject *obj) -{ - GdkAtom addr_atom = gdk_atom_intern ("_GNU_GTKAWT_ADDR", FALSE); - GdkAtom type_atom = gdk_atom_intern ("CARDINAL", FALSE); - - gdk_window_set_events (window, - gdk_window_get_events (window) - | GDK_POINTER_MOTION_MASK - | GDK_BUTTON_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_KEY_PRESS_MASK - | GDK_KEY_RELEASE_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK - | GDK_STRUCTURE_MASK - | GDK_KEY_PRESS_MASK - | GDK_FOCUS_CHANGE_MASK); - - gdk_property_change (window, - addr_atom, - type_atom, - 8, - GDK_PROP_MODE_REPLACE, - (guchar *)obj, - sizeof (jobject)); -} - -void -connect_awt_hook (JNIEnv *env, jobject peer_obj, int nwindows, ...) -{ - int i; - va_list ap; - jobject *obj; - - obj = (jobject *) malloc (sizeof (jobject)); - *obj = (*env)->NewGlobalRef (env, peer_obj); - - va_start (ap, nwindows); - for (i = 0; i < nwindows; i++) - attach_jobject (va_arg (ap, GdkWindow *), obj); - va_end (ap); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c deleted file mode 100644 index 2308d1100ed..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c +++ /dev/null @@ -1,92 +0,0 @@ -/* gtkfiledialogpeer.c -- Native implementation of GtkFileDialogPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkFileDialogPeer.h" - -/* - * Make a new file selection dialog - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_create - (JNIEnv *env, jobject obj) -{ - gpointer widget; - - gdk_threads_enter (); - widget = gtk_type_new (gtk_file_selection_get_type ()); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - /* NOTE: we don't call the superclass connect method here. */ - gtk_widget_realize (GTK_WIDGET (ptr)); - connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); - - gdk_threads_leave (); -} - -/* - * Set the filename in the file selection dialog. - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_gtkFileSelectionSetFilename - (JNIEnv *env, jobject obj, jstring filename) -{ - void *ptr; - const char *str; - - ptr = NSA_GET_PTR (env, obj); - - str = (*env)->GetStringUTFChars (env, filename, 0); - gdk_threads_enter (); - gtk_file_selection_set_filename (GTK_FILE_SELECTION (ptr), str); - gdk_threads_leave (); - (*env)->ReleaseStringUTFChars (env, filename, str); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c deleted file mode 100644 index dd446c89489..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c +++ /dev/null @@ -1,160 +0,0 @@ -/* gtkimagepainter.c - 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. */ - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkImagePainter.h" -#include <libart_lgpl/art_misc.h> -#include <libart_lgpl/art_rgb_affine.h> - -#define SWAPU32(w) \ - (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24)) - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels -(JNIEnv *env, jobject obj, jobject gc_obj, jint bg_red, jint bg_green, - jint bg_blue, jint x, jint y, jint width, jint height, jintArray jpixels, - jint offset, jint scansize, jdoubleArray jaffine) -{ - struct graphics *g; - jint *pixels, *elems; - guchar *packed; - int i; - jsize num_pixels; - guchar *j_rgba, *c_rgb; - - g = (struct graphics *) NSA_GET_PTR (env, gc_obj); - - elems = (*env)->GetIntArrayElements (env, jpixels, NULL); - num_pixels = (*env)->GetArrayLength (env, jpixels); - - /* get a copy of the pixel data so we can modify it */ - pixels = malloc (sizeof (jint) * num_pixels); - memcpy (pixels, elems, sizeof (jint) * num_pixels); - - (*env)->ReleaseIntArrayElements (env, jpixels, elems, 0); - -#ifndef WORDS_BIGENDIAN - /* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */ - for (i = 0; i < num_pixels; i++) - pixels[i] = SWAPU32 ((unsigned)pixels[i]); -#endif - - packed = (guchar *) malloc (sizeof (guchar) * 3 * num_pixels); - j_rgba = (guchar *) pixels; - c_rgb = packed; - - /* copy over pixels in DirectColorModel format to 24 bit RGB image data, - and process the alpha channel */ - for (i = 0; i < num_pixels; i++) - { - jint ialpha = *j_rgba++; - - switch (ialpha) - { - case 0: /* full transparency */ - *c_rgb++ = bg_red; - *c_rgb++ = bg_green; - *c_rgb++ = bg_blue; - j_rgba += 3; - break; - case 255: /* opaque */ - *c_rgb++ = *j_rgba++; - *c_rgb++ = *j_rgba++; - *c_rgb++ = *j_rgba++; - break; - default: /* compositing required */ - { - jfloat alpha = ialpha / 255.0; - jfloat comp_alpha = 1.0 - alpha; - - *c_rgb++ = *j_rgba++ * alpha + bg_red * comp_alpha; - *c_rgb++ = *j_rgba++ * alpha + bg_green * comp_alpha; - *c_rgb++ = *j_rgba++ * alpha + bg_blue * comp_alpha; - } - break; - } - } - - if (jaffine) - { - jdouble *affine; - ArtAlphaGamma *alphagamma = NULL; - art_u8 *dst; - int new_width, new_height; - int i; - - affine = (*env)->GetDoubleArrayElements (env, jaffine, NULL); - - new_width = abs (width * affine[0]); - new_height = abs (height * affine[3]); - - dst = (art_u8 *) malloc (sizeof (art_u8) * 3 * (new_width * new_height)); - - art_rgb_affine (dst, - 0, 0, - new_width, new_height, - new_width * 3, - (art_u8 *) packed + offset * 3, - width, height, - scansize * 3, - affine, - ART_FILTER_NEAREST, - alphagamma); - - (*env)->ReleaseDoubleArrayElements (env, jaffine, affine, JNI_ABORT); - - free (packed); - packed = (guchar *) dst; - - width = scansize = new_width; - height = new_height; - offset = 0; - } - - gdk_threads_enter (); - - gdk_draw_rgb_image (g->drawable, - g->gc, - x + g->x_offset, - y + g->y_offset, - width, height, GDK_RGB_DITHER_NORMAL, - packed + offset * 3, scansize * 3); - - gdk_threads_leave (); - - free (pixels); - free (packed); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c deleted file mode 100644 index 9313a8a815b..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c +++ /dev/null @@ -1,57 +0,0 @@ -/* gtklabelpeer.c -- Native implementation of GtkLabelPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkLabelPeer.h" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create - (JNIEnv *env, jobject obj) -{ - GtkWidget *label; - GtkContainer *ebox; - - gdk_threads_enter (); - ebox = GTK_CONTAINER (gtk_type_new (gtk_event_box_get_type ())); - label = GTK_WIDGET (gtk_type_new (gtk_label_get_type ())); - gtk_container_add (ebox, label); - gtk_widget_show (label); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, ebox); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c deleted file mode 100644 index 5787ce5083e..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c +++ /dev/null @@ -1,381 +0,0 @@ -/* gtklistpeer.c -- Native implementation of GtkListPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkListPeer.h" - -static void -connect_selectable_hook (JNIEnv *env, jobject peer_obj, GtkCList *list); - -#define CLIST_FROM_SW(obj) (GTK_CLIST(GTK_SCROLLED_WINDOW (obj)->container.child)) - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_create - (JNIEnv *env, jobject obj) -{ - GtkWidget *list, *sw; - - gdk_threads_enter (); - list = gtk_clist_new (1); - gtk_widget_show (list); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (sw), list); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, sw); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_realize (GTK_WIDGET (ptr)); - connect_selectable_hook (env, obj, CLIST_FROM_SW (ptr)); - connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_append - (JNIEnv *env, jobject obj, jobjectArray items) -{ - void *ptr; - GtkCList *list; - jint count, i; - - ptr = NSA_GET_PTR (env, obj); - - count = (*env)->GetArrayLength (env, items); - - gdk_threads_enter (); - list = CLIST_FROM_SW (ptr); - for (i = 0; i < count; i++) - { - const char *text; - jobject item; - - item = (*env)->GetObjectArrayElement (env, items, i); - - text = (*env)->GetStringUTFChars (env, item, NULL); - gtk_clist_append (list, (char **)&text); - (*env)->ReleaseStringUTFChars (env, item, text); - } - - gtk_clist_columns_autosize (list); - gdk_threads_leave (); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_old_create - (JNIEnv *env, jobject obj, jobject parent_obj, - jobjectArray items, jboolean mode) -{ - GtkWidget *list, *sw, *parent; - jsize count, i; - - parent = NSA_GET_PTR (env, parent_obj); - - count = (*env)->GetArrayLength (env, items); - - gdk_threads_enter (); - - list = gtk_clist_new (1); - gtk_widget_show (list); - - sw = gtk_scrolled_window_new (NULL, NULL); - set_parent (sw, GTK_CONTAINER (parent)); - gtk_widget_realize (sw); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (sw), list); - - connect_selectable_hook (env, obj, GTK_CLIST (list)); - connect_awt_hook (env, obj, 1, list->window); - - gtk_clist_set_selection_mode (GTK_CLIST (list), - mode ? GTK_SELECTION_MULTIPLE : - GTK_SELECTION_SINGLE); - - for (i = 0; i < count; i++) - { - const char *text; - jobject item; - - item = (*env)->GetObjectArrayElement (env, items, i); - - text = (*env)->GetStringUTFChars (env, item, NULL); - gtk_clist_append (GTK_CLIST (list), (char **)&text); - (*env)->ReleaseStringUTFChars (env, item, text); - } - - gtk_clist_columns_autosize (GTK_CLIST (list)); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, sw); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_add - (JNIEnv *env, jobject obj, jstring text, jint index) -{ - void *ptr; - const char *str; - - ptr = NSA_GET_PTR (env, obj); - str = (*env)->GetStringUTFChars (env, text, NULL); - - gdk_threads_enter (); - gtk_clist_insert (CLIST_FROM_SW (ptr), index, (char **)&str); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, text, str); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_delItems - (JNIEnv *env, jobject obj, jint start, jint end) -{ - void *ptr; - GtkCList *list; - jint i; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - list = CLIST_FROM_SW (ptr); - - if (end == -1) /* special case for removing all rows */ - end = list->rows; - - gtk_clist_freeze (list); - for (i = start; i < end; i++) - gtk_clist_remove (list, i); - gtk_clist_thaw (list); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_select - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_clist_select_row (CLIST_FROM_SW (ptr), index, 0); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_deselect - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_clist_unselect_row (CLIST_FROM_SW (ptr), index, 0); - gdk_threads_leave (); -} - -/* FIXME: magic mojo (that doesn't seem to do anything) */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize - (JNIEnv *env, jobject obj, jint rows, jintArray jdims) -{ - void *ptr; - jint *dims; - GtkWidget *list; - GtkScrolledWindow *sw; - GtkRequisition myreq; - - dims = (*env)->GetIntArrayElements (env, jdims, NULL); - dims[0] = dims[1] = 0; - - if (rows < 3) - rows = 3; - - ptr = NSA_GET_PTR (env, obj); - gdk_threads_enter (); - - list = GTK_WIDGET (CLIST_FROM_SW (ptr)); - sw = GTK_SCROLLED_WINDOW (ptr); - - /* - gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->hscrollbar), - &myreq); - dims[1]=myreq.height+GTK_SCROLLED_WINDOW_CLASS - (GTK_OBJECT (sw)->klass)->scrollbar_spacing; - */ - - gtk_signal_emit_by_name (GTK_OBJECT (GTK_SCROLLED_WINDOW(sw)->vscrollbar), - "size_request", &myreq); - /* - - gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->vscrollbar), - &myreq); - */ - - dims[0]=myreq.width+GTK_SCROLLED_WINDOW_CLASS - (GTK_OBJECT (sw)->klass)->scrollbar_spacing; - - gtk_signal_emit_by_name (GTK_OBJECT (list), "size_request", &myreq); - - // gtk_widget_size_request(GTK_WIDGET (list), &myreq); - - dims[0] += myreq.width + gdk_char_width (list->style->font, 'W'); - - dims[1] += ((rows * (gdk_char_height (list->style->font, 'W')+7)) - + (2 * (list->style->klass->ythickness))); - - - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); -} - - -JNIEXPORT jintArray JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes - (JNIEnv *env, jobject obj) -{ - void *ptr; - GtkCList *list; - jintArray selection; - jint *sel; - GList *child; - jint count, i; - - ptr = NSA_GET_PTR (env, obj); - gdk_threads_enter (); - - list = CLIST_FROM_SW (ptr); - count = g_list_length (list->selection); - - selection = (*env)->NewIntArray (env, count); - sel = (*env)->GetIntArrayElements (env, selection, NULL); - - for (i = 0, child = list->selection; i < count; i++) - { - sel[i] = GPOINTER_TO_INT (child->data); - child = g_list_next (child); - } - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements (env, selection, sel, 0); - - return selection; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_makeVisible - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_clist_moveto (CLIST_FROM_SW (ptr), index, 0, 0.5, 0.5); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkListPeer_setMultipleMode - (JNIEnv *env, jobject obj, jboolean mode) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_clist_set_selection_mode (CLIST_FROM_SW (ptr), - mode ? GTK_SELECTION_MULTIPLE : - GTK_SELECTION_SINGLE); - gdk_threads_leave (); -} - -static void -item_select (GtkCList *list, int row, int col, GdkEventButton *event, - jobject *peer_obj) -{ - (*gdk_env)->CallVoidMethod (gdk_env, *peer_obj, - postListItemEventID, - row, - (jint) AWT_ITEM_SELECTED); -} - -static void -item_unselect (GtkCList *list, int row, int col, GdkEventButton *event, - jobject *peer_obj) -{ - (*gdk_env)->CallVoidMethod (gdk_env, *peer_obj, - postListItemEventID, - row, - (jint) AWT_ITEM_DESELECTED); -} - -static void -connect_selectable_hook (JNIEnv *env, jobject peer_obj, GtkCList *list) -{ - jobject *obj; - - obj = (jobject *) malloc (sizeof (jobject)); - *obj = (*env)->NewGlobalRef (env, peer_obj); - - gtk_signal_connect (GTK_OBJECT (list), "select_row", - GTK_SIGNAL_FUNC (item_select), obj); - - gtk_signal_connect (GTK_OBJECT (list), "unselect_row", - GTK_SIGNAL_FUNC (item_unselect), obj); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c deleted file mode 100644 index af14f0be8a9..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c +++ /dev/null @@ -1,163 +0,0 @@ -/* gtkmainthread.c -- Native implementation of GtkMainThread - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkMainThread.h" -#include "gthread-jni.h" - -#ifdef JVM_SUN - struct state_table *native_state_table; -#endif - -jmethodID postActionEventID; -jmethodID postMenuActionEventID; -jmethodID postMouseEventID; -jmethodID postConfigureEventID; -jmethodID postExposeEventID; -jmethodID postKeyEventID; -jmethodID postFocusEventID; -jmethodID postAdjustmentEventID; -jmethodID postItemEventID; -jmethodID postListItemEventID; -JNIEnv *gdk_env; - -/* - * Call gtk_init. It is very important that this happen before any other - * gtk calls. - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz) -{ - int argc = 1; - char **argv; - char *homedir, *rcpath = NULL; -/* jclass gtkgenericpeer; */ - jclass gtkcomponentpeer, gtkwindowpeer, gtkscrollbarpeer, gtklistpeer, gtkmenuitempeer; - - NSA_INIT (env, clazz); - - /* GTK requires a program's argc and argv variables, and requires that they - be valid. */ - - argv = (char **) malloc (sizeof (char *) * 2); - argv[0] = ""; - argv[1] = NULL; - - /* until we have JDK 1.2 JNI, assume we have a VM with threads that - match what GLIB was compiled for */ - g_thread_init (NULL); - - gtk_init (&argc, &argv); - - gdk_rgb_init (); - gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); - gtk_widget_set_default_visual (gdk_rgb_get_visual ()); - - /* Make sure queued calls don't get sent to GTK/GDK while - we're shutting down. */ - atexit (gdk_threads_enter); - - gdk_env = env; - gdk_event_handler_set ((GdkEventFunc)awt_event_handler, NULL, NULL); - - if ((homedir = getenv ("HOME"))) - { - rcpath = (char *) malloc (strlen (homedir) + strlen (RC_FILE) + 2); - sprintf (rcpath, "%s/%s", homedir, RC_FILE); - } - - gtk_rc_parse ((rcpath) ? rcpath : RC_FILE); - - if (rcpath) - free (rcpath); - - free (argv); - - /* setup cached IDs for posting GTK events to Java */ -/* gtkgenericpeer = (*env)->FindClass (env, */ -/* "gnu/java/awt/peer/gtk/GtkGenericPeer"); */ - gtkcomponentpeer = (*env)->FindClass (env, - "gnu/java/awt/peer/gtk/GtkComponentPeer"); - gtkwindowpeer = (*env)->FindClass (env, - "gnu/java/awt/peer/gtk/GtkWindowPeer"); - gtkscrollbarpeer = (*env)->FindClass (env, - "gnu/java/awt/peer/gtk/GtkScrollbarPeer"); - gtklistpeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkListPeer"); - gtkmenuitempeer = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GtkMenuItemPeer"); -/* gdkColor = (*env)->FindClass (env, */ -/* "gnu/java/awt/peer/gtk/GdkColor"); */ -/* gdkColorID = (*env)->GetMethodID (env, gdkColor, "<init>", "(III)V"); */ -/* postActionEventID = (*env)->GetMethodID (env, gtkgenericpeer, */ -/* "postActionEvent", */ -/* "(Ljava/lang/String;I)V"); */ - - postMenuActionEventID = (*env)->GetMethodID (env, gtkmenuitempeer, - "postMenuActionEvent", - "()V"); - postMouseEventID = (*env)->GetMethodID (env, gtkcomponentpeer, - "postMouseEvent", "(IJIIIIZ)V"); - postConfigureEventID = (*env)->GetMethodID (env, gtkwindowpeer, - "postConfigureEvent", "(IIIIIIII)V"); - postExposeEventID = (*env)->GetMethodID (env, gtkcomponentpeer, - "postExposeEvent", "(IIII)V"); - postKeyEventID = (*env)->GetMethodID (env, gtkcomponentpeer, - "postKeyEvent", "(IJIIC)V"); - postFocusEventID = (*env)->GetMethodID (env, gtkcomponentpeer, - "postFocusEvent", "(IZ)V"); - postAdjustmentEventID = (*env)->GetMethodID (env, gtkscrollbarpeer, - "postAdjustmentEvent", - "(II)V"); - postItemEventID = (*env)->GetMethodID (env, gtkcomponentpeer, - "postItemEvent", - "(Ljava/lang/Object;I)V"); - postListItemEventID = (*env)->GetMethodID (env, gtklistpeer, - "postItemEvent", - "(II)V"); -} - -/* - * Run gtk_main and block. - */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkMain (JNIEnv *env, jobject obj) -{ - gdk_threads_enter (); - gtk_main (); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c deleted file mode 100644 index 89818e05fb1..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c +++ /dev/null @@ -1,81 +0,0 @@ -/* gtkmenubarpeer.c -- Native implementation of GtkMenuBarPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkMenuBarPeer.h" - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_create - (JNIEnv *env, jobject obj) -{ - GtkWidget *widget; - - gdk_threads_enter (); - widget = gtk_menu_bar_new (); - gtk_widget_show (widget); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_addMenu - (JNIEnv *env, jobject obj, jobject menupeer) -{ - void *mbar, *menu; - - mbar = NSA_GET_PTR (env, obj); - menu = NSA_GET_PTR (env, menupeer); - - gdk_threads_enter (); - gtk_menu_bar_append (GTK_MENU_BAR (mbar), GTK_WIDGET (menu)); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_delMenu - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - GList *list; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - list = gtk_container_children (GTK_CONTAINER (ptr)); - list = g_list_nth (list, index); - gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data)); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c deleted file mode 100644 index ee3920867a8..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c +++ /dev/null @@ -1,120 +0,0 @@ -/* gtkmenuitempeer.c -- Native implementation of GtkMenuItemPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkMenuItemPeer.h" -#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" - -static void -connect_activate_hook (JNIEnv *, jobject, GtkMenuItem *); - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_create - (JNIEnv *env, jobject obj, jstring label) -{ - GtkWidget *widget; - const char *str; - - str = (*env)->GetStringUTFChars (env, label, NULL); - - gdk_threads_enter (); - - if (strcmp (str, "-") == 0) /* "-" signals that we need a separator */ - widget = gtk_menu_item_new (); - else - widget = gtk_menu_item_new_with_label (str); - - connect_activate_hook (env, obj, GTK_MENU_ITEM (widget)); - gtk_widget_show (widget); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, label, str); - - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel - (JNIEnv *env, jobject obj, jstring label) -{ - void *ptr; - const char *str; - - ptr = NSA_GET_PTR (env, obj); - - str = (*env)->GetStringUTFChars (env, label, NULL); - - gdk_threads_enter (); - - if (strcmp (str, "-") == 0) /* "-" signals that we need a separator */ - gtk_container_remove (GTK_CONTAINER (ptr), GTK_BIN (ptr)->child); - else - { - GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (GTK_BIN (ptr)->child); - - gtk_label_set_text (GTK_LABEL (accel_label), str); - gtk_accel_label_refetch (accel_label); - } - - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, label, str); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setEnabled - (JNIEnv *env, jobject obj, jboolean enabled) -{ -/* Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setEnabled (env, obj, enabled); */ -} - -static void -item_activate (GtkMenuItem *item, jobject *peer_obj) -{ - (*gdk_env)->CallVoidMethod (gdk_env, *peer_obj, - postMenuActionEventID); -} - -static void -connect_activate_hook (JNIEnv *env, jobject peer_obj, GtkMenuItem *item) -{ - jobject *obj; - - obj = (jobject *) malloc (sizeof (jobject)); - *obj = (*env)->NewGlobalRef (env, peer_obj); - - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (item_activate), obj); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c deleted file mode 100644 index ec8154276cd..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c +++ /dev/null @@ -1,152 +0,0 @@ -/* gtkmenupeer.c -- Native implementation of GtkMenuPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkMenuPeer.h" - -static void -accel_attach (GtkMenuItem *menu_item, gpointer *user_data) -{ - GtkAccelGroup *accel; - - accel = gtk_menu_get_accel_group (GTK_MENU (menu_item->submenu)); - gtk_accel_group_attach (accel, - GTK_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET(menu_item)))); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup - (JNIEnv *env, jobject obj, jobject parent) -{ - void *ptr1, *ptr2; - - ptr1 = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - if (!parent) - { - gtk_menu_set_accel_group (GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu), - gtk_accel_group_new ()); - - if (GTK_WIDGET_REALIZED (GTK_WIDGET (ptr1))) - accel_attach (GTK_MENU_ITEM (ptr1), NULL); - else - gtk_signal_connect (GTK_OBJECT (ptr1), - "realize", - GTK_SIGNAL_FUNC (accel_attach), - NULL); - } - else - { - GtkAccelGroup *parent_accel; - - ptr2 = NSA_GET_PTR (env, parent); - parent_accel = gtk_menu_get_accel_group (GTK_MENU (GTK_MENU_ITEM (ptr2)->submenu)); - - gtk_menu_set_accel_group (GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu), - parent_accel); - } - - gdk_threads_leave (); -} - - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_create - (JNIEnv *env, jobject obj, jstring label) -{ - GtkWidget *menu_title, *menu; - const char *str; - - str = (*env)->GetStringUTFChars (env, label, NULL); - - gdk_threads_enter (); - menu = gtk_menu_new (); - - menu_title = gtk_menu_item_new_with_label (str); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_title), menu); - - gtk_widget_show (menu); - gtk_widget_show (menu_title); - - NSA_SET_PTR (env, obj, menu_title); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, label, str); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addItem - (JNIEnv *env, jobject obj, jobject menuitempeer, jint key, jboolean shift) -{ - void *ptr1, *ptr2; - GtkMenu *menu; - - ptr1 = NSA_GET_PTR (env, obj); - ptr2 = NSA_GET_PTR (env, menuitempeer); - - gdk_threads_enter (); - - menu = GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu); - gtk_menu_append (menu, GTK_WIDGET (ptr2)); - - if (key) - { - gtk_widget_add_accelerator (GTK_WIDGET (ptr2), "activate", - gtk_menu_get_accel_group (menu), key, - (GDK_CONTROL_MASK - | ((shift) ? GDK_SHIFT_MASK : 0)), - GTK_ACCEL_VISIBLE); - } - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_delItem - (JNIEnv *env, jobject obj, jint index) -{ - void *ptr; - GList *list; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - list = gtk_container_children (GTK_CONTAINER (ptr)); - list = g_list_nth (list, index); - gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data)); - gdk_threads_leave (); -} - - diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c deleted file mode 100644 index b52c75d5311..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c +++ /dev/null @@ -1,137 +0,0 @@ -/* gtkpanelpeer.c -- Native implementation of GtkPanelPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkPanelPeer.h" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkPanelPeer_create - (JNIEnv *env, jobject obj) -{ - gpointer widget; - - gdk_threads_enter (); - widget = gtk_layout_new (NULL, NULL); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, widget); -} - -typedef struct _GtkLayoutChild GtkLayoutChild; - -struct _GtkLayoutChild { - GtkWidget *widget; - gint x; - gint y; -}; - -static -void sr (GtkWidget *widget, GtkRequisition *requisition, gpointer user_data) -{ - GtkLayout *layout; - GtkLayoutChild *child; - GList *children; - - layout = GTK_LAYOUT (widget); - requisition->width = GTK_WIDGET (widget)->allocation.width; - requisition->height = GTK_WIDGET (widget)->allocation.height; - - children = layout->children; - while (children) - { - child = children->data; - children = children->next; - - if (GTK_WIDGET_VISIBLE (child->widget)) - { - requisition->height = MAX (requisition->height, - child->y + - child->widget->allocation.height); - requisition->width = MAX (requisition->width, - child->x + - child->widget->allocation.width); - } - } - - requisition->height += GTK_CONTAINER (layout)->border_width * 2; - requisition->width += GTK_CONTAINER (layout)->border_width * 2; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_realize (GTK_WIDGET (ptr)); - connect_awt_hook (env, obj, 1, GTK_LAYOUT (ptr)->bin_window); - -/* gtk_signal_connect (GTK_OBJECT (ptr), "size_request", GTK_SIGNAL_FUNC (sr), */ -/* NULL); */ - gdk_threads_leave (); -} - -/* - * Make a new panel. - */ -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkPanelPeer_gtkPanelNew - (JNIEnv *env, jobject obj, jobject parent_obj) -{ - GtkWidget *layout; - void *parent; - - parent = NSA_GET_PTR (env, parent_obj); - - gdk_threads_enter (); - layout = gtk_layout_new (NULL, NULL); - - set_parent (layout, GTK_CONTAINER (parent)); - - gtk_widget_realize (layout); - connect_awt_hook (env, obj, 1, GTK_LAYOUT (layout)->bin_window); - set_visible (layout, 1); - - NSA_SET_PTR (env, obj, layout); - gdk_threads_leave (); -} - - diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c deleted file mode 100644 index 66affcff255..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c +++ /dev/null @@ -1,93 +0,0 @@ -/* gtkpopupmenupeer.c -- Native implementation of GtkPopupMenuPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkPopupMenuPeer.h" - -struct pos -{ - gint x; - gint y; -}; - -void -menu_pos (GtkMenu *menu, gint *x, gint *y, gpointer user_data) -{ - struct pos *p = (struct pos *) user_data; - - *x = p->x; - *y = p->y; -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_show - (JNIEnv *env, jobject obj, jint x, jint y, jlong time) -{ - void *ptr; - struct pos *p; - - ptr = NSA_GET_PTR (env, obj); - - p = g_malloc (sizeof (struct pos)); - p->x = x; - p->y = y; - - gdk_threads_enter (); - gtk_menu_popup (GTK_MENU (GTK_MENU_ITEM (ptr)->submenu), - NULL, NULL, menu_pos, p, 3, time); - gdk_threads_leave (); - - g_free (p); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkPopupMenuPeer_setupAccelGroup - (JNIEnv *env, jobject obj, jobject parent) -{ - void *ptr1, *ptr2; - GtkMenu *menu; - - ptr1 = NSA_GET_PTR (env, obj); - ptr2 = NSA_GET_PTR (env, parent); - - gdk_threads_enter (); - menu = GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu); - gtk_menu_set_accel_group (menu, gtk_accel_group_new ()); - gtk_accel_group_attach (gtk_menu_get_accel_group (menu), - GTK_OBJECT (gtk_widget_get_toplevel (ptr2))); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c deleted file mode 100644 index 9237a01b5a8..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c +++ /dev/null @@ -1,184 +0,0 @@ -/* gtkscrollbarpeer.c -- Native implementation of GtkScrollbarPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkScrollbarPeer.h" - -struct range_scrollbar -{ - GtkRange *range; - jobject *scrollbar; -}; - -static void -post_adjustment_event (GtkAdjustment *adj, struct range_scrollbar *rs) -{ - jint type; - - switch (rs->range->scroll_type) - { - case GTK_SCROLL_STEP_FORWARD: - type = AWT_ADJUSTMENT_UNIT_INCREMENT; - break; - case GTK_SCROLL_STEP_BACKWARD: - type = AWT_ADJUSTMENT_UNIT_DECREMENT; - break; - case GTK_SCROLL_PAGE_FORWARD: - type = AWT_ADJUSTMENT_BLOCK_INCREMENT; - break; - case GTK_SCROLL_PAGE_BACKWARD: - type = AWT_ADJUSTMENT_BLOCK_DECREMENT; - break; - case GTK_SCROLL_JUMP: - case GTK_SCROLL_NONE: /* Apparently generated when slider is dragged. */ - type = AWT_ADJUSTMENT_TRACK; - break; - default: /* Can this happen? If so, is this right? */ - return; - } - - (*gdk_env)->CallVoidMethod (gdk_env, *(rs->scrollbar), postAdjustmentEventID, - type, (jint) adj->value); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create -(JNIEnv *env, jobject obj, jint orientation, jint value, - jint min, jint max, jint step_incr, jint page_incr, jint visible_amount) -{ - GtkWidget *sb; - GtkObject *adj; - - gdk_threads_enter (); - adj = gtk_adjustment_new (value, min, max, - step_incr, page_incr, - visible_amount); - - sb = (orientation) ? gtk_vscrollbar_new (GTK_ADJUSTMENT (adj)) : - gtk_hscrollbar_new (GTK_ADJUSTMENT (adj)); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, sb); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr; - struct range_scrollbar *rs; - - rs = (struct range_scrollbar *) malloc (sizeof (struct range_scrollbar)); - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_realize (GTK_WIDGET (ptr)); - - rs->range = GTK_RANGE (ptr); - rs->scrollbar = (jobject *) malloc (sizeof (jobject)); - *(rs->scrollbar) = (*env)->NewGlobalRef (env, obj); - gtk_signal_connect (GTK_OBJECT (GTK_RANGE (ptr)->adjustment), - "value_changed", - GTK_SIGNAL_FUNC (post_adjustment_event), rs); - - connect_awt_hook (env, obj, 4, - GTK_RANGE (ptr)->trough, - GTK_RANGE (ptr)->slider, - GTK_RANGE (ptr)->step_forw, - GTK_RANGE (ptr)->step_back); - gdk_threads_leave (); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setLineIncrement - (JNIEnv *env, jobject obj, jint amount) -{ - void *ptr; - GtkAdjustment *adj; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - adj = GTK_RANGE (ptr)->adjustment; - adj->step_increment = amount; - gtk_adjustment_changed (adj); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setPageIncrement - (JNIEnv *env, jobject obj, jint amount) -{ - void *ptr; - GtkAdjustment *adj; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - adj = GTK_RANGE (ptr)->adjustment; - adj->page_increment = amount; - gtk_adjustment_changed (adj); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues - (JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max) -{ - void *ptr; - GtkAdjustment *adj; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - adj = GTK_RANGE (ptr)->adjustment; - adj->value = value; - adj->page_size = visible; - adj->lower = min; - adj->upper = max; - gtk_adjustment_changed (adj); - - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c deleted file mode 100644 index 499b3124d88..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c +++ /dev/null @@ -1,190 +0,0 @@ -/* gtkscrollpanepeer.c -- Native implementation of GtkScrollPanePeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkScrollPanePeer.h" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_create - (JNIEnv *env, jobject obj) -{ - gpointer window; - GtkWidget *layout; - - gdk_threads_enter (); - window = gtk_scrolled_window_new (NULL, NULL); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, window); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setScrollPosition - (JNIEnv *env, jobject obj, jint x, jint y) -{ - GtkAdjustment *hadj, *vadj; - GtkScrolledWindow *sw; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - sw = GTK_SCROLLED_WINDOW (ptr); - - hadj = gtk_scrolled_window_get_hadjustment (sw); - vadj = gtk_scrolled_window_get_vadjustment (sw); - - gtk_adjustment_set_value (hadj, x); - gtk_adjustment_set_value (vadj, y); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetHScrollIncrement - (JNIEnv *env, jobject obj, jint u) -{ - GtkAdjustment *hadj; - GtkScrolledWindow *sw; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - sw = GTK_SCROLLED_WINDOW(ptr); - - hadj = gtk_scrolled_window_get_hadjustment (sw); - hadj->step_increment = u; - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetVScrollIncrement - (JNIEnv *env, jobject obj, jint u) -{ - GtkAdjustment *vadj; - GtkScrolledWindow *sw; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - sw = GTK_SCROLLED_WINDOW(ptr); - - vadj = gtk_scrolled_window_get_hadjustment (sw); - vadj->step_increment = u; - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_childResized - (JNIEnv *env, jobject obj, jint width, jint height) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - return; - - gdk_threads_enter (); - gtk_widget_set_usize (GTK_BIN (ptr)->child, width, height); - gdk_threads_leave (); -} - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getHScrollbarHeight - (JNIEnv *env, jobject obj) -{ - void *ptr; - GtkScrolledWindow *sw; - jint height; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - sw = GTK_SCROLLED_WINDOW (ptr); - height = (sw->hscrollbar_visible) ? sw->hscrollbar->allocation.height : 0; - gdk_threads_leave (); - - return height; -} - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getVScrollbarWidth - (JNIEnv *env, jobject obj) -{ - void *ptr; - GtkScrolledWindow *sw; - jint width; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - sw = GTK_SCROLLED_WINDOW (ptr); - width = (sw->vscrollbar_visible) ? sw->vscrollbar->allocation.width : 0; - gdk_threads_leave (); - - return width; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setPolicy - (JNIEnv *env, jobject obj, jint policy) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - switch (policy) - { - case AWT_SCROLLPANE_SCROLLBARS_AS_NEEDED: - policy = GTK_POLICY_AUTOMATIC; - break; - case AWT_SCROLLPANE_SCROLLBARS_ALWAYS: - policy = GTK_POLICY_ALWAYS; - break; - case AWT_SCROLLPANE_SCROLLBARS_NEVER: - policy = GTK_POLICY_NEVER; - break; - } - - gdk_threads_enter (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ptr), policy, policy); - gdk_threads_leave (); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c deleted file mode 100644 index 27f27461518..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c +++ /dev/null @@ -1,246 +0,0 @@ -/* gtktextareapeer.c -- Native implementation of GtkTextAreaPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkTextAreaPeer.h" - -#define TEXT_FROM_SW(obj) (GTK_TEXT(GTK_SCROLLED_WINDOW (obj)->container.child)) -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create - (JNIEnv *env, jobject obj, jint scroll) -{ - GtkWidget *text, *sw; - - gdk_threads_enter (); - text = gtk_text_new (NULL, NULL); - gtk_widget_show (text); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (sw), text); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - - /* horizontal scrollbar */ - (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH - || scroll == AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY) ? - GTK_POLICY_ALWAYS : GTK_POLICY_NEVER, - - /* vertical scrollbar */ - (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH - || scroll == AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY) ? - GTK_POLICY_ALWAYS : GTK_POLICY_NEVER); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, sw); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_old_create - (JNIEnv *env, jobject obj, jobject parent_obj, - jstring contents, jint scroll) -{ - GtkWidget *text, *sw; - const char *str; - int pos=0; - void *parent; - - parent = NSA_GET_PTR (env, parent_obj); - str = (*env)->GetStringUTFChars (env, contents, NULL); - - gdk_threads_enter (); - - text = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (text), TRUE); - - gtk_editable_insert_text (GTK_EDITABLE (text), str, - strlen (str), &pos); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (sw), text); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - - /* horizontal scrollbar */ - (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH - || scroll == AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY) ? - GTK_POLICY_ALWAYS : GTK_POLICY_NEVER, - - /* vertical scrollbar */ - (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH - || scroll == AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY) ? - GTK_POLICY_ALWAYS : GTK_POLICY_NEVER); - - set_visible (text, TRUE); - set_parent (sw, GTK_CONTAINER (parent)); - - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, contents, str); - - NSA_SET_PTR (env, obj, sw); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkTextGetSize - (JNIEnv *env, jobject obj, jint rows, jint cols, jintArray jdims) -{ - void *ptr; - jint *dims; - GtkWidget *text; - GtkScrolledWindow *sw; - GtkRequisition myreq; - - ptr = NSA_GET_PTR (env, obj); - - dims = (*env)->GetIntArrayElements (env, jdims, 0); - dims[0] = dims[1] = 0; - - gdk_threads_enter (); - - text = GTK_WIDGET (TEXT_FROM_SW (ptr)); - sw = GTK_SCROLLED_WINDOW (ptr); - - gtk_signal_emit_by_name (GTK_OBJECT (GTK_SCROLLED_WINDOW(sw)->vscrollbar), - "size_request", &myreq); - //gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->hscrollbar), - // &myreq); - dims[0]=myreq.width+GTK_SCROLLED_WINDOW_CLASS - (GTK_OBJECT (sw)->klass)->scrollbar_spacing; - - gtk_signal_emit_by_name (GTK_OBJECT (GTK_SCROLLED_WINDOW(sw)->hscrollbar), - "size_request", &myreq); - //gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->vscrollbar), - // &myreq); - dims[1]=myreq.height+GTK_SCROLLED_WINDOW_CLASS - (GTK_OBJECT (sw)->klass)->scrollbar_spacing; - - /* The '1' in the following assignments is from - #define TEXT_BORDER_ROOM 1 - in gtktext.c */ - - /* Gtk text seems to wrap slightly prematurely. Compensate. */ - ++cols; - ++dims[0]; - - dims[0] += ((cols * gdk_char_width (text->style->font, 'W')) - + (2 * (text->style->klass->xthickness + 1))); - /* Guess at the height. Is there a better way? */ - dims[1] += ((rows * gdk_string_height (text->style->font, "Wg")) - + (2 * (text->style->klass->ythickness + 1))); - - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_insert - (JNIEnv *env, jobject obj, jstring contents, jint position) -{ - void *ptr; - const char *str; - int pos=position; - - ptr = NSA_GET_PTR (env, obj); - str = (*env)->GetStringUTFChars (env, contents, NULL); - - gdk_threads_enter (); - gtk_editable_insert_text (GTK_EDITABLE (TEXT_FROM_SW (ptr)), - str, strlen (str), &pos); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, contents, str); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_replaceRange - (JNIEnv *env, jobject obj, jstring contents, jint start, jint end) -{ - void *ptr; - GtkEditable *text; - const char *str; - int pos = start; - - ptr = NSA_GET_PTR (env, obj); - str = (*env)->GetStringUTFChars (env, contents, NULL); - - gdk_threads_enter (); - - text = GTK_EDITABLE (TEXT_FROM_SW (ptr)); - gtk_text_freeze (GTK_TEXT (text)); - gtk_editable_delete_text (text, start, end); - gtk_editable_insert_text (text, str, strlen (str), &pos); - gtk_text_thaw (GTK_TEXT (text)); - - gdk_threads_leave (); - (*env)->ReleaseStringUTFChars (env, contents, str); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkSetFont - (JNIEnv *env, jobject obj, jstring jname, jint size) -{ - const char *xlfd; -# define FBUFSZ 200 - char buf[FBUFSZ]; - void *ptr; - GdkFont * new_font; - GtkStyle * style; - GtkWidget * text; - - ptr = NSA_GET_PTR (env, obj); - text = GTK_WIDGET (TEXT_FROM_SW (ptr)); - - xlfd = (*env)->GetStringUTFChars (env, jname, NULL); - snprintf(buf, FBUFSZ, xlfd, size); - (*env)->ReleaseStringUTFChars (env, jname, xlfd); - gdk_threads_enter(); - new_font = gdk_font_load (buf); /* FIXME: deprecated. Replacement? */ - if (new_font == NULL) - { - /* Fail quietly for now. */ - gdk_threads_leave(); - return; - } - style = gtk_style_copy (gtk_widget_get_style (text)); - style -> font = new_font; - gtk_widget_set_style (text , style); - /* FIXME: Documentation varies as to whether we should unref style. */ - gdk_threads_leave(); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c deleted file mode 100644 index 0b6db8f1840..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c +++ /dev/null @@ -1,180 +0,0 @@ -/* gtktextcomponentpeer.c -- Native implementation of GtkTextComponentPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkTextComponentPeer.h" - -#define GET_EDITABLE(obj) (GTK_IS_EDITABLE (obj) ? GTK_EDITABLE (obj) : \ - GTK_EDITABLE (GTK_SCROLLED_WINDOW (obj)->container.child)) - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getCaretPosition - (JNIEnv *env, jobject obj) -{ - void *ptr; - int pos; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - pos = gtk_editable_get_position (GET_EDITABLE (ptr)); - gdk_threads_leave (); - - return pos; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setCaretPosition - (JNIEnv *env, jobject obj, jint pos) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_editable_set_position (GET_EDITABLE (ptr), pos); - gdk_threads_leave (); -} - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionStart - (JNIEnv *env, jobject obj) -{ - void *ptr; - int pos; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - pos = GET_EDITABLE (ptr)->selection_start_pos; - gdk_threads_leave (); - - return pos; -} - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionEnd - (JNIEnv *env, jobject obj) -{ - void *ptr; - int pos; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - pos = GET_EDITABLE (ptr)->selection_end_pos; - gdk_threads_leave (); - - return pos; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_select - (JNIEnv *env, jobject obj, jint start, jint end) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_editable_select_region (GET_EDITABLE (ptr), start, end); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setEditable - (JNIEnv *env, jobject obj, jboolean state) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_editable_set_editable (GET_EDITABLE (ptr), state); - gdk_threads_leave (); -} - -JNIEXPORT jstring JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getText - (JNIEnv *env, jobject obj) -{ - void *ptr; - char *contents; - jstring jcontents; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - contents = gtk_editable_get_chars (GET_EDITABLE (ptr), 0, -1); - gdk_threads_leave (); - - jcontents = (*env)->NewStringUTF (env, contents); - g_free (contents); - - return jcontents; -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setText - (JNIEnv *env, jobject obj, jstring contents) -{ - void *ptr; - GtkEditable *text; - const char *str; - int pos = 0; - - ptr = NSA_GET_PTR (env, obj); - str = (*env)->GetStringUTFChars (env, contents, NULL); - - gdk_threads_enter (); - - text = GET_EDITABLE (ptr); - - if (GTK_IS_TEXT (text)) - gtk_text_freeze (GTK_TEXT (text)); - - gtk_editable_delete_text (text, 0, -1); - gtk_editable_insert_text (text, str, strlen (str), &pos); - - if (GTK_IS_TEXT (text)) - gtk_text_thaw (GTK_TEXT (text)); - - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, contents, str); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c deleted file mode 100644 index 658c8639bb7..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c +++ /dev/null @@ -1,183 +0,0 @@ -/* gtktextfieldpeer.c -- Native implementation of GtkTextFieldPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkTextFieldPeer.h" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_create - (JNIEnv *env, jobject obj) -{ - gpointer widget; - - gdk_threads_enter (); - widget = gtk_type_new (gtk_entry_get_type ()); - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, widget); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_widget_realize (GTK_WIDGET (ptr)); - connect_awt_hook (env, obj, 2, - GTK_WIDGET (ptr)->window, - GTK_ENTRY (ptr)->text_area); - gdk_threads_leave (); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_old_create - (JNIEnv *env, jobject obj, jobject parent_obj, jstring text) -{ - GtkWidget *entry; - const char *str; - void *parent; - - parent = NSA_GET_PTR (env, parent_obj); - - str = (*env)->GetStringUTFChars (env, text, NULL); - gdk_threads_enter (); - - entry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (entry), str); - - set_parent (entry, GTK_CONTAINER (parent)); - - gtk_widget_realize (entry); - connect_awt_hook (env, obj, 2, - entry->window, GTK_ENTRY (entry)->text_area); - - NSA_SET_PTR (env, obj, entry); - - gdk_threads_leave (); - (*env)->ReleaseStringUTFChars (env, text, str); -} - - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkEntryGetSize - (JNIEnv *env, jobject obj, jint cols, jintArray jdims) -{ - void *ptr; - jint *dims; - GtkRequisition myreq; - GtkEntry *entry; - - ptr = NSA_GET_PTR (env, obj); - dims = (*env)->GetIntArrayElements (env, jdims, 0); - - gdk_threads_enter (); - entry = GTK_ENTRY (ptr); - - gtk_signal_emit_by_name (GTK_OBJECT (entry), "size_request", &myreq); - - dims[0]=myreq.width-150 + (cols * - gdk_char_width (GTK_WIDGET (entry)->style->font, - 'W')); - dims[1]=myreq.height; - - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setEchoChar - (JNIEnv *env, jobject obj, jchar c) -{ - void *ptr; - GtkEntry *entry; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - entry = GTK_ENTRY (ptr); - - if (c!=0) - { -/* gtk_entry_set_echo_char (entry, c); */ - gtk_entry_set_visibility (entry, FALSE); - } - else - gtk_entry_set_visibility (entry, TRUE); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkSetFont - (JNIEnv *env, jobject obj, jstring jname, jint size) -{ - const char *xlfd; -# define FBUFSZ 200 - char buf[FBUFSZ]; - void *ptr; - GdkFont * new_font; - GtkStyle * style; - GtkWidget * text; - - ptr = NSA_GET_PTR (env, obj); - text = GTK_WIDGET (ptr); - - xlfd = (*env)->GetStringUTFChars (env, jname, NULL); - snprintf(buf, FBUFSZ, xlfd, size); - (*env)->ReleaseStringUTFChars (env, jname, xlfd); - gdk_threads_enter(); - new_font = gdk_font_load(buf); /* FIXME: deprecated. Replacement? */ - if (new_font == NULL) - { - /* Fail quietly for now. */ - gdk_threads_leave(); - return; - } - style = gtk_style_copy (gtk_widget_get_style (text)); - style -> font = new_font; - gtk_widget_set_style (text , style); - /* FIXME: Documentation varies as to whether we should unref style. */ - gdk_threads_leave(); -} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c deleted file mode 100644 index 1436badea5a..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c +++ /dev/null @@ -1,87 +0,0 @@ -/* gtktoolkit.c -- Native portion of GtkToolkit - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkToolkit.h" - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_beep (JNIEnv *env, jobject obj) -{ - gdk_threads_enter (); - gdk_beep (); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_sync (JNIEnv *env, jobject obj) -{ - gdk_threads_enter (); - gdk_flush (); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_getScreenSizeDimensions -(JNIEnv *env, jobject obj, jintArray jdims) -{ - jint *dims = (*env)->GetIntArrayElements (env, jdims, 0); - - gdk_threads_enter (); - - dims[0] = gdk_screen_width (); - dims[1] = gdk_screen_height (); - - gdk_threads_leave (); - - (*env)->ReleaseIntArrayElements(env, jdims, dims, 0); -} - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkToolkit_getScreenResolution (JNIEnv *env, - jobject obj) -{ - jint res; - - gdk_threads_enter (); - - res = gdk_screen_width () / (gdk_screen_width_mm () / 25.4); - - gdk_threads_leave (); - return res; -} - diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c deleted file mode 100644 index 3b7c06bf057..00000000000 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +++ /dev/null @@ -1,365 +0,0 @@ -/* gtkwindowpeer.c -- Native implementation of GtkWindowPeer - 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. */ - - -#include "gtkpeer.h" -#include "gnu_java_awt_peer_gtk_GtkWindowPeer.h" -#include "gnu_java_awt_peer_gtk_GtkFramePeer.h" -#include <gdk/gdkprivate.h> -#include <gdk/gdkx.h> - -static void setBounds (GtkWidget *, jint, jint, jint, jint); - -/* - * Make a new window (any type) - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create - (JNIEnv *env, jobject obj, jint type) -{ - gpointer window; - GtkWidget *vbox, *layout; - - gdk_threads_enter (); - window = gtk_window_new (type); - - vbox = gtk_vbox_new (0, 0); - layout = gtk_layout_new (NULL, NULL); - gtk_box_pack_end (GTK_BOX (vbox), layout, 1, 1, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - - gtk_widget_show (layout); - gtk_widget_show (vbox); - - gdk_threads_leave (); - - NSA_SET_PTR (env, obj, window); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setVisible - (JNIEnv *env, jobject obj, jboolean visible) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - if (visible) - gtk_widget_show (GTK_WIDGET (ptr)); - else - gtk_widget_hide (GTK_WIDGET (ptr)); - - XFlush (GDK_DISPLAY ()); - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectHooks - (JNIEnv *env, jobject obj) -{ - void *ptr; - GtkWidget *layout; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - layout = GTK_WIDGET (gtk_container_children (GTK_CONTAINER (GTK_BIN (ptr)->child))->data); - gtk_widget_realize (layout); - connect_awt_hook (env, obj, 1, GTK_LAYOUT (layout)->bin_window); - - gtk_widget_realize (GTK_WIDGET (ptr)); - connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); - gdk_threads_leave (); -} - -void -setup_window (JNIEnv *env, jobject obj, GtkWidget *window, jint width, - jint height, jboolean visible) -{ - GtkWidget *layout, *vbox; - gint x, y; - - gtk_window_set_policy (GTK_WINDOW (window), 1, 1, 0); - gtk_widget_set_usize (window, width, height); - - vbox = gtk_vbox_new (0, 0); - layout = gtk_layout_new (NULL, NULL); - gtk_box_pack_end (GTK_BOX (vbox), layout, 1, 1, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_realize (layout); - connect_awt_hook (env, obj, 1, GTK_LAYOUT(layout)->bin_window); - gtk_widget_show (layout); - gtk_widget_show (vbox); - - gtk_widget_realize (window); -/* setBounds (window, x, y, width, height); */ - - connect_awt_hook (env, obj, 1, window->window); - set_visible (window, visible); -} - -/* - * Set a frame's title - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setTitle - (JNIEnv *env, jobject obj, jstring title) -{ - void *ptr; - const char *str; - - ptr = NSA_GET_PTR (env, obj); - - str = (*env)->GetStringUTFChars (env, title, NULL); - - gdk_threads_enter (); - gtk_window_set_title (GTK_WINDOW (ptr), str); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, title, str); -} - -/* - * Set a window's resizing policy - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setResizable - (JNIEnv *env, jobject obj, jboolean resize) -{ - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gtk_window_set_policy (GTK_WINDOW (ptr), resize, resize, 0); - gdk_threads_leave (); -} - - -/* - * Lower the z-level of a window. - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toBack (JNIEnv *env, - jobject obj) -{ - void *ptr; - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_window_lower (GTK_WIDGET (ptr)->window); - - XFlush (GDK_DISPLAY ()); - gdk_threads_leave (); -} - -/* - * Raise the z-level of a window. - */ - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toFront (JNIEnv *env, - jobject obj) -{ - void *ptr; - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - gdk_window_raise (GTK_WIDGET (ptr)->window); - - XFlush (GDK_DISPLAY ()); - gdk_threads_leave (); -} - -static void -setBounds (GtkWidget *widget, jint x, jint y, jint width, jint height) -{ - gint current_x, current_y; - gint origin_x, origin_y; - -/* gdk_window_get_root_origin (widget->window, ¤t_x, ¤t_y); */ - -/* if (current_x != x || current_y != y) */ -/* { */ -/* gdk_window_set_hints (widget->window, x, y, 0, 0, 0, 0, GDK_HINT_POS); */ -/* gdk_window_move (widget->window, x, y); */ -/* } */ - - gtk_widget_set_usize (widget, width, height); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setBounds - (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height) -{ - void *ptr; - GtkWidget *widget; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - - widget = GTK_WIDGET (ptr); - setBounds (widget, x, y, width, height); - - gdk_threads_leave (); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer - (JNIEnv *env, jobject obj, jobject menubar) -{ - void *wptr, *mptr; - GtkBox *box; - - if (!menubar) return; - - wptr = NSA_GET_PTR (env, obj); - mptr = NSA_GET_PTR (env, menubar); - - if (!mptr) return; /* this case should remove a menu */ - - gdk_threads_enter (); - box = GTK_BOX (GTK_BIN (wptr)->child); - gtk_box_pack_start (box, GTK_WIDGET (mptr), 0, 0, 0); - gdk_threads_leave (); -} - -JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight - (JNIEnv *env, jobject obj) -{ - void *ptr; - GList *children; - jint height = 0; - - ptr = NSA_GET_PTR (env, obj); - - gdk_threads_enter (); - children = gtk_container_children (GTK_CONTAINER (GTK_BIN (ptr)->child)); - if (g_list_length (children) == 2) - { - GtkWidget *menubar = GTK_WIDGET (children->data); - height = menubar->allocation.height; - - } - gdk_threads_leave (); - - return height; -} - - -void -gdk_window_get_root_geometry (GdkWindow *window, - gint *x, - gint *y, - gint *width, - gint *height, - gint *border, - gint *depth) -{ - GdkWindowPrivate *private; - Window xwindow; - Window xparent; - Window root; - Window *children; - unsigned int nchildren; - - g_return_if_fail (window != NULL); - - private = (GdkWindowPrivate*) window; - if (x) - *x = 0; - if (y) - *y = 0; - if (width) - *width = 0; - if (height) - *height = 0; - if (border) - *border = 0; - if (depth) - *depth = 0; - - if (private->destroyed) - return; - - while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) - private = (GdkWindowPrivate*) private->parent; - if (private->destroyed) - return; - - xparent = private->xwindow; - do - { - xwindow = xparent; - if (!XQueryTree (private->xdisplay, xwindow, - &root, &xparent, - &children, &nchildren)) - return; - - if (children) - XFree (children); - } - while (xparent != root); - - if (xparent == root) - { - unsigned int ww, wh, wb, wd; - int wx, wy; - - if (XGetGeometry (private->xdisplay, xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) - { - if (x) - *x = wx; - if (y) - *y = wy; - if (width) - *width = ww; - if (height) - *height = wh; - if (border) - *border = wb; - if (depth) - *depth = wd; - } - } -} - diff --git a/libjava/jni/gtk-peer/gthread-jni.c b/libjava/jni/gtk-peer/gthread-jni.c deleted file mode 100644 index 9409720f9ac..00000000000 --- a/libjava/jni/gtk-peer/gthread-jni.c +++ /dev/null @@ -1,169 +0,0 @@ -/* gthread-jni.c -- JNI threading routines for GLIB - Copyright (C) 1998 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. */ - - -#include "gthread-jni.h" - -/* - * This code has been written specifically to be used with GTK+ 1.2. - * `Real' GLIB threading is not supported. We fake things where necessary. - * Once we know we're running on a 1.2 VM, we can write a real implementation. - */ - -static GMutex * -g_mutex_new_jni_impl (void) -{ - jclass obj_class; - jobject *mutex; - - obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/Object"); - if (obj_class == NULL) - return NULL; - - mutex = (jobject *) g_malloc (sizeof (jobject)); - *mutex = (*gdk_env)->AllocObject (gdk_env, obj_class); - if (*mutex == NULL) - { - g_free (mutex); - return NULL; - } - *mutex = (*gdk_env)->NewGlobalRef (gdk_env, *mutex); - - return (GMutex *) mutex; -} - -static void -g_mutex_lock_jni_impl (GMutex *mutex) -{ - if (mutex && mutex == gdk_threads_mutex) - (*gdk_env)->MonitorEnter (gdk_env, *((jobject *)mutex)); -} - -static gboolean -g_mutex_trylock_jni_impl (GMutex *mutex) -{ - return FALSE; -} - -static void -g_mutex_unlock_jni_impl (GMutex *mutex) -{ - if (mutex && mutex == gdk_threads_mutex) - (*gdk_env)->MonitorExit (gdk_env, *((jobject *)mutex)); -} - -static void -g_mutex_free_jni_impl (GMutex *mutex) -{ - if (mutex && mutex == gdk_threads_mutex) - { - (*gdk_env)->DeleteGlobalRef (gdk_env, *((jobject *)mutex)); - g_free (mutex); - } -} - -static GPrivate * -g_private_new_jni_impl (GDestroyNotify notify) -{ - return NULL; -} - -static gpointer -g_private_get_jni_impl (GPrivate *private) -{ - return NULL; -} - -static void -g_private_set_jni_impl (GPrivate *private, gpointer data) -{ -} - -static GCond * -g_cond_new_jni_impl () -{ - return NULL; -} - -static void -g_cond_signal_jni_impl (GCond *cond) -{ -} - -static void -g_cond_broadcast_jni_impl (GCond *cond) -{ -} - -static void -g_cond_wait_jni_impl (GCond *cond, GMutex *mutex) -{ -} - -static gboolean -g_cond_timed_wait_jni_impl (GCond *cond, GMutex *mutex) -{ - return FALSE; -} - -static void -g_cond_free_jni_impl (GCond *cond) -{ -} - -GThreadFunctions g_thread_jni_functions = -{ - g_mutex_new_jni_impl, /* mutex_new */ - g_mutex_lock_jni_impl, /* mutex_lock */ - g_mutex_trylock_jni_impl, /* mutex_try_lock */ - g_mutex_unlock_jni_impl, /* mutex_unlock */ - g_mutex_free_jni_impl, /* mutex_free */ - g_cond_new_jni_impl, /* cond_new */ - g_cond_signal_jni_impl, /* cond_signal */ - g_cond_broadcast_jni_impl, /* cond_broadcast */ - g_cond_wait_jni_impl, /* cond_wait */ - g_cond_timed_wait_jni_impl, /* cond_timed_wait */ - g_cond_free_jni_impl, /* cond_free */ - g_private_new_jni_impl, /* private_new */ - g_private_get_jni_impl, /* private_get */ - g_private_set_jni_impl /* private_set */ -}; - -void -gdk_threads_wake () -{ -} diff --git a/libjava/jni/gtk-peer/gthread-jni.h b/libjava/jni/gtk-peer/gthread-jni.h deleted file mode 100644 index 0bb5a56f1d8..00000000000 --- a/libjava/jni/gtk-peer/gthread-jni.h +++ /dev/null @@ -1,47 +0,0 @@ -/* gthread-jni.h - Copyright (C) 1998, 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. */ - -#ifndef __GTHREADJNI_H__ -#define __GTHREADJNI_H__ - -#include <jni.h> -#include <glib.h> -#include "gtkpeer.h" - -extern GThreadFunctions g_thread_jni_functions; - -#endif /* __GTHREADJNI_H__ */ diff --git a/libjava/jni/gtk-peer/gtkpeer.h b/libjava/jni/gtk-peer/gtkpeer.h deleted file mode 100644 index fa1f19b5a1d..00000000000 --- a/libjava/jni/gtk-peer/gtkpeer.h +++ /dev/null @@ -1,299 +0,0 @@ -/* gtkpeer.h -- Some global variables and #defines - 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. */ - - -#include <gtk/gtk.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <config.h> -#include "native_state.h" - -#include <jni.h> - -#define RC_FILE ".classpath-gtkrc" -#define JVM_SUN -/* - #define JVM_JAPHAR -*/ - -#ifndef __GTKPEER_H__ -#define __GTKPEER_H__ - -#ifdef JVM_SUN - -extern struct state_table *native_state_table; - -#define NSA_INIT(env, clazz) \ - native_state_table = init_state_table (env, clazz) - -#define NSA_GET_PTR(env, obj) \ - get_state (env, obj, native_state_table) - -#define NSA_SET_PTR(env, obj, ptr) \ - set_state (env, obj, native_state_table, (void *)ptr) - -#define NSA_DEL_PTR(env, obj) \ - remove_state_slot (env, obj, native_state_table) - -#endif /* JVM_SUN */ - -struct graphics -{ - GdkDrawable *drawable; - GdkGC *gc; - GdkColormap *cm; - jint x_offset, y_offset; -}; - -#define AWT_DEFAULT_CURSOR 0 -#define AWT_CROSSHAIR_CURSOR 1 -#define AWT_TEXT_CURSOR 2 -#define AWT_WAIT_CURSOR 3 -#define AWT_SW_RESIZE_CURSOR 4 -#define AWT_SE_RESIZE_CURSOR 5 -#define AWT_NW_RESIZE_CURSOR 6 -#define AWT_NE_RESIZE_CURSOR 7 -#define AWT_N_RESIZE_CURSOR 8 -#define AWT_S_RESIZE_CURSOR 9 -#define AWT_W_RESIZE_CURSOR 10 -#define AWT_E_RESIZE_CURSOR 11 -#define AWT_HAND_CURSOR 12 -#define AWT_MOVE_CURSOR 13 - -#define SYNTHETIC_EVENT_MASK (1 << 10) - -#define AWT_SHIFT_MASK (1 << 0) -#define AWT_CTRL_MASK (1 << 1) -#define AWT_META_MASK (1 << 2) -#define AWT_ALT_MASK (1 << 3) - -#define AWT_BUTTON1_MASK (1 << 4) -#define AWT_BUTTON2_MASK AWT_ALT_MASK -#define AWT_BUTTON3_MASK AWT_META_MASK - -#define MULTI_CLICK_TIME 250 -/* as opposed to a MULTI_PASS_TIME :) */ - -#define AWT_MOUSE_CLICKED 500 -#define AWT_MOUSE_PRESSED 501 -#define AWT_MOUSE_RELEASED 502 -#define AWT_MOUSE_MOVED 503 -#define AWT_MOUSE_ENTERED 504 -#define AWT_MOUSE_EXITED 505 -#define AWT_MOUSE_DRAGGED 506 - -#define AWT_ADJUSTMENT_UNIT_INCREMENT 1 -#define AWT_ADJUSTMENT_UNIT_DECREMENT 2 -#define AWT_ADJUSTMENT_BLOCK_DECREMENT 3 -#define AWT_ADJUSTMENT_BLOCK_INCREMENT 4 -#define AWT_ADJUSTMENT_TRACK 5 - -#define AWT_SCROLLPANE_SCROLLBARS_AS_NEEDED 0 -#define AWT_SCROLLPANE_SCROLLBARS_ALWAYS 1 -#define AWT_SCROLLPANE_SCROLLBARS_NEVER 2 - -#define AWT_LABEL_LEFT 0 -#define AWT_LABEL_CENTER 1 -#define AWT_LABEL_RIGHT 2 - -#define AWT_TEXTAREA_SCROLLBARS_BOTH 0 -#define AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY 1 -#define AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY 2 - -#define AWT_ITEM_SELECTED 1 -#define AWT_ITEM_DESELECTED 2 - -#define AWT_KEY_TYPED 400 -#define AWT_KEY_PRESSED 401 -#define AWT_KEY_RELEASED 402 - -#define VK_UNDEFINED 0 -#define AWT_KEY_CHAR_UNDEFINED 0 - -#define VK_0 48 -#define VK_1 49 -#define VK_2 50 -#define VK_3 51 -#define VK_4 52 -#define VK_5 53 -#define VK_6 54 -#define VK_7 55 -#define VK_8 56 -#define VK_9 57 -#define VK_A 65 -#define VK_ACCEPT 30 -#define VK_ADD 107 -#define VK_ALT 18 -#define VK_B 66 -#define VK_BACK_QUOTE 192 -#define VK_BACK_SLASH 92 -#define VK_BACK_SPACE 8 -#define VK_C 67 -#define VK_CANCEL 3 -#define VK_CAPS_LOCK 20 -#define VK_CLEAR 12 -#define VK_CLOSE_BRACKET 93 -#define VK_COMMA 44 -#define VK_CONTROL 17 -#define VK_CONVERT 28 -#define VK_D 68 -#define VK_DECIMAL 110 -#define VK_DELETE 127 -#define VK_DIVIDE 111 -#define VK_DOWN 40 -#define VK_E 69 -#define VK_END 35 -#define VK_ENTER 10 -#define VK_ESCAPE 27 -#define VK_F 70 -#define VK_F1 112 -#define VK_F10 121 -#define VK_F11 122 -#define VK_F12 123 -#define VK_F2 113 -#define VK_F3 114 -#define VK_F4 115 -#define VK_F5 116 -#define VK_F6 117 -#define VK_F7 118 -#define VK_F8 119 -#define VK_F9 120 -#define VK_FINAL 24 -#define VK_G 71 -#define VK_H 72 -#define VK_HELP 156 -#define VK_HOME 36 -#define VK_I 73 -#define VK_INSERT 155 -#define VK_J 74 -#define VK_K 75 -#define VK_KANA 21 -#define VK_KANJI 25 -#define VK_L 76 -#define VK_LEFT 37 -#define VK_M 77 -#define VK_META 157 -#define VK_MODECHANGE 31 -#define VK_MULTIPLY 106 -#define VK_N 78 -#define VK_NONCONVERT 29 -#define VK_NUM_LOCK 144 -#define VK_NUMPAD0 96 -#define VK_NUMPAD1 97 -#define VK_NUMPAD2 98 -#define VK_NUMPAD3 99 -#define VK_NUMPAD4 100 -#define VK_NUMPAD5 101 -#define VK_NUMPAD6 102 -#define VK_NUMPAD7 103 -#define VK_NUMPAD8 104 -#define VK_NUMPAD9 105 -#define VK_O 79 -#define VK_OPEN_BRACKET 91 -#define VK_P 80 -#define VK_PAGE_DOWN 34 -#define VK_PAGE_UP 33 -#define VK_PAUSE 19 -#define VK_PERIOD 46 -#define VK_PRINTSCREEN 154 -#define VK_Q 81 -#define VK_QUOTE 222 -#define VK_R 82 -#define VK_RIGHT 39 -#define VK_S 83 -#define VK_SCROLL_LOCK 145 -#define VK_SEMICOLON 59 -#define VK_SEPARATOR 108 -#define VK_SHIFT 16 -#define VK_SLASH 47 -#define VK_SPACE 32 -#define VK_SUBTRACT 109 -#define VK_T 84 -#define VK_TAB 9 -#define VK_U 85 -#define VK_UP 38 -#define VK_V 86 -#define VK_W 87 -#define VK_X 88 -#define VK_Y 89 -#define VK_Z 90 - -#define AWT_FOCUS_LOST 1004 -#define AWT_FOCUS_GAINED 1005 - -extern jmethodID postActionEventID; -extern jmethodID postMenuActionEventID; -extern jmethodID postMouseEventID; -extern jmethodID postConfigureEventID; -extern jmethodID postExposeEventID; -extern jmethodID postKeyEventID; -extern jmethodID postFocusEventID; -extern jmethodID postAdjustmentEventID; -extern jmethodID postItemEventID; -extern jmethodID postListItemEventID; -extern jmethodID syncAttrsID; -extern jclass gdkColor; -extern jmethodID gdkColorID; -extern JNIEnv *gdk_env; - -void -gdk_window_get_root_geometry (GdkWindow *window, - gint *x, - gint *y, - gint *width, - gint *height, - gint *border, - gint *depth); - -void awt_event_handler (GdkEvent *event); - -void connect_awt_hook (JNIEnv *env, jobject peer_obj, int nwindows, ...); - -void set_visible (GtkWidget *widget, jboolean visible); -void set_parent (GtkWidget *widget, GtkContainer *parent); -GtkLayout *find_gtk_layout (GtkWidget *parent); -void setup_window (JNIEnv *env, jobject obj, GtkWidget *window, jint width, - jint height, jboolean visible); - -struct item_event_hook_info -{ - jobject peer_obj; - jobject item_obj; -}; - -#endif /* __GTKPEER_H */ |