diff options
| author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-27 19:04:42 +0000 |
|---|---|---|
| committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-27 19:04:42 +0000 |
| commit | c3d201dee6a1d42270bf2d1388faf42a4a5da8c4 (patch) | |
| tree | fcc5d69edb5a39dceca0ff7cc2899f14dbba82ab /libjava/gnu/java/awt | |
| parent | 149a7f801f64efdc61c4194d8632c11989e12dcd (diff) | |
| download | ppe42-gcc-c3d201dee6a1d42270bf2d1388faf42a4a5da8c4.tar.gz ppe42-gcc-c3d201dee6a1d42270bf2d1388faf42a4a5da8c4.zip | |
2003-07-27 Thomas Fitzsimmons <fitzsim@redhat.com.h>
Michael Koch <konqueror@gmx.de>
* gnu/java/awt/EmbeddedWindow.java
(EmbeddedWindow): Extends Frame instead of Window.
(window_id): New member variable to store the native window handle.
(create): Removed.
(EmbeddedWindow): New constructor.
(addNotify): New method.
(getHandler): Likewise.
(setWindowPeer): New native method.
* gnu/java/awt/EmbeddedWindowSupport.java
(EmbeddedWindowSupport): Fixed documentation.
(createEmbeddedWindow): Return EmbeddedWindowPeer instead of
WindowPeer, give it an EmbeddedWindow instance instead of the raw
window data.
* gnu/java/awt/natEmbeddedWindow.cc
(create): Removed.
(setWindowPeer): New method.
* gnu/java/awt/peer/EmbeddedWindowPeer.java,
gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c:
New files
* gnu/java/awt/peer/gtk/GtkToolkit.java
(GtkToolkit): Implements EmbeddedWindowSupport.
(createEmbeddedWindow): New method.
* java/awt/Window.java
(Window): Removed.
* Makefile.am
(java_source_files): Added EmbeddedWindowPeer.java.
(gtk_awt_peer_sources): Added GtkEmbeddedWindowPeer.java.
(gtk_c_source_files): Added gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c.
* Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69859 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/java/awt')
| -rw-r--r-- | libjava/gnu/java/awt/EmbeddedWindow.java | 52 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/EmbeddedWindowSupport.java | 22 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/natEmbeddedWindow.cc | 9 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/peer/EmbeddedWindowPeer.java | 46 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.java | 55 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkToolkit.java | 11 |
6 files changed, 169 insertions, 26 deletions
diff --git a/libjava/gnu/java/awt/EmbeddedWindow.java b/libjava/gnu/java/awt/EmbeddedWindow.java index 607cc38518c..fc64e215162 100644 --- a/libjava/gnu/java/awt/EmbeddedWindow.java +++ b/libjava/gnu/java/awt/EmbeddedWindow.java @@ -38,25 +38,59 @@ exception statement from your version. */ package gnu.java.awt; -import java.awt.Window; +import gnu.java.awt.peer.EmbeddedWindowPeer; +import java.awt.Frame; +import java.awt.Toolkit; /** - * This class represents an AWT window embedded into another graphical - * toolkit or anther application. + * Represents an AWT window that can be embedded into another + * application. * * @author Michael Koch <konqueror@gmx.de> */ -public class EmbeddedWindow extends Window +public class EmbeddedWindow extends Frame { + private int window_id; + /** - * Creates an window embedded into another application of graphical toolkit. + * Creates an window to be embedded into another application. * * @param window_id The native handle to the screen area where the AWT window * should be embedded. - * @param width The width of the screen area. - * @param height The height of the screen area. */ + public EmbeddedWindow (int window_id) + { + super(); + this.window_id = window_id; + } + + /** + * Creates the native peer for this embedded window. + */ + public void addNotify() + { + Toolkit tk = getToolkit(); + + if (! (tk instanceof EmbeddedWindowSupport)) + throw new UnsupportedOperationException + ("Embedded windows are not supported by the current peers: " + tk.getClass()); + + setWindowPeer (((EmbeddedWindowSupport) tk).createEmbeddedWindow (this)); + super.addNotify(); + } + // This method is only made native to circumvent the package-privateness of - // an internal java.awt.Window constructor. - public static native Window create (int window_id, int width, int height); + // an AWT internal java.awt.Component.peer member variable. + native void setWindowPeer (EmbeddedWindowPeer peer); + + /** + * Gets the native handle of the screen area where the window will + * be embedded. + * + * @return The native handle that was passed to the constructor. + */ + public int getHandle() + { + return window_id; + } } diff --git a/libjava/gnu/java/awt/EmbeddedWindowSupport.java b/libjava/gnu/java/awt/EmbeddedWindowSupport.java index b29db278197..986095305f7 100644 --- a/libjava/gnu/java/awt/EmbeddedWindowSupport.java +++ b/libjava/gnu/java/awt/EmbeddedWindowSupport.java @@ -38,14 +38,15 @@ exception statement from your version. */ package gnu.java.awt; -import java.awt.peer.WindowPeer; +import gnu.java.awt.peer.EmbeddedWindowPeer; /** - * This interface defines a method for creating embedded windows. + * Declares a method for creating native embedded window peers. * - * All classes inherited from java.awt.Toolkit that implement this interface - * are assumed to support embedded windows. To embed the real embedded window - * you need to use gnu.java.awt.EmbeddedWindow. + * All classes inherited from java.awt.Toolkit that implement this + * interface are assumed to support the creation of embedded window + * peers. To create an embedded window, use + * gnu.java.awt.EmbeddedWindow. * * @see gnu.java.awt.EmbeddedWindow * @see java.awt.Toolkit @@ -55,13 +56,10 @@ import java.awt.peer.WindowPeer; public interface EmbeddedWindowSupport { /** - * This method creates an embedded window in an application. + * Creates an embedded window peer, and associates it with an + * EmbeddedWindow object. * - * @param window_id The native handle of a screen area to display an - * AWT window in it. - * @param width The width of the screen area. - * @param height The height of the screen area. + * @param w The embedded window with which to associate a peer. */ - public WindowPeer createEmbeddedWindow (int window_id, - int width, int height); + public EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w); } diff --git a/libjava/gnu/java/awt/natEmbeddedWindow.cc b/libjava/gnu/java/awt/natEmbeddedWindow.cc index 0811d415482..14aa30f9295 100644 --- a/libjava/gnu/java/awt/natEmbeddedWindow.cc +++ b/libjava/gnu/java/awt/natEmbeddedWindow.cc @@ -7,10 +7,11 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for details. */ #include <gnu/java/awt/EmbeddedWindow.h> -#include <java/awt/Window.h> +#include <gnu/java/awt/peer/EmbeddedWindowPeer.h> -::java::awt::Window* -gnu::java::awt::EmbeddedWindow::create (jint window_id, jint width, jint height) +void +gnu::java::awt::EmbeddedWindow::setWindowPeer (gnu::java::awt::peer::EmbeddedWindowPeer* w) { - return new ::java::awt::Window (window_id, width, height); + if (!peer) + (::java::lang::Object*) peer = (::java::lang::Object*) w; } diff --git a/libjava/gnu/java/awt/peer/EmbeddedWindowPeer.java b/libjava/gnu/java/awt/peer/EmbeddedWindowPeer.java new file mode 100644 index 00000000000..a1787684505 --- /dev/null +++ b/libjava/gnu/java/awt/peer/EmbeddedWindowPeer.java @@ -0,0 +1,46 @@ +/* EmbeddedWindowPeer.java -- Interface for window peers that may be + embedded into other applications + Copyright (C) 2003 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.peer; + +import java.awt.peer.FramePeer; + +public interface EmbeddedWindowPeer extends FramePeer +{ +} diff --git a/libjava/gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.java new file mode 100644 index 00000000000..d17ff63e11e --- /dev/null +++ b/libjava/gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.java @@ -0,0 +1,55 @@ +/* GtkEmbeddedWindowPeer.java -- Implements FramePeer using a GtkPlug + Copyright (C) 2003 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.peer.gtk; + +import gnu.java.awt.EmbeddedWindow; +import gnu.java.awt.peer.EmbeddedWindowPeer; + +public class GtkEmbeddedWindowPeer extends GtkFramePeer + implements EmbeddedWindowPeer +{ + native void create(); + native void construct (int window_id); + + public GtkEmbeddedWindowPeer (EmbeddedWindow w) + { + super (w); + construct (w.getHandle()); + } +} diff --git a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java index c998d1909e4..9f669ac5281 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java @@ -52,6 +52,9 @@ import java.util.Hashtable; import java.util.Map; import java.util.MissingResourceException; import java.util.Properties; +import gnu.java.awt.EmbeddedWindow; +import gnu.java.awt.EmbeddedWindowSupport; +import gnu.java.awt.peer.EmbeddedWindowPeer; import gnu.classpath.Configuration; /* This class uses a deprecated method java.awt.peer.ComponentPeer.getPeer(). @@ -61,7 +64,8 @@ import gnu.classpath.Configuration; 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 +public class GtkToolkit extends Toolkit + implements EmbeddedWindowSupport { GtkMainThread main; Hashtable containers = new Hashtable(); @@ -299,6 +303,11 @@ public class GtkToolkit extends java.awt.Toolkit return new GtkWindowPeer (w); } + public EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w) + { + return new GtkEmbeddedWindowPeer (w); + } + protected FontPeer getFontPeer (String name, int style) { try { |

