diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
commit | 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/gnu/java/awt | |
parent | 7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff) | |
download | gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/java/awt')
12 files changed, 120 insertions, 91 deletions
diff --git a/libjava/classpath/gnu/java/awt/AWTUtilities.java b/libjava/classpath/gnu/java/awt/AWTUtilities.java index af1fc13ca50..ca7b5511853 100644 --- a/libjava/classpath/gnu/java/awt/AWTUtilities.java +++ b/libjava/classpath/gnu/java/awt/AWTUtilities.java @@ -592,9 +592,12 @@ public class AWTUtilities if (destination == null) destination = getRoot(source); - - convertPointToScreen(pt, source); - convertPointFromScreen(pt, destination); + + if (source.isShowing() && destination.isShowing()) + { + convertPointToScreen(pt, source); + convertPointFromScreen(pt, destination); + } return pt; } diff --git a/libjava/classpath/gnu/java/awt/EmbeddedWindow.java b/libjava/classpath/gnu/java/awt/EmbeddedWindow.java index 08b2140f443..99f90c9f85d 100644 --- a/libjava/classpath/gnu/java/awt/EmbeddedWindow.java +++ b/libjava/classpath/gnu/java/awt/EmbeddedWindow.java @@ -98,13 +98,11 @@ public class EmbeddedWindow extends Frame } catch (IllegalAccessException e) { - throw new RuntimeException - ("couldn't set java.awt.Component.peer field"); + throw new AssertionError (e); } catch (NoSuchFieldException e) { - throw new RuntimeException - ("couldn't set java.awt.Component.peer field"); + throw new AssertionError (e); } super.addNotify(); diff --git a/libjava/classpath/gnu/java/awt/FocusManager.java b/libjava/classpath/gnu/java/awt/FocusManager.java deleted file mode 100644 index 49b40bfc184..00000000000 --- a/libjava/classpath/gnu/java/awt/FocusManager.java +++ /dev/null @@ -1,52 +0,0 @@ -/* FocusManager.java -- Provide Swing FocusManager API compatibility - Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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; - -/** - * This is a subclass of the otherwise abstract class - * {@link javax.swing.FocusManager}. Its sole purpose is to make the Swing - * FocusManager usable as a FocusManager in AWT, so that we can provide both - * the new (1.4) KeyboardFocusManager API and still support the older - * Swing FocusManager. - * - * @author Roman Kennke - */ -public class FocusManager - extends javax.swing.FocusManager -{ -} diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontMetrics.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontMetrics.java index 7a439e83a9d..c79f403edfd 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontMetrics.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontMetrics.java @@ -1,5 +1,5 @@ /* GdkFontMetrics.java - Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -62,15 +62,28 @@ public class GdkFontMetrics extends FontMetrics static final int TEXT_METRICS_HEIGHT = 3; static final int TEXT_METRICS_X_ADVANCE = 4; static final int TEXT_METRICS_Y_ADVANCE = 5; - - + + /** + * Makes sure to return a Font based on the given Font that has as + * peer a GdkFontPeer. Used in the initializer. + */ + private static Font initFont(Font font) + { + if (font == null) + return new Font("Dialog", Font.PLAIN, 12); + else if (font.getPeer() instanceof GdkFontPeer) + return font; + else + { + ClasspathToolkit toolkit; + toolkit = (ClasspathToolkit) Toolkit.getDefaultToolkit(); + return toolkit.getFont(font.getName(), font.getAttributes()); + } + } + public GdkFontMetrics (Font font) { - super (font.getPeer() instanceof GdkFontPeer - ? font - : ((ClasspathToolkit)(Toolkit.getDefaultToolkit ())) - .getFont (font.getName(), font.getAttributes ())); - + super(initFont(font)); peer = (GdkFontPeer) this.font.getPeer(); font_metrics = new int[5]; diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java index 160602b03bf..d80306c8a82 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java @@ -68,7 +68,7 @@ public class GdkGraphics extends Graphics Color color, xorColor; GtkComponentPeer component; - Font font; + Font font = new Font ("Dialog", Font.PLAIN, 12); Rectangle clip; GtkImage image; @@ -88,6 +88,8 @@ public class GdkGraphics extends Graphics color = g.color; xorColor = g.xorColor; font = g.font; + if (font == null) + font = new Font ("Dialog", Font.PLAIN, 12); clip = new Rectangle (g.clip); component = g.component; @@ -115,7 +117,6 @@ public class GdkGraphics extends Graphics GdkGraphics (GtkComponentPeer component) { this.component = component; - font = component.awtComponent.getFont (); color = Color.black; if (component.isRealized ()) @@ -128,6 +129,8 @@ public class GdkGraphics extends Graphics { initState (component); color = component.awtComponent.getForeground (); + if (color == null) + color = Color.BLACK; Dimension d = component.awtComponent.getSize (); clip = new Rectangle (0, 0, d.width, d.height); } @@ -137,6 +140,8 @@ public class GdkGraphics extends Graphics { initStateUnlocked (component); color = component.awtComponent.getForeground (); + if (color == null) + color = Color.BLACK; Dimension d = component.awtComponent.getSize (); clip = new Rectangle (0, 0, d.width, d.height); } @@ -378,7 +383,8 @@ public class GdkGraphics extends Graphics public void setFont (Font font) { - this.font = font; + if (font != null) + this.font = font; } native void setFunction (int gdk_func); diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java index 6d9aabf77d5..c9ed3012658 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java @@ -101,7 +101,7 @@ public class GdkGraphics2D extends Graphics2D static { if (! Configuration.GTK_CAIRO_ENABLED) - throw new Error("Grahics2D not implemented. " + throw new Error("Graphics2D not implemented. " + "Cairo was not found or disabled at configure time"); if (Configuration.INIT_LOAD_LIBRARY) @@ -154,11 +154,22 @@ public class GdkGraphics2D extends Graphics2D public Graphics create(int x, int y, int width, int height) { - return new GdkGraphics2D(width, height); + return new GdkGraphics2D(this, x, y, width, height); + } + + private void fail_g2d () + { + System.err.println ("Attempted to instantiate GdkGraphics2D" + + " but Graphics2D not enabled. Try again with" + + " -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D"); + System.exit (1); } GdkGraphics2D(GdkGraphics2D g) { + if (!GtkToolkit.useGraphics2D ()) + fail_g2d (); + paint = g.paint; stroke = g.stroke; setRenderingHints(g.hints); @@ -198,8 +209,18 @@ public class GdkGraphics2D extends Graphics2D stateStack = new Stack(); } + GdkGraphics2D(GdkGraphics2D g, int x, int y, int widht, int height) + { + this(g); + translate(x, y); + clipRect(0, 0, widht, height); + } + GdkGraphics2D(int width, int height) { + if (!GtkToolkit.useGraphics2D ()) + fail_g2d (); + initState(width, height); setColor(Color.black); @@ -215,6 +236,9 @@ public class GdkGraphics2D extends Graphics2D GdkGraphics2D(GtkComponentPeer component) { + if (!GtkToolkit.useGraphics2D ()) + fail_g2d (); + this.component = component; if (component.isRealized()) @@ -949,7 +973,10 @@ public class GdkGraphics2D extends Graphics2D public Shape getClip() { - return clip.getBounds2D(); //getClipInDevSpace(); + if (clip == null) + return null; + else + return clip.getBounds2D(); //getClipInDevSpace(); } public Rectangle getClipBounds() @@ -992,8 +1019,11 @@ public class GdkGraphics2D extends Graphics2D if (clip == null) { // Reset clipping. - Dimension d = component.awtComponent.getSize(); - setClip(0, 0, d.width, d.height); + if (component != null) + { + Dimension d = component.awtComponent.getSize(); + setClip(0, 0, d.width, d.height); + } } else { @@ -1045,8 +1075,9 @@ public class GdkGraphics2D extends Graphics2D public void clearRect(int x, int y, int width, int height) { - cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0, - bg.getBlue() / 255.0, 1.0); + if (bg != null) + cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0, + bg.getBlue() / 255.0, 1.0); cairoNewPath(); cairoRectangle(x, y, width, height); cairoFill(); @@ -1371,7 +1402,8 @@ public class GdkGraphics2D extends Graphics2D public void copyArea(int x, int y, int width, int height, int dx, int dy) { - throw new java.lang.UnsupportedOperationException(); + GdkGraphics2D g = (GdkGraphics2D) create(x, y, width, height); + gdkDrawDrawable(g, x + dx, y + dy); } public void drawArc(int x, int y, int width, int height, int startAngle, @@ -1604,6 +1636,11 @@ public class GdkGraphics2D extends Graphics2D public void setFont(Font f) { + // Sun's JDK does not throw NPEs, instead it leaves the current setting + // unchanged. So do we. + if (f == null) + return; + if (f.getPeer() instanceof GdkFontPeer) font = f; else diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java index ff51745f26c..c3ae581b14f 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java @@ -388,10 +388,7 @@ public class GdkTextLayout throw new Error("not implemented"); } - public Shape getOutline (AffineTransform tx) - { - throw new Error("not implemented"); - } + public native Shape getOutline (AffineTransform tx); public Shape getVisualHighlightShape (TextHitInfo firstEndpoint, TextHitInfo secondEndpoint, diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java index c140744397a..ed7dc74d22e 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java @@ -131,9 +131,6 @@ public class GtkChoicePeer extends GtkComponentPeer protected void postChoiceItemEvent (String label, int stateChange) { - // Must set our state before notifying listeners - if (stateChange == ItemEvent.SELECTED) - ((Choice) awtComponent).select (label); postItemEvent (label, stateChange); } } diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java index 60e8371277f..fe0dae70dd0 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java @@ -71,6 +71,7 @@ import java.awt.image.ImageProducer; import java.awt.image.VolatileImage; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; +import java.awt.peer.WindowPeer; import java.util.Timer; import java.util.TimerTask; @@ -98,6 +99,7 @@ public class GtkComponentPeer extends GtkGenericPeer native int[] gtkWidgetGetBackground (); native void gtkWidgetGetDimensions (int[] dim); native void gtkWidgetGetPreferredDimensions (int[] dim); + native void gtkWindowGetLocationOnScreen (int[] point); native void gtkWidgetGetLocationOnScreen (int[] point); native void gtkWidgetSetCursor (int type); native void gtkWidgetSetCursorUnlocked (int type); @@ -270,7 +272,10 @@ public class GtkComponentPeer extends GtkGenericPeer public Point getLocationOnScreen () { int point[] = new int[2]; - gtkWidgetGetLocationOnScreen (point); + if( this instanceof WindowPeer ) + gtkWindowGetLocationOnScreen (point); + else + gtkWidgetGetLocationOnScreen (point); return new Point (point[0], point[1]); } diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java index c2cbc37dce9..f5ba3ad2c5e 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java @@ -44,6 +44,10 @@ import java.awt.Rectangle; import java.awt.event.PaintEvent; import java.awt.peer.DialogPeer; +import javax.swing.JDialog; +import javax.swing.JPopupMenu; +import javax.swing.JToolTip; + public class GtkDialogPeer extends GtkWindowPeer implements DialogPeer { @@ -82,10 +86,28 @@ public class GtkDialogPeer extends GtkWindowPeer void create () { - // Create a decorated dialog window. - create (GDK_WINDOW_TYPE_HINT_DIALOG, true); - Dialog dialog = (Dialog) awtComponent; + int type = GDK_WINDOW_TYPE_HINT_DIALOG; + + if (dialog instanceof JDialog) + { + Class heavyWeightClass; + try + { + heavyWeightClass = Class.forName("javax.swing.Popup$JWindowPopup"); + } + catch (ClassNotFoundException e) + { + throw new AssertionError(e); + } + + if (dialog.getClass() == heavyWeightClass + || ((JDialog) dialog).getContentPane() instanceof JToolTip) + type = GDK_WINDOW_TYPE_HINT_MENU; + } + + // Create a decorated dialog window. + create (type, !((Dialog) awtComponent).isUndecorated ()); gtkWindowSetModal (dialog.isModal ()); setTitle (dialog.getTitle ()); diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java index 6eb90ffa0bd..99cca0cffa7 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java @@ -168,7 +168,8 @@ public class GtkFramePeer extends GtkWindowPeer void create () { // Create a normal decorated window. - create (GDK_WINDOW_TYPE_HINT_NORMAL, true); + create (GDK_WINDOW_TYPE_HINT_NORMAL, + !((Frame) awtComponent).isUndecorated ()); Frame frame = (Frame) awtComponent; diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java b/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java index 54f4888cf8d..591b528035d 100644 --- a/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java +++ b/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java @@ -37,6 +37,7 @@ exception statement from your version. */ package gnu.java.awt.peer.qt; +import gnu.classpath.Configuration; import gnu.java.awt.EmbeddedWindow; import gnu.java.awt.peer.ClasspathFontPeer; import gnu.java.awt.peer.EmbeddedWindowPeer; @@ -135,7 +136,8 @@ public class QtToolkit extends ClasspathToolkit { eventQueue = new EventQueue(); repaintThread = new QtRepaintThread(); - System.loadLibrary("qtpeer"); + if (Configuration.INIT_LOAD_LIBRARY) + System.loadLibrary("qtpeer"); String theme = null; try |