summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/awt/peer/qt
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/gnu/java/awt/peer/qt
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/qt')
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/MainQtThread.java84
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/NativeWrapper.java43
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QMatrix.java72
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QPainterPath.java140
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QPen.java70
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtAudioClip.java110
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtButtonPeer.java75
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtCanvasPeer.java65
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java111
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtChoicePeer.java93
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java120
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java834
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java112
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java73
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java64
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtFileDialogPeer.java83
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java125
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java197
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtFramePeer.java164
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java714
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java105
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImage.java641
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java147
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java145
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java139
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtLabelPeer.java62
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtListPeer.java188
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java101
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtMenuComponentPeer.java94
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java100
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtMenuPeer.java149
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtPanelPeer.java56
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java76
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtRepaintThread.java156
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtScreenDevice.java115
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java145
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java90
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtScrollbarPeer.java80
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtTextAreaPeer.java179
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtTextFieldPeer.java159
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java470
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java434
-rw-r--r--libjava/classpath/gnu/java/awt/peer/qt/QtWindowPeer.java105
43 files changed, 7285 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/MainQtThread.java b/libjava/classpath/gnu/java/awt/peer/qt/MainQtThread.java
new file mode 100644
index 000000000..bee979ac7
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/MainQtThread.java
@@ -0,0 +1,84 @@
+/* MainQtThread.java --
+ 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.peer.qt;
+
+/**
+ * This Thread is the main Qt thread.
+ *
+ * It doesn't appear to do much here, since all custom code executed by
+ * this thread is injected into Qt's main event loop through the (native)
+ * MainThreadInterface class.
+ */
+public class MainQtThread extends Thread
+{
+ long QApplicationPointer;
+ long mainThreadInterface;
+ String theme;
+ private boolean running;
+ private boolean doublebuffer;
+
+ public MainQtThread( String theme, boolean doublebuffer )
+ {
+ this.theme = theme;
+ this.doublebuffer = doublebuffer;
+ running = false;
+ }
+
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ /**
+ * Creates the QApplication
+ */
+ public native long init(String theme, boolean doublebuffer);
+
+ /**
+ * Runs the QApplication (doesn't return.)
+ */
+ public native void exec(long ptr);
+
+ public void run()
+ {
+ QApplicationPointer = init(theme, doublebuffer);
+ running = true;
+ exec(QApplicationPointer);
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/NativeWrapper.java b/libjava/classpath/gnu/java/awt/peer/qt/NativeWrapper.java
new file mode 100644
index 000000000..706e0df6c
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/NativeWrapper.java
@@ -0,0 +1,43 @@
+/* NativeWrapper.java --
+ 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.peer.qt;
+
+public class NativeWrapper
+{
+ protected long nativeObject;
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QMatrix.java b/libjava/classpath/gnu/java/awt/peer/qt/QMatrix.java
new file mode 100644
index 000000000..ca4d55b59
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QMatrix.java
@@ -0,0 +1,72 @@
+/* QMatrix.java --
+ 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.peer.qt;
+
+import java.awt.geom.AffineTransform;
+
+/**
+ * A simple wrapper class for a QMatrix,
+ * interfacing it to an AffineTransform.
+ */
+public class QMatrix extends NativeWrapper
+{
+
+ public QMatrix( AffineTransform t )
+ {
+ double[] matrix = new double[6];
+ t.getMatrix( matrix );
+ init( matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] );
+ }
+
+ private native void init(double m00, double m10, double m01, double m11,
+ double m02, double m12 );
+
+ private native double[] getMatrix();
+
+ public AffineTransform getTransform()
+ {
+ return new AffineTransform( getMatrix() );
+ }
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QPainterPath.java b/libjava/classpath/gnu/java/awt/peer/qt/QPainterPath.java
new file mode 100644
index 000000000..848b10497
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QPainterPath.java
@@ -0,0 +1,140 @@
+/* QPainterPath.java --
+ 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.peer.qt;
+
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.GeneralPath;
+
+/**
+ * A simple wrapper class for a QPainterPath,
+ * createable from an AWT Shape
+ */
+public class QPainterPath extends NativeWrapper
+{
+ QPainterPath()
+ {
+ }
+
+ public QPainterPath( Shape s )
+ {
+ PathIterator pi = s.getPathIterator( new AffineTransform() );
+ double[] coords = new double[6];
+
+ init( pi.getWindingRule() );
+
+ while( !pi.isDone() )
+ {
+ switch( pi.currentSegment(coords) )
+ {
+ case PathIterator.SEG_MOVETO:
+ moveTo( coords[0], coords[1] );
+ break;
+
+ case PathIterator.SEG_CLOSE:
+ close();
+ break;
+
+ case PathIterator.SEG_LINETO:
+ lineTo( coords[0], coords[1] );
+ break;
+
+ case PathIterator.SEG_QUADTO:
+ quadTo( coords[0], coords[1], coords[2], coords[3] );
+ break;
+
+ case PathIterator.SEG_CUBICTO:
+ cubicTo( coords[0], coords[1],
+ coords[2], coords[3],
+ coords[4], coords[5] );
+ break;
+ }
+ pi.next();
+ }
+ }
+
+ /**
+ * Constructor for rectangles.
+ */
+ public QPainterPath( double x, double y, double w, double h )
+ {
+ init(PathIterator.WIND_EVEN_ODD);
+ moveTo( x, y );
+ lineTo( x + w, y );
+ lineTo( x + w, y + h );
+ lineTo( x , y + h );
+ lineTo( x, y );
+ close();
+ }
+
+ /**
+ * Constructor for lines.
+ */
+ public QPainterPath( double x1, double y1, double x2, double y2, boolean s )
+ {
+ init(PathIterator.WIND_EVEN_ODD);
+ moveTo( x1, y1 );
+ lineTo( x2, y2 );
+ }
+
+ /**
+ * Returns the QPainterPath as a GeneralPath
+ */
+ public native GeneralPath getPath();
+
+ private native void init(int windingRule);
+
+ private native void moveTo(double x, double y);
+
+ private native void close();
+
+ private native void lineTo(double x, double y);
+
+ private native void quadTo(double x1, double y1, double x2, double y2);
+
+ private native void cubicTo(double x1, double y1, double x2, double y2,
+ double x3, double y3);
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QPen.java b/libjava/classpath/gnu/java/awt/peer/qt/QPen.java
new file mode 100644
index 000000000..aee308c26
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QPen.java
@@ -0,0 +1,70 @@
+/* QPen.java --
+ 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.peer.qt;
+
+import java.awt.Stroke;
+import java.awt.BasicStroke;
+
+/**
+ * A simple wrapper class for a QPen,
+ * interfacing it to an BasicStroke.
+ */
+public class QPen extends NativeWrapper
+{
+
+ public QPen( Stroke stroke )
+ {
+ if( !( stroke instanceof BasicStroke ) )
+ throw new IllegalArgumentException("Not a basic stroke.");
+
+ BasicStroke s = (BasicStroke)stroke;
+ if(s.getDashArray() != null)
+ throw new IllegalArgumentException("Can't handle dashed strokes.");
+
+ init(s.getLineWidth(), s.getEndCap(), s.getLineJoin(), s.getMiterLimit());
+ }
+
+ private native void init(double width, int cap, int join, double miterlimit);
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtAudioClip.java b/libjava/classpath/gnu/java/awt/peer/qt/QtAudioClip.java
new file mode 100644
index 000000000..ae2e350eb
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtAudioClip.java
@@ -0,0 +1,110 @@
+/* QtAudioClip.java -- Qt implementation of the applet AudioClip interface
+ 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.peer.qt;
+
+import java.applet.AudioClip;
+import java.awt.Toolkit;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * Implementation of the applet AudioClip interface on a Qt
+ * QSound object.
+ */
+public class QtAudioClip extends NativeWrapper implements AudioClip
+{
+ private static Toolkit t = null;
+
+ public QtAudioClip(String filename)
+ {
+ checkForQt();
+ File f = new File(filename);
+ try
+ {
+ String fn = f.getCanonicalPath();
+ loadClip( fn );
+ }
+ catch(IOException e)
+ {
+ }
+ }
+
+ public QtAudioClip(URL url)
+ {
+
+ }
+
+ private native void loadClip(String filename);
+
+ private native void play(boolean looped);
+
+ private native boolean isAvailable();
+
+ /**
+ * Checks that Qt and sound is available.
+ */
+ private void checkForQt()
+ {
+ if( t == null )
+ t = Toolkit.getDefaultToolkit();
+ if( !( t instanceof QtToolkit) )
+ throw new IllegalStateException("This requires Qt peers.");
+ }
+
+ // *************** Public methods *******************
+
+ public void loop()
+ {
+ play( true );
+ }
+
+ public void play()
+ {
+ play( false );
+ }
+
+ public native void stop();
+
+ public native void dispose();
+
+ public void finalize()
+ {
+ dispose();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtButtonPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtButtonPeer.java
new file mode 100644
index 000000000..6722eb285
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtButtonPeer.java
@@ -0,0 +1,75 @@
+/* QtButtonPeer.java --
+ 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.peer.qt;
+
+import java.awt.Button;
+import java.awt.event.ActionEvent;
+import java.awt.peer.ButtonPeer;
+
+public class QtButtonPeer extends QtComponentPeer implements ButtonPeer
+{
+ public QtButtonPeer( QtToolkit kit, Button owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setLabel( ((Button)owner).getLabel() );
+ }
+
+ /**
+ * Callback for button click events
+ */
+ void fireClick(int modifiers)
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((Button)owner).getActionCommand(),
+ System.currentTimeMillis(),
+ modifiers);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void setLabel( String label );
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtCanvasPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtCanvasPeer.java
new file mode 100644
index 000000000..2367cd066
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtCanvasPeer.java
@@ -0,0 +1,65 @@
+/* QtCanvasPeer.java --
+ 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.peer.qt;
+
+import java.awt.Canvas;
+import java.awt.Dimension;
+import java.awt.peer.CanvasPeer;
+
+public class QtCanvasPeer extends QtComponentPeer implements CanvasPeer
+{
+ public QtCanvasPeer( QtToolkit kit, Canvas owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ /**
+ * Overloaded, because a Canvas doesn't have a preferred size.
+ */
+ public Dimension getPreferredSize()
+ {
+ return owner.getSize();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java
new file mode 100644
index 000000000..37fb51c48
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtCheckboxPeer.java
@@ -0,0 +1,111 @@
+/* QtCheckboxPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Checkbox;
+import java.awt.CheckboxGroup;
+import java.awt.event.ItemEvent;
+import java.awt.peer.CheckboxPeer;
+import java.util.WeakHashMap;
+
+public class QtCheckboxPeer extends QtComponentPeer implements CheckboxPeer
+{
+ private CheckboxGroup group;
+
+ // Map QButtonGroup<->CheckboxGroup
+ private static WeakHashMap groupMap;
+
+ static
+ {
+ groupMap = new WeakHashMap();
+ }
+
+ public QtCheckboxPeer( QtToolkit kit, Checkbox owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setCheckboxGroup( ((Checkbox)owner).getCheckboxGroup() );
+ setLabel( ((Checkbox)owner).getLabel() );
+ setState( ((Checkbox)owner).getState() );
+ }
+
+ private void fireToggle(boolean checked)
+ {
+ if (group == null)
+ ((Checkbox)owner).setState( checked );
+ else
+ if ( checked )
+ group.setSelectedCheckbox((Checkbox)owner);
+
+ int sel = checked ? ItemEvent.SELECTED : ItemEvent.DESELECTED;
+ ItemEvent e = new ItemEvent((Checkbox)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ((Checkbox)owner).getLabel(),
+ sel);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public void setCheckboxGroup( CheckboxGroup group )
+ {
+ if(this.group == group)
+ return;
+
+ // if we change from a checkbox to a radio button or vice versa
+ if((this.group == null) != (group == null))
+ {
+ this.group = group;
+ callInit();
+ setup();
+ }
+
+ this.group = group;
+ }
+
+ public native void setLabel( String label );
+
+ public native void setState( boolean state );
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtChoicePeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtChoicePeer.java
new file mode 100644
index 000000000..d279468cd
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtChoicePeer.java
@@ -0,0 +1,93 @@
+/* QtChoicePeer.java --
+ 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.peer.qt;
+
+import java.awt.Choice;
+import java.awt.event.ItemEvent;
+import java.awt.peer.ChoicePeer;
+
+public class QtChoicePeer extends QtComponentPeer implements ChoicePeer
+{
+ public QtChoicePeer( QtToolkit kit, Choice owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+
+ Choice c = (Choice) owner;
+ int n = c.getItemCount();
+ for ( int i = 0; i < n ; i++ )
+ add( c.getItem( i ), i );
+ select( c.getSelectedIndex() );
+ }
+
+ private void fireChoice( int index )
+ {
+ ((Choice)owner).select( index );
+ ItemEvent e = new ItemEvent((Choice)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ((Choice)owner).getItem(index),
+ ItemEvent.SELECTED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void add( String item, int index );
+
+ public void addItem( String item, int index )
+ {
+ add(item, index);
+ }
+
+ public native void remove( int index );
+
+ public void removeAll()
+ {
+ int n = ((Choice)owner).getItemCount();
+ for (int i = 0; i < n; i++)
+ remove( i );
+ }
+
+ public native void select( int index );
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java
new file mode 100644
index 000000000..27e12e659
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentGraphics.java
@@ -0,0 +1,120 @@
+/* QtComponentGraphics.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+/**
+ * QtComponentPainter is a Graphics2D context for painting directly to AWT
+ * components. They require an existing QPainter object (the one passed into
+ * the native paint method), and are created there (ONLY).
+ *
+ * Since this context does direct on-screen drawing it is NOT thread-safe,
+ * and should NOT be used outside the thread in which it was created.
+ *
+ * In other words,
+ * this is intended for use by QtComponentPeer.paintEvent() only.
+ *
+ */
+public class QtComponentGraphics extends QtGraphics
+{
+ private QtComponentPeer peer;
+
+ /**
+ * Creates a new ComponentGraphics from an *existing* QPainter object.
+ *
+ * @param ptr the pointer to the QPainter object.
+ */
+ public QtComponentGraphics(long ptr, QtComponentPeer component,
+ int x, int y, int w, int h)
+ {
+ nativeObject = ptr;
+ peer = component;
+
+ Rectangle r = new Rectangle(x, y, w, h);
+ initialClip = r;
+
+ setAlpha( 1.0 );
+ Color c = component.owner.getBackground();
+ if(c == null)
+ setBackground(Color.white);
+ else
+ setBackground( c );
+
+ c = component.owner.getForeground();
+ if(c == null)
+ setColor( Color.black );
+ else
+ setColor( c );
+ setup();
+ setClip( initialClip );
+ }
+
+ /**
+ * Copying constructor
+ */
+ QtComponentGraphics( QtComponentGraphics g )
+ {
+ super( g ); // Slalom is fun
+ }
+
+ public Graphics create()
+ {
+ return new QtComponentGraphics( this );
+ }
+
+ /**
+ * This is a tricky one
+ */
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ // FIXME
+ }
+
+ /**
+ * Returns the GraphicsConfiguration of the context component.
+ */
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ return peer.getGraphicsConfiguration();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java
new file mode 100644
index 000000000..16149b2e6
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtComponentPeer.java
@@ -0,0 +1,834 @@
+/* QtComponentPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Component;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Image;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.KeyboardFocusManager;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.event.ComponentEvent; // 100%
+import java.awt.event.FocusEvent; // 100%
+import java.awt.event.InputEvent; // (abstract)
+import java.awt.event.KeyEvent; // 2/3
+import java.awt.event.MouseEvent; // 70%?
+import java.awt.event.PaintEvent; // Yup.
+import java.awt.event.WindowEvent; // 2/ 12
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class QtComponentPeer extends NativeWrapper implements ComponentPeer
+{
+
+ /**
+ * Popup trigger button, may differ between platforms
+ */
+ protected static final int POPUP_TRIGGER = 3;
+
+ /**
+ * The toolkit which manufactured this peer.
+ */
+ protected QtToolkit toolkit;
+
+ /**
+ * The component which owns this peer.
+ */
+ Component owner;
+
+ /**
+ * Classpath updates our eventMask.
+ */
+ private long eventMask;
+
+ /**
+ * if the thing has mouse motion listeners or not.
+ */
+ private boolean hasMotionListeners;
+
+ /**
+ * The component's double buffer for off-screen drawing.
+ */
+ protected QtImage backBuffer;
+
+ protected long qtApp;
+
+ private boolean settingUp;
+
+ private boolean ignoreResize = false;
+
+ QtComponentPeer( QtToolkit kit, Component owner )
+ {
+ this.owner = owner;
+ this.toolkit = kit;
+ qtApp = QtToolkit.guiThread.QApplicationPointer;
+ nativeObject = 0;
+ synchronized(this)
+ {
+ callInit(); // Calls the init method FROM THE MAIN THREAD.
+ try
+ {
+ wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ setup();
+ hasMotionListeners = false;
+ }
+
+ protected native void callInit();
+
+ /**
+ * Init does the creation of native widgets, it is therefore
+ * called from the main thread. (the constructor waits for this to happen.)
+ */
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ settingUp = true;
+ if (owner != null)
+ {
+ if (owner instanceof javax.swing.JComponent)
+ setBackground(owner.getBackground());
+ else
+ owner.setBackground(getNativeBackground());
+
+ if (owner.getForeground() != null)
+ setForeground(owner.getForeground());
+ else
+ setForeground( Color.black );
+
+ if (owner.getCursor() != null)
+ if (owner.getCursor().getType() != Cursor.DEFAULT_CURSOR)
+ setCursor(owner.getCursor());
+
+ if (owner.getFont() != null)
+ setFont(owner.getFont());
+
+ setEnabled( owner.isEnabled() );
+
+ backBuffer = null;
+ updateBounds();
+
+ setVisible( owner.isVisible() );
+ QtToolkit.repaintThread.queueComponent(this);
+ }
+ settingUp = false;
+ }
+
+ native void QtUpdate();
+ native void QtUpdateArea( int x, int y, int w, int h );
+ private synchronized native void disposeNative();
+ private native void setGround( int r, int g, int b, boolean isForeground );
+ private native void setBoundsNative( int x, int y, int width, int height );
+ private native void setCursor( int ctype );
+ private native Color getNativeBackground();
+ private native void setFontNative( QtFontPeer fp );
+ private native int whichScreen();
+ private native void reparentNative( QtContainerPeer parent );
+ private native void getLocationOnScreenNative( Point p );
+
+ private boolean drawableComponent()
+ {
+ return ((this instanceof QtContainerPeer &&
+ !(this instanceof QtScrollPanePeer)) ||
+ (this instanceof QtCanvasPeer));
+ }
+
+ void updateBounds()
+ {
+ Rectangle r = owner.getBounds();
+ setBounds( r.x, r.y, r.width, r.height );
+ }
+
+ synchronized void updateBackBuffer(int width, int height)
+ {
+ if(width <= 0 || height <= 0)
+ return;
+
+ if( !drawableComponent() && backBuffer == null)
+ return;
+
+ if( backBuffer != null )
+ {
+ if( width < backBuffer.width && height < backBuffer.height )
+ return;
+ backBuffer.dispose();
+ }
+ backBuffer = new QtImage(width, height);
+ }
+
+
+ // ************ Event methods *********************
+
+ /**
+ * Window closing event
+ */
+ protected void closeEvent()
+ {
+ if (owner instanceof Window)
+ {
+ WindowEvent e = new WindowEvent((Window)owner,
+ WindowEvent.WINDOW_CLOSING);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ protected void enterEvent(int modifiers, int x, int y, int dummy)
+ {
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_ENTERED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, 0, false);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void focusInEvent()
+ {
+ FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_GAINED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void focusOutEvent()
+ {
+ FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_LOST);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void keyPressEvent(int modifiers, int code, int unicode, int dummy)
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ KeyEvent e = new KeyEvent(owner,
+ KeyEvent.KEY_PRESSED,
+ System.currentTimeMillis(),
+ modifiers, code, (char)(unicode & 0xFFFF),
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ if (!manager.dispatchEvent (e))
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void keyReleaseEvent(int modifiers, int code, int unicode, int dummy)
+ {
+ KeyEvent e = new KeyEvent(owner,
+ KeyEvent.KEY_RELEASED,
+ System.currentTimeMillis(),
+ modifiers, code, (char)(unicode & 0xFFFF),
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void leaveEvent(int modifiers, int x, int y, int dummy)
+ {
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_EXITED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, 0, false);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // FIXME: Coalesce press-release events into clicks.
+ protected void mouseDoubleClickEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_CLICKED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mouseMoveEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+
+ int type = (button != 0) ?
+ MouseEvent.MOUSE_DRAGGED :MouseEvent.MOUSE_MOVED;
+
+ MouseEvent e = new MouseEvent(owner,
+ type,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mousePressEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_PRESSED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ ( button == POPUP_TRIGGER ),
+ button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void mouseReleaseEvent( int modifiers, int x, int y, int clickCount)
+ {
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
+ int button = 0;
+ if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
+ InputEvent.BUTTON1_DOWN_MASK) button = 1;
+ if((modifiers & InputEvent.BUTTON2_DOWN_MASK) ==
+ InputEvent.BUTTON2_DOWN_MASK) button = 2;
+ if((modifiers & InputEvent.BUTTON3_DOWN_MASK) ==
+ InputEvent.BUTTON3_DOWN_MASK) button = 3;
+
+ MouseEvent e = new MouseEvent(owner,
+ MouseEvent.MOUSE_RELEASED,
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF), x, y, clickCount,
+ false, button);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ protected void moveEvent(int x, int y, int oldx, int oldy)
+ {
+ if( !ignoreResize )
+ {
+ // Since Component.setLocation calls back to setBounds,
+ // we need to ignore that.
+ ignoreResize = true;
+ owner.setLocation( x, y );
+ ignoreResize = false;
+ }
+ }
+
+ protected void resizeEvent(int oldWidth, int oldHeight,
+ int width, int height)
+ {
+ if(!(owner instanceof Window))
+ return;
+ updateBackBuffer(width, height);
+ ignoreResize = true;
+ owner.setSize(width, height);
+ ignoreResize = false;
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_RESIZED);
+ QtToolkit.eventQueue.postEvent(e);
+ QtToolkit.repaintThread.queueComponent(this);
+ }
+
+ protected void showEvent()
+ {
+ if (owner instanceof Window)
+ {
+ WindowEvent e = new WindowEvent((Window)owner,
+ WindowEvent.WINDOW_OPENED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ else
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_SHOWN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ protected void hideEvent()
+ {
+ ComponentEvent e = new ComponentEvent(owner,
+ ComponentEvent.COMPONENT_HIDDEN);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ /** Classpath-specific method */
+ public void setEventMask(long x)
+ {
+ eventMask = x;
+ }
+
+
+ public boolean canDetermineObscurity()
+ {
+ return true;
+ }
+
+ public int checkImage(Image img,
+ int w,
+ int h,
+ ImageObserver o)
+ {
+ return toolkit.checkImage(img, w, h, o);
+ }
+
+ public void createBuffers(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ // FIXME
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ return toolkit.createImage(producer);
+ }
+
+ public Image createImage(int width, int height)
+ {
+ return new QtImage(width, height);
+ }
+
+ public void coalescePaintEvent(PaintEvent e)
+ {
+ // FIXME
+ }
+
+ public VolatileImage createVolatileImage(int w, int h)
+ {
+ return new QtVolatileImage( w, h );
+ }
+
+ public void destroyBuffers()
+ {
+ // FIXME
+ }
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void dispose()
+ {
+ disposeNative();
+ if( backBuffer != null )
+ backBuffer.dispose();
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void flip(BufferCapabilities.FlipContents contents)
+ {
+ }
+
+ public Image getBackBuffer()
+ {
+ return backBuffer;
+ }
+
+ public ColorModel getColorModel()
+ {
+ return toolkit.getColorModel();
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics( font, getGraphics() );
+ }
+
+ public Graphics getGraphics()
+ {
+ if( backBuffer == null )
+ {
+ Rectangle r = owner.getBounds();
+ backBuffer = new QtImage( r.width, r.height );
+ }
+ return backBuffer.getDirectGraphics( this );
+ }
+
+ public GraphicsConfiguration getGraphicsConfiguration()
+ {
+ int id = whichScreen(); // get the ID of the screen the widget is on.
+ GraphicsDevice[] devs = QtToolkit.graphicsEnv.getScreenDevices();
+ return devs[id].getDefaultConfiguration();
+ }
+
+ public Point getLocationOnScreen()
+ {
+ Point p = new Point();
+ synchronized( p )
+ {
+ getLocationOnScreenNative( p );
+ try
+ {
+ p.wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ return p;
+ }
+
+ private native void getSizeNative(Dimension d, boolean preferred);
+
+ private Dimension getSize(boolean preferred)
+ {
+ Dimension d = new Dimension();
+ synchronized( d )
+ {
+ getSizeNative(d, preferred);
+ try
+ {
+ d.wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ return d;
+ }
+
+ public Dimension getMinimumSize()
+ {
+ return getSize( false );
+ }
+
+ public Dimension getPreferredSize()
+ {
+ return getSize( true );
+ }
+
+ public Toolkit getToolkit()
+ {
+ return toolkit;
+ }
+
+ public native boolean handlesWheelScrolling();
+
+ public void hide()
+ {
+ setVisible(false);
+ }
+
+ public native boolean isFocusable();
+
+ public boolean isFocusTraversable()
+ {
+ // FIXME
+ return false;
+ }
+
+ public native boolean isObscured();
+
+ public Dimension minimumSize()
+ {
+ return getMinimumSize();
+ }
+
+ public Dimension preferredSize()
+ {
+ return getPreferredSize();
+ }
+
+ public native void requestFocus();
+
+ public boolean requestFocus (Component source, boolean bool1,
+ boolean bool2, long x)
+ {
+ // FIXME
+ return true;
+ }
+
+ public void reshape(int x,
+ int y,
+ int width,
+ int height)
+ {
+ setBounds( x, y, width, height );
+ }
+
+ public void setBackground(Color c)
+ {
+ if(c == null && !settingUp)
+ return;
+ setGround(c.getRed(), c.getGreen(), c.getBlue(), false);
+ }
+
+ public void setBounds(int x, int y, int width, int height)
+ {
+ if( ignoreResize )
+ return;
+ updateBackBuffer(width, height);
+ QtToolkit.repaintThread.queueComponent(this);
+ setBoundsNative(x, y, width, height);
+ }
+
+ public void setCursor(Cursor cursor)
+ {
+ if (cursor != null)
+ setCursor(cursor.getType());
+ }
+
+ public native void setEnabled(boolean b);
+
+ public void setFont(Font f)
+ {
+ if( f == null || f.getPeer() == null)
+ throw new IllegalArgumentException("Null font.");
+ setFontNative( (QtFontPeer)f.getPeer() );
+ }
+
+ public void setForeground(Color c)
+ {
+ if(c == null && !settingUp)
+ return;
+ setGround(c.getRed(), c.getGreen(), c.getBlue(), true);
+ }
+
+ public native void setVisible(boolean b);
+
+ public void show()
+ {
+ setVisible(true);
+ }
+
+ public void handleEvent (AWTEvent e)
+ {
+ int eventID = e.getID();
+ Rectangle r;
+
+ switch (eventID)
+ {
+ case ComponentEvent.COMPONENT_SHOWN:
+ QtToolkit.repaintThread.queueComponent(this);
+ break;
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ r = ((PaintEvent)e).getUpdateRect();
+ QtToolkit.repaintThread.queueComponent(this, r.x, r.y,
+ r.width, r.height);
+ break;
+ case KeyEvent.KEY_PRESSED:
+ break;
+ case KeyEvent.KEY_RELEASED:
+ break;
+ }
+ }
+
+ /**
+ * paint() is called back from the native side in response to a native
+ * repaint event.
+ */
+ public void paint(Graphics g)
+ {
+ Rectangle r = g.getClipBounds();
+
+ if (backBuffer != null)
+ backBuffer.drawPixelsScaledFlipped ((QtGraphics) g,
+ 0, 0, 0, /* bg colors */
+ false, false, /* no flipping */
+ r.x, r.y, r.width, r.height,
+ r.x, r.y, r.width, r.height,
+ false ); /* no compositing */
+ }
+
+ public void paintBackBuffer() throws InterruptedException
+ {
+ if( backBuffer != null )
+ {
+ backBuffer.clear();
+ Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
+ owner.paint(bbg);
+ bbg.dispose();
+ }
+ }
+
+ public void paintBackBuffer(int x, int y, int w, int h)
+ throws InterruptedException
+ {
+ if( backBuffer != null )
+ {
+ Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
+ bbg.setBackground( getNativeBackground() );
+ bbg.clearRect(x, y, w, h);
+ bbg.setClip(x, y, w, h);
+ owner.paint(bbg);
+ bbg.dispose();
+ }
+ }
+
+ public boolean prepareImage(Image img,
+ int w,
+ int h,
+ ImageObserver o)
+ {
+ return toolkit.prepareImage(img, w, h, o);
+ }
+
+ public void print(Graphics g)
+ {
+ // FIXME
+ }
+
+ /**
+ * Schedules a timed repaint.
+ */
+ public void repaint(long tm,
+ int x,
+ int y,
+ int w,
+ int h)
+ {
+ if( tm <= 0 )
+ {
+ QtToolkit.repaintThread.queueComponent(this, x, y, w, h);
+ return;
+ }
+ Timer t = new Timer();
+ t.schedule(new RepaintTimerTask(this, x, y, w, h), tm);
+ }
+
+ /**
+ * Update the cursor (note that setCursor is usually not called)
+ */
+ public void updateCursorImmediately()
+ {
+ if (owner.getCursor() != null)
+ setCursor(owner.getCursor().getType());
+ }
+
+ /**
+ * Timed repainter
+ */
+ private class RepaintTimerTask extends TimerTask
+ {
+ private int x, y, w, h;
+ private QtComponentPeer peer;
+ RepaintTimerTask(QtComponentPeer peer, int x, int y, int w, int h)
+ {
+ this.x=x;
+ this.y=y;
+ this.w=w;
+ this.h=h;
+ this.peer=peer;
+ }
+ public void run()
+ {
+ QtToolkit.repaintThread.queueComponent(peer, x, y, w, h);
+ }
+ }
+
+ public native Rectangle getBounds();
+
+ public void reparent(ContainerPeer parent)
+ {
+ if(!(parent instanceof QtContainerPeer))
+ throw new IllegalArgumentException("Illegal peer.");
+ reparentNative((QtContainerPeer)parent);
+ }
+
+ public void setBounds(int x, int y, int width, int height, int z)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isReparentSupported()
+ {
+ return true;
+ }
+
+ // What does this do, anyway?
+ public void layout()
+ {
+ // TODO Auto-generated method stub
+ }
+
+ public boolean requestFocus(Component lightweightChild, boolean temporary,
+ boolean focusedWindowChangeAllowed,
+ long time, sun.awt.CausedFocusEvent.Cause cause)
+ {
+ // TODO: Implement this properly and remove the other requestFocus()
+ // methods.
+ return true;
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java
new file mode 100644
index 000000000..ee2873730
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtContainerPeer.java
@@ -0,0 +1,112 @@
+/* QtContainerPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Component;
+import java.awt.Insets;
+import java.awt.peer.ContainerPeer;
+
+public class QtContainerPeer extends QtComponentPeer implements ContainerPeer
+{
+ public QtContainerPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+ public void beginLayout()
+ {
+ // FIXME
+ }
+
+ public void beginValidate()
+ {
+ }
+
+ public void endLayout()
+ {
+ QtUpdate();
+ }
+
+ public void endValidate()
+ {
+ }
+
+ public Insets getInsets()
+ {
+ return new Insets(0, 0, 0, 0);
+ }
+
+ public Insets insets()
+ {
+ return getInsets();
+ }
+
+ public boolean isPaintPending()
+ {
+ // FIXME etc.
+ return false;
+ }
+
+ public boolean isRestackSupported()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void cancelPendingPaint(int x, int y, int width, int height)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void restack()
+ {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java
new file mode 100644
index 000000000..2f2c25550
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtDialogPeer.java
@@ -0,0 +1,73 @@
+/* QtDialogPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Dialog;
+import java.awt.peer.DialogPeer;
+
+public class QtDialogPeer extends QtWindowPeer implements DialogPeer
+{
+ public QtDialogPeer( QtToolkit kit, Dialog owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setTitle( ((Dialog)owner).getTitle() );
+ setResizable( ((Dialog)owner).isResizable() );
+ setModal( ((Dialog)owner).isModal() );
+ }
+
+ native void setModal(boolean modal);
+
+ private native void setBoundsNative(int x, int y, int width, int height, boolean fixed);
+
+ // ************ Public methods *********************
+
+ public native void setResizable (boolean resizeable);
+
+ public void setBounds(int x, int y, int width, int height)
+ {
+ setBoundsNative(x, y, width, height,
+ !((Dialog)owner).isResizable());
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
new file mode 100644
index 000000000..de76cd17f
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
@@ -0,0 +1,64 @@
+/* QtEmbeddedWindowPeer.java -- embedded window peer
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Component;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+
+/**
+ * Embedded window peer for applets.
+ * FIXME: EmbeddedWindowPeer and this class should extend Window, NOT Frame.
+ */
+public class QtEmbeddedWindowPeer extends QtFramePeer implements EmbeddedWindowPeer
+{
+ public QtEmbeddedWindowPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+
+ public native void embed( long handle );
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtFileDialogPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtFileDialogPeer.java
new file mode 100644
index 000000000..06943d955
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtFileDialogPeer.java
@@ -0,0 +1,83 @@
+/* QtFileDialogPeer.java --
+ 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.peer.qt;
+
+import java.awt.FileDialog;
+import java.io.FilenameFilter;
+import java.awt.peer.FileDialogPeer;
+
+public class QtFileDialogPeer extends QtDialogPeer implements FileDialogPeer
+{
+ public QtFileDialogPeer( QtToolkit kit, FileDialog owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setMode( ((FileDialog)owner).getMode() );
+ }
+
+ /**
+ * Sets load or save mode
+ */
+ private native void setMode(int mode);
+
+ private void fileDialogDone(String path, String filename)
+ {
+ }
+
+ // ************ Public methods *********************
+ public void setFile (String file)
+ {
+ // FIXME
+ }
+
+ public void setDirectory (String dir)
+ {
+ // FIXME
+ }
+
+ public void setFilenameFilter (FilenameFilter ff)
+ {
+ // FIXME
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java
new file mode 100644
index 000000000..1998339dc
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtFontMetrics.java
@@ -0,0 +1,125 @@
+/* QtFontMetrics.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.geom.Rectangle2D;
+
+public class QtFontMetrics extends FontMetrics
+{
+
+ private long nativeObject;
+ private QtFontPeer peer;
+
+ public QtFontMetrics( Font f )
+ {
+ super( f );
+ if(f.getPeer() == null || !(f.getPeer() instanceof QtFontPeer))
+ throw new IllegalArgumentException("Invalid Font object.");
+ peer = (QtFontPeer) f.getPeer();
+ init( peer );
+ }
+
+ public QtFontMetrics( Font f, Graphics g )
+ {
+ super( f );
+ if(f.getPeer() == null || !(f.getPeer() instanceof QtFontPeer))
+ throw new IllegalArgumentException("Invalid Font object.");
+ if( !(g instanceof QtGraphics) )
+ throw new IllegalArgumentException("Invalid graphics object.");
+ peer = (QtFontPeer) f.getPeer();
+ initGraphics(peer, (QtGraphics)g );
+ }
+
+ QtFontMetrics( QtFontPeer f, Graphics g )
+ {
+ super( null );
+ if( !(g instanceof QtGraphics) )
+ throw new IllegalArgumentException("Invalid graphics object.");
+ peer = f;
+ initGraphics(peer, (QtGraphics)g );
+ }
+
+ public QtFontMetrics( QtFontPeer fp )
+ {
+ super( (Font)null );
+ peer = fp;
+ init( peer );
+ }
+
+ private native void init(QtFontPeer fp);
+
+ private native void initGraphics(QtFontPeer fp, QtGraphics g);
+
+ private native void dispose();
+
+ native Rectangle2D getStringBounds(String s);
+
+ // ****************** Package private ***************************
+
+ native boolean canDisplay( int c );
+
+ // ****************** Public methods ****************************
+
+ public native int getAscent();
+
+ public native int getDescent();
+
+ public native int getHeight();
+
+ public native int getLeading();
+
+ public native int getMaxAdvance();
+
+ public native int charWidth(char c);
+
+ public int charsWidth(char[] chars, int off, int len)
+ {
+ return stringWidth( new String(chars, off, len) );
+ }
+
+ public native int stringWidth(String str);
+
+ public Rectangle2D getStringBounds(String str, Graphics context)
+ {
+ QtFontMetrics fm = new QtFontMetrics(peer, context);
+ return fm.getStringBounds( str );
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java
new file mode 100644
index 000000000..03ed1d2df
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtFontPeer.java
@@ -0,0 +1,197 @@
+/* QtFontPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.geom.Rectangle2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+import java.text.CharacterIterator;
+import java.util.Locale;
+import java.util.Map;
+
+import gnu.java.awt.peer.ClasspathFontPeer;
+
+public class QtFontPeer extends ClasspathFontPeer
+{
+ // Pointer to native QFont structure.
+ private long nativeObject;
+ private QtFontMetrics metrics;
+
+
+ public QtFontPeer (String name, int style)
+ {
+ this(name, style, 12);
+ }
+
+ public QtFontPeer (String name, int style, int size)
+ {
+ super(name, style, size);
+ init();
+ }
+
+ public QtFontPeer (String name, Map attributes)
+ {
+ super(name, attributes);
+ init();
+ }
+
+ public void init()
+ {
+ if(this.familyName == null)
+ throw new IllegalArgumentException("null family name");
+ if(this.familyName.equals("Helvetica"))
+ this.familyName = "sans serif";
+ if(this.familyName.equals("Dialog"))
+ this.familyName = "sans serif";
+ create(this.familyName, this.style, (int)this.size);
+ metrics = new QtFontMetrics(this);
+ }
+
+ /**
+ * Creates the QFont object.
+ */
+ private native void create(String name, int style, int size);
+
+ /**
+ * Destroys the QFont.
+ */
+ public native void dispose();
+
+
+ // ****************** ClasspathFontPeer Methods.
+
+ public boolean canDisplay (Font font, int c)
+ {
+ return metrics.canDisplay( c );
+ }
+
+ public int canDisplayUpTo (Font font, CharacterIterator i,
+ int start, int limit)
+ {
+ int index = start;
+ char c = i.setIndex( index );
+ while( index <= limit )
+ {
+ if(!canDisplay(font, c))
+ return index;
+ index++;
+ c = i.next();
+ }
+ return -1;
+ }
+
+ public String getSubFamilyName (Font font, Locale locale)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPostScriptName (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNumGlyphs (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getMissingGlyphCode (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getBaselineFor (Font font, char c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getGlyphName (Font font, int glyphIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector createGlyphVector (Font font,
+ FontRenderContext frc,
+ CharacterIterator ci)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector createGlyphVector (Font font,
+ FontRenderContext ctx,
+ int[] glyphCodes)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public GlyphVector layoutGlyphVector (Font font,
+ FontRenderContext frc,
+ char[] chars, int start,
+ int limit, int flags)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public FontMetrics getFontMetrics (Font font)
+ {
+ return new QtFontMetrics( this );
+ }
+
+ public boolean hasUniformLineMetrics (Font font)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public LineMetrics getLineMetrics (Font font,
+ CharacterIterator ci,
+ int begin, int limit,
+ FontRenderContext rc)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Rectangle2D getMaxCharBounds (Font font,
+ FontRenderContext rc)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtFramePeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtFramePeer.java
new file mode 100644
index 000000000..d5162106f
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtFramePeer.java
@@ -0,0 +1,164 @@
+/* QtFramePeer.java --
+ 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.peer.qt;
+
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.MenuBar;
+import java.awt.Rectangle;
+import java.awt.peer.FramePeer;
+
+public class QtFramePeer extends QtWindowPeer implements FramePeer
+{
+ private int theState; // FIXME
+
+ long frameObject;
+
+ public QtFramePeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setTitle( ((Frame)owner).getTitle() );
+ if( ((Frame)owner).getMenuBar() != null )
+ setMenuBar( ((Frame)owner).getMenuBar() );
+ }
+
+ private native void setIcon(QtImage image);
+
+ private native void setMaximizedBounds(int w, int h);
+
+ private native void setMenu(QtMenuBarPeer mb);
+
+ private native int menuBarHeight();
+
+ // ************ Public methods *********************
+
+ public void destroy()
+ {
+ dispose();
+ }
+
+ public int getState()
+ {
+ // FIXME
+ return theState;
+ }
+
+ public Insets getInsets()
+ {
+ int mbHeight = ( ((Frame)owner).getMenuBar() != null ) ?
+ menuBarHeight() : 0;
+ return new Insets(mbHeight, 0, 0, 0);
+ }
+
+ public void setIconImage(Image im)
+ {
+ if (im instanceof QtImage)
+ setIcon( (QtImage)im );
+ else
+ setIcon( new QtImage( im.getSource() ) );
+ }
+
+ public void setMaximizedBounds(Rectangle rect)
+ {
+ // FIXME
+ }
+
+ public void setMenuBar(MenuBar mb)
+ {
+ if( mb != null )
+ {
+ QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
+ if( mbpeer == null )
+ {
+ mb.addNotify();
+ mbpeer = (QtMenuBarPeer)mb.getPeer();
+ if( mbpeer == null )
+ throw new IllegalStateException("No menu bar peer.");
+ }
+ mbpeer.addMenus();
+ setMenu( mbpeer );
+ }
+ else
+ setMenu( null );
+ }
+
+ public void setResizable(boolean resizeable)
+ {
+ // FIXME
+ }
+
+ public void setState(int s)
+ {
+ theState = s;
+ // FIXME
+ }
+
+ public void setBoundsPrivate(int x, int y, int width, int height)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateAlwaysOnTop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean requestWindowFocus()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Rectangle getBoundsPrivate()
+ {
+ // TODO: Implement this properly.
+ throw new InternalError("Not yet implemented");
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java
new file mode 100644
index 000000000..f68cc0dbd
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphics.java
@@ -0,0 +1,714 @@
+/* QtGraphics.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.AlphaComposite;
+import java.awt.AWTPermission;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.GradientPaint;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Rectangle;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ImageObserver;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.util.Map;
+
+/**
+ * QtGraphics is an abstract implementation of Graphics2D over a QPainter
+ * object. This is to be subclassed for different drawing contexts,
+ * which may have different requirements.
+ */
+public abstract class QtGraphics extends Graphics2D
+{
+ /**
+ * Native QPainter pointer.
+ */
+ protected long nativeObject;
+
+ private static final AffineTransform identity = new AffineTransform();
+
+ // Graphics state
+ protected Font font; // Current font.
+ protected Color color, bgcolor; // Current color and background color.
+ protected Shape clip; // Current clipping area.
+ protected Shape initialClip; // Initial clip bounds
+ protected AffineTransform xform; // Current transform
+ protected Stroke currentStroke; // the current stroke
+ protected boolean nativeStroking; // whether we're using Qt's stroking or not
+ protected Composite composite; // current composite operator
+ protected double currentAlpha; // current alpha
+ protected Paint currentPaint; // current paint
+ protected RenderingHints renderingHints; // the rendering hints.
+
+ /**
+ * Owner Graphics, used by subcontext created by create()
+ * to avoid GC of the original context.
+ */
+ Graphics parent;
+
+ /**
+ * Do-nothing constructor.
+ */
+ QtGraphics()
+ {
+ }
+
+ /**
+ * Copying constructor - used by copy() and subclasses.
+ */
+ QtGraphics(QtGraphics parent)
+ {
+ cloneNativeContext( parent );
+ setFont( parent.getFont() );
+ setAlpha( parent.currentAlpha );
+ setBackground( parent.getBackground() );
+ setColor( parent.getColor() );
+ setClip( (initialClip = parent.getClip()) );
+ setTransform( parent.getTransform() );
+ setStroke( parent.getStroke() );
+ setComposite( parent.getComposite() );
+ setPaint( parent.getPaint() );
+ setRenderingHints( parent.getRenderingHints() );
+ }
+
+ /**
+ * Set up some generic defaults.
+ */
+ protected void setup()
+ {
+ font = new Font ("Dialog", Font.PLAIN, 12);
+ setTransform( identity );
+ setStroke( new BasicStroke() );
+ renderingHints = new RenderingHints( null );
+ }
+
+ public synchronized native void delete();
+
+ public void dispose()
+ {
+ }
+
+ // ********************** etc *******************************
+
+ private void resetClip()
+ {
+ AffineTransform current = getTransform();
+ setTransform( identity );
+ setClip( initialClip );
+ setTransform( current );
+ }
+
+ protected native void initImage(QtImage image);
+ protected native void initVolatileImage(QtVolatileImage image);
+
+ // Creates a new native QPainter object on the same context.
+ private native void cloneNativeContext( QtGraphics parent );
+ private native void setColor(int r, int g, int b, int a);
+ private native void drawNative( QPainterPath p );
+ private native void fillNative( QPainterPath p );
+ private native void setClipNative( QPainterPath p );
+ private native void setClipRectNative( int x, int y, int w, int h );
+ private native void intersectClipNative( QPainterPath p );
+ private native void intersectClipRectNative( int x, int y, int w, int h );
+ private native void setQtTransform(QMatrix m);
+ private native void setNativeStroke(QPen p);
+ private native void setNativeComposite(int alphaMode);
+ private native void drawStringNative(String string, double x, double y);
+ private native void setLinearGradient(int r1, int g1, int b1,
+ int r2, int g2, int b2,
+ double x1, double y1,
+ double x2, double y2, boolean cyclic);
+ private native void setAlphaNative(double alpha);
+ private native void setFontNative(QtFontPeer font);
+ private native QPainterPath getClipNative();
+
+ void setAlpha(double alpha)
+ {
+ currentAlpha = alpha;
+ setAlphaNative(currentAlpha);
+ }
+
+ // ************ Public methods *********************
+
+ /**
+ * Context-sensitive methods are declared abstract.
+ */
+ public abstract Graphics create();
+
+ public abstract void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ public abstract GraphicsConfiguration getDeviceConfiguration();
+
+
+ public Color getColor()
+ {
+ return new Color(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
+ public void setColor(Color c)
+ {
+ if( c == null )
+ c = Color.white;
+ this.color = c;
+ int alpha = (int)(c.getAlpha() * currentAlpha);
+ setColor(c.getRed(), c.getGreen(), c.getBlue(), alpha);
+ }
+
+ public void setBackground(Color color)
+ {
+ bgcolor = new Color(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
+ public Color getBackground()
+ {
+ return new Color(bgcolor.getRed(), bgcolor.getGreen(), bgcolor.getBlue());
+ }
+
+ public void setPaintMode()
+ {
+ }
+
+ public void setXORMode(Color color)
+ {
+ // FIXME
+ }
+
+ public boolean hit(Rectangle rect, Shape s, boolean onStroke)
+ {
+ if( onStroke )
+ {
+ Shape stroked = currentStroke.createStrokedShape( s );
+ return stroked.intersects( (double)rect.x, (double)rect.y,
+ (double)rect.width, (double)rect.height );
+ }
+ return s.intersects( (double)rect.x, (double)rect.y,
+ (double)rect.width, (double)rect.height );
+ }
+
+ // ******************* Font ***********************
+ public Font getFont()
+ {
+ return font;
+ }
+
+ public void setFont(Font font)
+ {
+ if( font == null )
+ return;
+ this.font = font;
+ if(font.getPeer() != null && font.getPeer() instanceof QtFontPeer)
+ setFontNative( (QtFontPeer)font.getPeer() );
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics(font, this);
+ }
+
+ // ***************** Clipping *********************
+
+ /**
+ * Intersects the current clip with the shape
+ */
+ public void clip(Shape s)
+ {
+ intersectClipNative( new QPainterPath( s ) );
+ }
+
+ public void clipRect(int x, int y, int width, int height)
+ {
+ intersectClipRectNative( x, y, width, height );
+ }
+
+ public void setClip(int x, int y, int width, int height)
+ {
+ setClipRectNative( x, y, width, height );
+ }
+
+ public Shape getClip()
+ {
+ return getClipNative().getPath();
+ }
+
+ public native Rectangle getClipBounds();
+
+ /**
+ * Sets the clip
+ */
+ public void setClip(Shape clip)
+ {
+ if (clip == null)
+ resetClip();
+ else
+ setClipNative(new QPainterPath( clip ));
+ }
+
+ // ***************** Drawing primitives *********************
+
+ public void draw(Shape s)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath(s) );
+ else
+ fillNative( new QPainterPath( currentStroke.createStrokedShape( s ) ) );
+ }
+
+ public void fill(Shape s)
+ {
+ fillNative( new QPainterPath(s) );
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath((double)x1, (double)y1, (double)x2, (double)y2, true) );
+ else
+ draw( new Line2D.Double((double)x1, (double)y1, (double)x2, (double)y2) );
+ }
+
+ public void drawRect(int x, int y, int width, int height)
+ {
+ if( nativeStroking )
+ drawNative( new QPainterPath((double)x, (double)y,
+ (double)width, (double)height) );
+ else
+ fillNative( new QPainterPath
+ ( currentStroke.createStrokedShape
+ (new Rectangle2D.Double
+ ((double)x, (double)y,
+ (double)width, (double)height) ) ) );
+ }
+
+ public void fillRect(int x, int y, int width, int height)
+ {
+ fillNative( new QPainterPath( x, y, width, height ) );
+ }
+
+ public void clearRect(int x, int y, int width, int height)
+ {
+ Color c = color;
+ setColor( bgcolor ); // FIXME
+ fillRect( x, y, width, height );
+ setColor( c );
+ }
+
+ public void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ draw( new RoundRectangle2D.Double(x, y, width, height,
+ arcWidth, arcHeight) );
+ }
+
+ public void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ fill( new RoundRectangle2D.Double(x, y, width, height,
+ arcWidth, arcHeight) );
+ }
+
+ public void drawOval(int x, int y, int width, int height)
+ {
+ draw( new Ellipse2D.Double((double)x, (double)y,
+ (double)width, (double)height) );
+ }
+
+ public void fillOval(int x, int y, int width, int height)
+ {
+ fill( new Ellipse2D.Double(x, y, width, height) );
+ }
+
+ public void drawArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle)
+ {
+ draw( new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
+ Arc2D.OPEN) );
+ }
+
+ public void fillArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle)
+ {
+ fill( new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
+ Arc2D.CHORD) );
+ }
+
+ public void drawPolyline(int xPoints[], int yPoints[], int npoints)
+ {
+ for( int i = 0; i < npoints - 1; i++)
+ drawLine(xPoints[i], yPoints[i], xPoints[i + 1], yPoints[i + 1]);
+ }
+
+ public void drawPolygon(int xPoints[], int yPoints[], int npoints)
+ {
+ draw( new Polygon(xPoints, yPoints, npoints) );
+ }
+
+ public void fillPolygon(int xPoints[], int yPoints[], int npoints)
+ {
+ fill( new Polygon(xPoints, yPoints, npoints) );
+ }
+
+ public native void fill3DRect(int x, int y, int width, int height, boolean raised);
+
+ public native void draw3DRect(int x, int y, int width, int height, boolean raised);
+
+ // *********************** Text rendering *************************
+
+ public void drawString(String string, int x, int y)
+ {
+ drawStringNative(string, (double)x, (double)y);
+ }
+
+ public void drawString(String string, float x, float y)
+ {
+ drawStringNative(string, (double)x, (double)y);
+ }
+
+ public void drawString (AttributedCharacterIterator ci, int x, int y)
+ {
+ // FIXME - to something more correct ?
+ String s = "";
+ for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
+ s += c;
+ drawString(s, x, y);
+ }
+
+ public void drawString(AttributedCharacterIterator ci,
+ float x, float y)
+ {
+ // FIXME - to something more correct ?
+ String s = "";
+ for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
+ s += c;
+ drawString(s, x, y);
+ }
+
+ public void drawGlyphVector(GlyphVector v, float x, float y)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ // ******************* Image drawing ******************************
+ public boolean drawImage(Image image,
+ AffineTransform Tx,
+ ImageObserver obs)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage(this, new QMatrix( Tx ), obs);
+
+ return (new QtImage(image.getSource())).drawImage(this,
+ new QMatrix( Tx ),
+ obs);
+ }
+
+ public boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage (this, x, y, bgcolor, observer);
+ return (new QtImage(image.getSource())).drawImage (this, x, y,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage(this, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, bgcolor, observer);
+
+ return (new QtImage(image.getSource())).drawImage(this, dx1, dy1,
+ dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ int width, int height, Color bgcolor,
+ ImageObserver observer)
+ {
+ if (image instanceof QtImage)
+ return ((QtImage)image).drawImage (this, x, y, width, height,
+ bgcolor, observer);
+ return (new QtImage(image.getSource())).drawImage (this, x, y,
+ width, height,
+ bgcolor, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y, int width, int height,
+ ImageObserver observer)
+ {
+ return drawImage(image, x, y, width, height, null, observer);
+ }
+
+ public boolean drawImage(Image image, int x, int y, ImageObserver observer)
+ {
+ return drawImage(image, x, y, null, observer);
+ }
+
+ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
+ {
+ return drawImage(image, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, null, observer);
+ }
+
+ // *********************** Transform methods *************************
+ public AffineTransform getTransform()
+ {
+ return new AffineTransform( xform );
+ }
+
+ public void setTransform(AffineTransform Tx)
+ {
+ xform = new AffineTransform( Tx );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void rotate(double theta)
+ {
+ xform.rotate( theta );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void rotate(double theta, double x, double y)
+ {
+ xform.rotate(theta, x, y);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void scale(double sx, double sy)
+ {
+ xform.scale(sx, sy);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void shear(double shx, double shy)
+ {
+ xform.shear(shx, shy);
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void transform(AffineTransform Tx)
+ {
+ xform.concatenate( Tx );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void translate(double tx, double ty)
+ {
+ xform.translate( tx, ty );
+ setQtTransform( new QMatrix( xform ) );
+ }
+
+ public void translate(int x, int y)
+ {
+ translate((double)x, (double)y);
+ }
+
+ // *************** Stroking, Filling, Compositing *****************
+ public void setStroke(Stroke s)
+ {
+ try // ..to convert the stroke into a native one.
+ {
+ QPen pen = new QPen( s );
+ nativeStroking = true;
+ setNativeStroke( pen );
+ setColor( color );
+ }
+ catch (IllegalArgumentException e)
+ {
+ nativeStroking = false;
+ }
+ currentStroke = s;
+ }
+
+ public Stroke getStroke()
+ { // FIXME: return copy?
+ return currentStroke;
+ }
+
+ public void setComposite(Composite comp)
+ {
+ if( comp == null)
+ {
+ setNativeComposite( AlphaComposite.SRC_OVER );
+ return;
+ }
+
+ if( comp instanceof AlphaComposite )
+ {
+ if( ((AlphaComposite)comp).getRule() != AlphaComposite.XOR )
+ setAlpha( ((AlphaComposite)comp).getAlpha() );
+ setNativeComposite( ((AlphaComposite)comp).getRule() );
+ composite = comp;
+ }
+ else
+ {
+ // FIXME: this check is only required "if this Graphics2D
+ // context is drawing to a Component on the display screen".
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new AWTPermission("readDisplayPixels"));
+
+ throw new UnsupportedOperationException("We don't support custom"+
+ " composites yet.");
+ }
+ }
+
+ public Composite getComposite()
+ {
+ return composite;
+ }
+
+ public void setPaint(Paint p)
+ {
+ if( p == null )
+ return;
+
+ // FIXME
+ currentPaint = p;
+ if( p instanceof GradientPaint )
+ {
+ GradientPaint lg = (GradientPaint)p;
+ setLinearGradient(lg.getColor1().getRed(), lg.getColor1().getGreen(),
+ lg.getColor1().getBlue(), lg.getColor2().getRed(),
+ lg.getColor2().getGreen(), lg.getColor2().getBlue(),
+ lg.getPoint1().getX(), lg.getPoint1().getY(),
+ lg.getPoint2().getX(), lg.getPoint2().getY(),
+ lg.isCyclic() );
+ return;
+ }
+ if( p instanceof Color )
+ {
+ setColor((Color) p);
+ return;
+ }
+ throw new UnsupportedOperationException("We don't support custom"+
+ " paints yet.");
+ }
+
+ public Paint getPaint()
+ {
+ // FIXME
+ return currentPaint;
+ }
+
+ // ********************** Rendering Hints *************************
+
+ public void addRenderingHints(Map hints)
+ {
+ renderingHints.putAll( hints );
+ }
+
+ public Object getRenderingHint(RenderingHints.Key hintKey)
+ {
+ return renderingHints.get( hintKey );
+ }
+
+ public RenderingHints getRenderingHints()
+ {
+ return (RenderingHints) renderingHints.clone();
+ }
+
+ public void setRenderingHints(Map<?,?> hints)
+ {
+ renderingHints = new RenderingHints( null );
+ renderingHints.putAll(hints);
+ updateRenderingHints();
+ }
+
+ public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
+ {
+ renderingHints.put( hintKey, hintValue );
+ updateRenderingHints();
+ }
+
+ private void updateRenderingHints()
+ {
+ // FIXME - update native settings.
+ }
+
+ ////////////////////////////// unimplemented /////////////////////
+
+ public FontRenderContext getFontRenderContext()
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawRenderableImage(RenderableImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
+ public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
new file mode 100644
index 000000000..dec4db2c8
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtGraphicsEnvironment.java
@@ -0,0 +1,105 @@
+/* QtGraphicsEnvironment.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.util.Locale;
+
+public class QtGraphicsEnvironment extends GraphicsEnvironment
+{
+ QtToolkit toolkit;
+ GraphicsDevice[] screens;
+
+ public QtGraphicsEnvironment (QtToolkit tk)
+ {
+ super();
+ toolkit = tk;
+ // Get the number of screens from Qt.
+ int n = toolkit.numScreens();
+
+ /**
+ * Create the screen device objects
+ */
+ screens = new GraphicsDevice[ n ];
+ for(int i = 0; i < n; i++)
+ screens[ i ] = new QtScreenDevice( i );
+ }
+
+ public Font[] getAllFonts ()
+ {
+ String[] fonts = getAvailableFontFamilyNames();
+ Font[] fontObjs = new Font[fonts.length];
+ for( int i = 0; i < fonts.length; i++)
+ fontObjs[i] = new Font(fonts[i], Font.PLAIN, 12);
+ return fontObjs;
+ }
+
+ public String[] getAvailableFontFamilyNames()
+ {
+ return toolkit.getFontList();
+ }
+
+ public String[] getAvailableFontFamilyNames(Locale l)
+ {
+ return getAvailableFontFamilyNames();
+ }
+
+ public GraphicsDevice getDefaultScreenDevice ()
+ {
+ return screens[ toolkit.defaultScreen() ];
+ }
+
+ public Graphics2D createGraphics (BufferedImage image)
+ {
+ return (Graphics2D)image.getGraphics();
+ }
+
+ public GraphicsDevice[] getScreenDevices()
+ {
+ return screens;
+ }
+
+ public QtToolkit getToolkit()
+ {
+ return toolkit;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java
new file mode 100644
index 000000000..b7e50ea25
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImage.java
@@ -0,0 +1,641 @@
+/* QtImage.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Graphics;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.MemoryImageSource;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.io.File;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedInputStream;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.WeakHashMap;
+import java.util.Vector;
+
+/**
+ * QtImage - wraps a QImage
+ *
+ */
+public class QtImage extends Image
+{
+ int width = -1, height = -1;
+
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Loaded or not flag, for asynchronous compatibility.
+ */
+ boolean isLoaded;
+
+ /**
+ * Pointer to the QImage
+ */
+ long nativeObject;
+
+ /**
+ * Observer queue.
+ */
+ Vector observers;
+
+ /**
+ * Error flag for loading.
+ */
+ boolean errorLoading;
+
+ /**
+ * Original source, if created from an ImageProducer.
+ */
+ ImageProducer source;
+
+ /*
+ * The 32-bit AARRGGBB format the uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ /**
+ * HashMap of Graphics objects painting on this Image.
+ */
+ WeakHashMap painters;
+
+ /**
+ * Flags if this image is to be destroyed.
+ */
+ boolean killFlag;
+
+ /**
+ * Clears the image to RGBA 0
+ */
+ public native void clear();
+
+ /**
+ * Returns a copy of the pixel data as a java array.
+ */
+ private native int[] getPixels();
+
+ /**
+ * Sets the pixel data from a java array.
+ */
+ private native void setPixels(int[] pixels);
+
+ /**
+ * Loads an image
+ */
+ private native boolean loadImage(String name);
+
+ /**
+ * Loads an image from data.
+ */
+ private native boolean loadImageFromData(byte[] data);
+
+ /**
+ * Allocates a QImage
+ */
+ private native void createImage();
+
+ /**
+ * Frees the above.
+ */
+ private synchronized native void freeImage();
+
+ /**
+ * Sets the image to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledImage(QtImage src, int hints);
+
+ /**
+ * Draws the image optionally composited.
+ */
+ native void drawPixels (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y,
+ boolean composite);
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image transformed.
+ */
+ private native void drawPixelsTransformed (QtGraphics gc, QMatrix transform);
+
+ /**
+ * Draws the image scaled flipped and optionally composited.
+ */
+ native void drawPixelsScaledFlipped (QtGraphics gc,
+ int bg_red, int bg_green,
+ int bg_blue,
+ boolean flipX, boolean flipY,
+ int srcX, int srcY,
+ int srcWidth, int srcHeight,
+ int dstX, int dstY,
+ int dstWidth, int dstHeight,
+ boolean composite);
+
+ /**
+ * Creates the image from an ImageProducer. May result in an error image.
+ */
+ public QtImage (ImageProducer producer)
+ {
+ killFlag = false;
+ isLoaded = false;
+ observers = new Vector();
+ source = producer;
+ errorLoading = false;
+ if( producer != null )
+ source.startProduction(new QtImageConsumer(this, source));
+ }
+
+ /**
+ * Creates the image from a URL. May result in an error image.
+ */
+ public QtImage (URL url)
+ {
+ killFlag = false;
+ isLoaded = false;
+ observers = new Vector();
+ errorLoading = false;
+ if( url == null)
+ return;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream( 5000 );
+ try
+ {
+ BufferedInputStream bis = new BufferedInputStream(url.openStream());
+
+ byte[] buf = new byte[5000];
+ int n = 0;
+
+ while ( (n = bis.read( buf )) != -1 )
+ baos.write(buf, 0, n);
+ bis.close();
+ }
+ catch(IOException e)
+ {
+ throw new IllegalArgumentException("Couldn't load image.");
+ }
+ if ( loadImageFromData( baos.toByteArray() ) != true )
+ throw new IllegalArgumentException("Couldn't load image.");
+
+ isLoaded = true;
+ observers = null;
+ props = new Hashtable();
+ }
+
+ /**
+ * Constructs a QtImage by loading a given file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public QtImage (String filename)
+ {
+ killFlag = false;
+ File f = new File(filename);
+ observers = null;
+ props = new Hashtable();
+ try
+ {
+ String fn = f.getCanonicalPath();
+ if (loadImage( fn ) != true)
+ {
+ errorLoading = true;
+ isLoaded = false;
+ return;
+ }
+ }
+ catch(IOException e)
+ {
+ errorLoading = true;
+ isLoaded = false;
+ return;
+ }
+ errorLoading = false;
+ isLoaded = true;
+ }
+
+ /**
+ * Constructs a QtImage from a byte array of an image file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public QtImage (byte[] data)
+ {
+ if (loadImageFromData(data) != true)
+ throw new IllegalArgumentException("Couldn't load image.");
+
+ killFlag = false;
+ isLoaded = true;
+ observers = null;
+ errorLoading = false;
+ props = new Hashtable();
+ }
+
+ /**
+ * Constructs an empty QtImage.
+ */
+ public QtImage (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ killFlag = false;
+ observers = null;
+ errorLoading = false;
+ createImage();
+ clear();
+ }
+
+ /**
+ * Constructs a scaled version of the src bitmap, using Qt
+ */
+ private QtImage (QtImage src, int width, int height, int hints)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ killFlag = false;
+ observers = null;
+ errorLoading = false;
+
+ createScaledImage(src, hints);
+ }
+
+ /**
+ * Callback from the image consumer.
+ */
+ public void setImage(int width, int height,
+ int[] pixels, Hashtable properties)
+ {
+ this.width = width;
+ this.height = height;
+ props = (properties != null) ? properties : new Hashtable();
+
+ if (width <= 0 || height <= 0 || pixels == null)
+ {
+ errorLoading = true;
+ return;
+ }
+
+ isLoaded = true;
+ deliver();
+ createImage();
+ setPixels(pixels);
+ }
+
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public int getWidth (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return -1;
+
+ return width;
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return -1;
+
+ return height;
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return UndefinedProperty;
+
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
+ {
+ if (!isLoaded)
+ return null;
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
+ }
+
+ void putPainter(QtImageGraphics g)
+ {
+ if( painters == null )
+ painters = new WeakHashMap();
+ painters.put( g, "dummy" );
+ }
+
+ void removePainter(QtImageGraphics g)
+ {
+ painters.remove( g );
+ if( killFlag && painters.isEmpty() )
+ freeImage();
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ public Graphics getGraphics ()
+ {
+ if (!isLoaded || killFlag)
+ return null;
+
+ return new QtImageGraphics(this);
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ Graphics getDirectGraphics(QtComponentPeer peer)
+ {
+ if (!isLoaded)
+ return null;
+
+ return new QtImageDirectGraphics(this, peer);
+ }
+
+ /**
+ * Returns a scaled instance of this image.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
+
+ return new QtImage(this, width, height, hints);
+ }
+
+ /**
+ * If the image is loaded and comes from an ImageProducer,
+ * regenerate the image from there.
+ *
+ * I have no idea if this is ever actually used. Since QtImage can't be
+ * instantiated directly, how is the user to know if it was created from
+ * an ImageProducer or not?
+ */
+ public synchronized void flush ()
+ {
+ if (isLoaded && source != null)
+ {
+ observers = new Vector();
+ isLoaded = false;
+ freeImage();
+ source.startProduction(new QtImageConsumer(this, source));
+ }
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void dispose()
+ {
+ if (isLoaded)
+ {
+ if( painters == null || painters.isEmpty() )
+ freeImage();
+ else
+ killFlag = true; // can't destroy image yet.
+ // Do so when all painters are gone.
+ }
+ }
+
+ /**
+ * Returns the image status, used by QtToolkit
+ */
+ public int checkImage (ImageObserver observer)
+ {
+ if (addObserver(observer))
+ {
+ if (errorLoading == true)
+ return ImageObserver.ERROR;
+ else
+ return 0;
+ }
+
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
+ }
+
+ // Drawing methods ////////////////////////////////////////////////
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, QMatrix matrix,
+ ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ drawPixelsTransformed (g, matrix);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) with optional
+ * compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ if(bgcolor != null)
+ drawPixels(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, true);
+ else
+ drawPixels(g, 0, 0, 0, x, y, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ if(bgcolor != null)
+ drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, width, height, true);
+ else
+ drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ boolean flipX = (dx1 > dx2)^(sx1 > sx2);
+ boolean flipY = (dy1 > dy2)^(sy1 > sy2);
+ int dstWidth = Math.abs (dx2 - dx1);
+ int dstHeight = Math.abs (dy2 - dy1);
+ int srcWidth = Math.abs (sx2 - sx1);
+ int srcHeight = Math.abs (sy2 - sy1);
+ int srcX = (sx1 < sx2) ? sx1 : sx2;
+ int srcY = (sy1 < sy2) ? sy1 : sy2;
+ int dstX = (dx1 < dx2) ? dx1 : dx2;
+ int dstY = (dy1 < dy2) ? dy1 : dy2;
+
+ // Clipping. This requires the dst to be scaled as well,
+ if (srcWidth > width)
+ {
+ dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight > height)
+ {
+ dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
+ srcHeight = height - srcY;
+ }
+
+ if (srcWidth + srcX > width)
+ {
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight + srcY > height)
+ {
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
+ }
+
+ if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
+ return true;
+
+ if(bgcolor != null)
+ drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (),
+ flipX, flipY,
+ srcX, srcY,
+ srcWidth, srcHeight,
+ dstX, dstY,
+ dstWidth, dstHeight,
+ true);
+ else
+ drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY,
+ srcX, srcY, srcWidth, srcHeight,
+ dstX, dstY, dstWidth, dstHeight,
+ false);
+ return true;
+ }
+
+ public native void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ // Private methods ////////////////////////////////////////////////
+
+ /**
+ * Delivers notifications to all queued observers.
+ */
+ private void deliver()
+ {
+ int flags = ImageObserver.HEIGHT |
+ ImageObserver.WIDTH |
+ ImageObserver.PROPERTIES |
+ ImageObserver.ALLBITS;
+
+ if (observers != null)
+ for(int i=0; i < observers.size(); i++)
+ ((ImageObserver)observers.elementAt(i)).
+ imageUpdate(this, flags, 0, 0, width, height);
+
+ observers = null;
+ }
+
+ /**
+ * Adds an observer, if we need to.
+ * @return true if an observer was added.
+ */
+ private boolean addObserver(ImageObserver observer)
+ {
+ if (!isLoaded)
+ {
+ if(observer != null)
+ if (!observers.contains (observer))
+ observers.addElement (observer);
+ return true;
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return "QtImage [isLoaded="+isLoaded+", width="+width+", height="+height
+ +"]";
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java
new file mode 100644
index 000000000..9883475f9
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImageConsumer.java
@@ -0,0 +1,147 @@
+/* QtImageConsumer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.image.ColorModel;
+import java.awt.image.ImageConsumer;
+import java.awt.image.ImageProducer;
+import java.util.Hashtable;
+
+/**
+ * Helper class to QtImage. Sits and gathers pixels for a QtImage and then
+ * calls QtImage.setImage().
+ *
+ * @author Sven de Marothy
+ */
+public class QtImageConsumer implements ImageConsumer
+{
+ private QtImage target;
+ private int width, height;
+ private Hashtable properties;
+ private int[] pixelCache = null;
+ private ImageProducer source;
+
+ public QtImageConsumer(QtImage target, ImageProducer source)
+ {
+ this.target = target;
+ this.source = source;
+ }
+
+ public synchronized void imageComplete (int status)
+ {
+ source.removeConsumer(this);
+ target.setImage(width, height, pixelCache, properties);
+ }
+
+ public synchronized void setColorModel (ColorModel model)
+ {
+ // This method is to inform on what the most used color model
+ // in the image is, for optimization reasons. We ignore this
+ // information.
+ }
+
+ public synchronized void setDimensions (int width, int height)
+ {
+ pixelCache = new int[width*height];
+
+ this.width = width;
+ this.height = height;
+ }
+
+ public synchronized void setHints (int flags)
+ {
+ // This method informs us in which order the pixels are
+ // delivered, for progressive-loading support, etc.
+ // Since we wait until it's all loaded, we can ignore the hints.
+ }
+
+ 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)
+ {
+ if (pixelCache == null)
+ return; // Not sure this should ever happen.
+
+ if (cm.equals(QtImage.nativeModel))
+ for (int i = 0; i < height; i++)
+ System.arraycopy (pixels, offset + (i * scansize),
+ pixelCache, (y + i) * this.width + x,
+ width);
+ else
+ {
+ for (int i = 0; i < height; i++)
+ for (int j = 0; j < width; j++)
+ {
+ // get in AARRGGBB and convert to AABBGGRR
+ int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]);
+ byte b = (byte)(pix & 0xFF);
+ byte r = (byte)(((pix & 0x00FF0000) >> 16) & 0xFF);
+ pix &= 0xFF00FF00;
+ pix |= ((b & 0xFF) << 16);
+ pix |= (r & 0xFF);
+ pixelCache[(y + i) * this.width + x + j] = pix;
+ }
+ }
+ }
+
+ /**
+ * This is an old method, no idea if it's correct.
+ */
+ private int[] convertPixels (byte[] pixels)
+ {
+ int ret[] = new int[pixels.length];
+
+ for (int i = 0; i < pixels.length; i++)
+ ret[i] = pixels[i] & 0xFF;
+
+ return ret;
+ }
+
+ public synchronized void setProperties (Hashtable props)
+ {
+ this.properties = props;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java
new file mode 100644
index 000000000..daa174ad4
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImageDirectGraphics.java
@@ -0,0 +1,145 @@
+/* QtImageDirectGraphics.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.image.ImageObserver;
+
+/**
+ * A QtImagePainter that does an update after every drawing op.
+ */
+public class QtImageDirectGraphics extends QtImageGraphics
+{
+ private QtComponentPeer peer;
+ private boolean modified;
+
+ public QtImageDirectGraphics(QtImage image, QtComponentPeer peer)
+ {
+ super( image );
+ this.peer = peer;
+ modified = false;
+ }
+
+ public QtImageDirectGraphics(QtImageGraphics g)
+ {
+ super( g );
+ }
+
+ private void scheduleUpdate()
+ {
+ }
+
+ public void dispose()
+ {
+ super.dispose();
+ peer.toolkit.sync();
+ peer.QtUpdate();
+ }
+
+ public void draw(Shape s)
+ {
+ super.draw(s);
+ scheduleUpdate();
+ }
+
+ public void fill(Shape s)
+ {
+ super.fill(s);
+ scheduleUpdate();
+ }
+
+ public void drawString(String string, int x, int y)
+ {
+ super.drawString( string, x, y );
+ scheduleUpdate();
+ }
+
+ public void drawString(String string, float x, float y)
+ {
+ super.drawString( string, x, y );
+ scheduleUpdate();
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ super.drawLine(x1, y1, x2, y2);
+ scheduleUpdate();
+ }
+
+ public boolean drawImage(Image image,
+ AffineTransform Tx,
+ ImageObserver obs)
+ {
+ boolean r = super.drawImage(image, Tx, obs);
+ scheduleUpdate();
+ return r;
+ }
+
+ public boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ boolean r = super.drawImage(image, x, y, bgcolor, observer);
+ scheduleUpdate();
+ return r;
+ }
+
+ public boolean drawImage(Image image,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ boolean r = super.drawImage( image, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
+ scheduleUpdate();
+ return r;
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ int width, int height, Color bgcolor,
+ ImageObserver observer)
+ {
+ boolean r = super.drawImage(image, x, y, width, height, bgcolor,
+ observer);
+ scheduleUpdate();
+ return r;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java b/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java
new file mode 100644
index 000000000..bba25e068
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtImageGraphics.java
@@ -0,0 +1,139 @@
+/* QtImageGraphics.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Color;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.util.Stack;
+
+/**
+ * QtComponentPainter is a Graphics2D context for painting to QtImage and
+ * QtVolatileImages.
+ */
+public class QtImageGraphics extends QtGraphics
+{
+ Image parentImage;
+ Stack owners;
+ QtImageGraphics topParent;
+
+ public QtImageGraphics(Image image)
+ {
+ if(!( image instanceof QtVolatileImage || image instanceof QtImage))
+ throw new IllegalArgumentException("Cannot create QtImageGraphics for a non-QImage context.");
+
+ owners = new Stack();
+ owners.push(this);
+ topParent = null;
+ int w, h;
+ if(image instanceof QtImage)
+ {
+ w = ((QtImage)image).width;
+ h = ((QtImage)image).height;
+ initImage((QtImage) image );
+ ((QtImage)image).putPainter( this );
+ }
+ else
+ {
+ w = ((QtVolatileImage)image).width;
+ h = ((QtVolatileImage)image).height;
+ initVolatileImage((QtVolatileImage) image );
+ ((QtVolatileImage)image).putPainter( this );
+ }
+
+ parentImage = image;
+ initialClip = new Rectangle( 0, 0, w, h );
+ setClip( initialClip );
+ setBackground(Color.white); // fixme
+ currentAlpha = 1.0;
+ setColor(Color.black);
+ setup();
+ }
+
+ /**
+ * Copying constructor
+ */
+ QtImageGraphics( QtImageGraphics g )
+ {
+ super( g );
+ parentImage = g.parentImage;
+ if(parentImage instanceof QtImage)
+ ((QtImage)parentImage).putPainter( this );
+ else
+ ((QtVolatileImage)parentImage).putPainter( this );
+ }
+
+ public void dispose()
+ {
+ delete();
+ if( parentImage instanceof QtImage )
+ ((QtImage)parentImage).removePainter( this );
+ else
+ ((QtVolatileImage)parentImage).removePainter( this );
+ }
+
+ /**
+ * Create a copy of this context.
+ */
+ public Graphics create()
+ {
+ return new QtImageGraphics( this );
+ }
+
+ /**
+ * Copy an area.
+ */
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ if(parentImage instanceof QtImage)
+ ((QtImage)parentImage).copyArea(x, y, width, height, dx, dy);
+ else
+ ((QtVolatileImage)parentImage).copyArea(x, y, width, height, dx, dy);
+ }
+
+ /**
+ * Returns the GraphicsConfiguration of the context component.
+ */
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtLabelPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtLabelPeer.java
new file mode 100644
index 000000000..80acd491d
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtLabelPeer.java
@@ -0,0 +1,62 @@
+/* QtLabelPeer.java --
+ 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.peer.qt;
+
+import java.awt.Label;
+import java.awt.peer.LabelPeer;
+
+public class QtLabelPeer extends QtComponentPeer implements LabelPeer
+{
+ public QtLabelPeer( QtToolkit kit, Label owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText( ((Label)owner).getText() );
+ setAlignment( ((Label)owner).getAlignment() );
+ }
+
+ public native void setAlignment( int alignment );
+
+ public native void setText( String label );
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtListPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtListPeer.java
new file mode 100644
index 000000000..14ae2a0cd
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtListPeer.java
@@ -0,0 +1,188 @@
+/* QtListPeer.java --
+ 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.peer.qt;
+
+import java.awt.Dimension;
+import java.awt.List;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.peer.ListPeer;
+
+public class QtListPeer extends QtComponentPeer implements ListPeer
+{
+ public QtListPeer( QtToolkit kit, List owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ List o = (List)owner;
+ // Multiple selection
+ setMultipleMode(o.isMultipleMode());
+ // Add initial list items.
+ String[] items = o.getItems();
+ for (int i = 0; i < items.length; i++)
+ add(items[i], i);
+
+ // Initial selections.
+ int[] selected = o.getSelectedIndexes();
+ for (int i = 0; i < selected.length; i++)
+ select(selected[i]);
+
+ // If no initial selection, use 0.
+ if(selected.length == 0 && items.length > 0)
+ select( 0 );
+ }
+
+ private boolean ignoreNextSelect = false;
+
+ /**
+ * Called back when a row is selected. -1 if no row is selected.
+ */
+ private void fireChoice( int index )
+ {
+ ignoreNextSelect = true;
+ if( index == -1)
+ ((List)owner).deselect( ((List)owner).getSelectedIndex() );
+ else
+ {
+ ((List)owner).select( index );
+ ItemEvent e = new ItemEvent((List)owner,
+ ItemEvent.ITEM_STATE_CHANGED,
+ ""+index,
+ ItemEvent.SELECTED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+ }
+
+ /**
+ * Called back when an item is double-clicked.
+ */
+ private void itemDoubleClicked( int index, int modifiers )
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((List)owner).getItem( index ),
+ System.currentTimeMillis(),
+ modifiers);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ private native void select(int index, boolean selected);
+
+ // ************ Public methods *********************
+
+ public native void add(String item, int index);
+
+ public void addItem(String item, int index)
+ {
+ add(item, index);
+ }
+
+ public void clear()
+ {
+ removeAll();
+ }
+
+ /**
+ * Deletes items from the starting index to the ending index (inclusive).
+ */
+ public native void delItems(int start_index, int end_index);
+
+ public void deselect(int index)
+ {
+ if( ignoreNextSelect == true )
+ ignoreNextSelect = false;
+ else
+ select(index, false);
+ }
+
+ public native int[] getSelectedIndexes();
+
+ public native void makeVisible(int index);
+
+ public Dimension minimumSize(int s)
+ {
+ return getMinimumSize(s);
+ }
+
+ public Dimension preferredSize(int s)
+ {
+ return getPreferredSize(s);
+ }
+
+ public void removeAll()
+ {
+ delItems(0, ((List)owner).getItemCount() - 1);
+ }
+
+ public void select(int index)
+ {
+ if( ignoreNextSelect == true )
+ ignoreNextSelect = false;
+ else
+ select(index, true);
+ }
+
+ /**
+ * Sets multiple-selection mode.
+ * Note there's a bug in multiple selection in Qt 4.0.0, use 4.0.1.
+ */
+ public native void setMultipleMode(boolean multi);
+
+ public void setMultipleSelections(boolean multi)
+ {
+ setMultipleMode(multi);
+ }
+
+ public Dimension getPreferredSize(int s)
+ {
+ // FIXME
+ return getPreferredSize();
+ }
+
+ public Dimension getMinimumSize(int s)
+ {
+ // FIXME
+ return getMinimumSize();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java
new file mode 100644
index 000000000..962d76d41
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuBarPeer.java
@@ -0,0 +1,101 @@
+/* QtMenuBarPeer.java -- Qt peer for a menu bar.
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.peer.MenuBarPeer;
+
+public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
+{
+ public QtMenuBarPeer( QtToolkit kit, MenuBar owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ }
+
+ /**
+ * Recurses the menubar adding menus (and menu items),
+ * called from the Frame peer.
+ */
+ void addMenus()
+ {
+ MenuBar o = (MenuBar)owner;
+ int help = (o.getHelpMenu() != null) ? 1 : 0;
+ for (int i = 0; i < o.getMenuCount() - help; i++)
+ addMenu( o.getMenu(i) );
+ if(o.getHelpMenu() != null)
+ addHelpMenu( o.getHelpMenu() );
+ }
+
+ private native void addMenu( QtMenuPeer mp );
+
+ private native void addHelpMenu( QtMenuPeer mp );
+
+ private native void delMenu( QtMenuPeer mp );
+
+ // ************ Public methods *********************
+
+ public void addMenu( Menu m )
+ {
+ if (m.getPeer() == null)
+ m.addNotify();
+ ((QtMenuPeer)m.getPeer()).addItems();
+ addMenu( (QtMenuPeer)m.getPeer() );
+ }
+
+ public void addHelpMenu( Menu m )
+ {
+ if (m.getPeer() == null)
+ m.addNotify();
+ ((QtMenuPeer)m.getPeer()).addItems();
+ addHelpMenu( (QtMenuPeer)m.getPeer() );
+ }
+
+ public void delMenu( int index )
+ {
+ Menu m = ((MenuBar)owner).getMenu( index );
+ if(m != null)
+ delMenu( (QtMenuPeer)m.getPeer() );
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuComponentPeer.java
new file mode 100644
index 000000000..2050bef06
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuComponentPeer.java
@@ -0,0 +1,94 @@
+/* QtMenuComponentPeer.java --
+ 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.peer.qt;
+
+import java.awt.Font;
+import java.awt.MenuComponent;
+import java.awt.peer.MenuComponentPeer;
+
+public class QtMenuComponentPeer extends NativeWrapper
+ implements MenuComponentPeer
+{
+ protected QtToolkit toolkit;
+ protected MenuComponent owner;
+
+ public QtMenuComponentPeer( QtToolkit kit, MenuComponent owner )
+ {
+ this.toolkit = kit;
+ this.owner = owner;
+ nativeObject = 0;
+ synchronized(this)
+ {
+ callInit(); // Calls the init method FROM THE MAIN THREAD.
+ try
+ {
+ wait(); // Wait for the thing to be created.
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ setup();
+ }
+
+ protected native void callInit();
+
+ protected void init()
+ {
+ }
+
+ protected void setup()
+ {
+ }
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ // ************ Public methods *********************
+
+ public native void dispose();
+
+ public void setFont(Font font)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java
new file mode 100644
index 000000000..2b77540a5
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuItemPeer.java
@@ -0,0 +1,100 @@
+/* QtMenuItemPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.MenuItem;
+import java.awt.CheckboxMenuItem;
+import java.awt.event.ActionEvent;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+
+public class QtMenuItemPeer extends QtMenuComponentPeer
+ implements MenuItemPeer, CheckboxMenuItemPeer
+{
+ public QtMenuItemPeer( QtToolkit toolkit, MenuItem owner )
+ {
+ super(toolkit, owner);
+ }
+
+ protected void init()
+ {
+ String label = ((MenuItem)owner).getLabel();
+ create(label, label.equals("-"), (owner instanceof CheckboxMenuItem));
+ }
+
+ protected void setup()
+ {
+ }
+
+ private native void create(String label, boolean isSeperator, boolean isCheckable);
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public native void dispose();
+
+ private void fireClick(int modifiers)
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((MenuItem)owner).getActionCommand(),
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF));
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public native void setEnabled(boolean b);
+
+ public native void setLabel(String label);
+
+ public native void setState(boolean state);
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtMenuPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuPeer.java
new file mode 100644
index 000000000..0f65fecbd
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtMenuPeer.java
@@ -0,0 +1,149 @@
+/* QtMenuPeer.java --
+ 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.peer.qt;
+
+import java.awt.Menu;
+import java.awt.MenuItem;
+import java.awt.PopupMenu;
+import java.awt.event.ActionEvent;
+import java.awt.peer.MenuPeer;
+import java.util.Vector;
+
+public class QtMenuPeer extends QtMenuComponentPeer implements MenuPeer
+{
+ Vector items;
+ boolean itemsAdded;
+
+ public QtMenuPeer( QtToolkit kit, Menu owner )
+ {
+ super( kit, owner );
+ itemsAdded = false;
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ items = new Vector();
+ setLabel( ((Menu)owner).getLabel() );
+ if( ((Menu)owner).isTearOff() )
+ allowTearOff();
+ }
+
+ // Recurse the menu tree adding items,
+ // called from the MenuBar addMenus() method, called from the Frame peer.
+ void addItems()
+ {
+ if(!itemsAdded)
+ {
+ Menu o = (Menu)owner;
+ for( int i=0; i < o.getItemCount(); i++ )
+ {
+ MenuItem ci = o.getItem(i);
+ if (ci instanceof Menu && ci.getPeer() != null)
+ ((QtMenuPeer)ci.getPeer()).addItems();
+ addItem( ci );
+ }
+ itemsAdded = true;
+ }
+ }
+
+ private void fireClick()
+ {
+ ActionEvent e = new ActionEvent(owner,
+ ActionEvent.ACTION_PERFORMED,
+ ((Menu)owner).getActionCommand());
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ private native void allowTearOff();
+
+ private native void insertSeperator();
+
+ private native void insertItem(QtMenuItemPeer p);
+
+ private native void insertMenu(QtMenuPeer menu);
+
+ private native void delItem(long ptr);
+
+ private void add(long ptr)
+ {
+ items.add(new Long(ptr));
+ }
+
+ // ************ Public methods *********************
+
+ public void addItem( MenuItem item )
+ {
+ if( item instanceof Menu || item instanceof PopupMenu)
+ insertMenu((QtMenuPeer)item.getPeer());
+ else
+ {
+ QtMenuItemPeer p = (QtMenuItemPeer)item.getPeer();
+ insertItem(p);
+ }
+ }
+
+ public void addSeparator()
+ {
+ insertSeperator();
+ }
+
+ public void delItem( int index )
+ {
+ long ptr = ((Long)items.elementAt(index)).longValue();
+ delItem(ptr);
+ items.removeElementAt(index);
+ }
+
+ // Inherited methods..
+
+ public void disable()
+ {
+ setEnabled(false);
+ }
+
+ public void enable()
+ {
+ setEnabled(true);
+ }
+
+ public native void setEnabled(boolean enabled);
+
+ public native void setLabel(String text);
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtPanelPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtPanelPeer.java
new file mode 100644
index 000000000..1ac0ca9a6
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtPanelPeer.java
@@ -0,0 +1,56 @@
+/* QtPanelPeer.java --
+ 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.peer.qt;
+
+import java.awt.Component;
+import java.awt.peer.PanelPeer;
+
+public class QtPanelPeer extends QtContainerPeer implements PanelPeer
+{
+ public QtPanelPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
new file mode 100644
index 000000000..eb4dae404
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtPopupMenuPeer.java
@@ -0,0 +1,76 @@
+/* QtPopupMenuPeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.Event;
+import java.awt.peer.PopupMenuPeer;
+
+public class QtPopupMenuPeer extends QtMenuPeer implements PopupMenuPeer
+{
+ public QtPopupMenuPeer( QtToolkit kit, PopupMenu owner )
+ {
+ super( kit, owner );
+ }
+
+ private native void showNative(int x, int y);
+
+ // ************ Public methods *********************
+
+ /**
+ * Part of the older API, replaced by event version instead.
+ */
+ public void show (Component origin, int x, int y)
+ {
+ if( origin == null )
+ throw new NullPointerException("Null parent component.");
+ addItems();
+
+ Point p = origin.getLocationOnScreen();
+ showNative( (int)p.getX() + x, (int)p.getY() + y );
+ }
+
+ public void show (Event e)
+ {
+ if (!(e.target instanceof Component))
+ throw new IllegalArgumentException("Expecting a component Event target!");
+ show((Component)e.target, e.x, e.y);
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtRepaintThread.java b/libjava/classpath/gnu/java/awt/peer/qt/QtRepaintThread.java
new file mode 100644
index 000000000..6861be8fc
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtRepaintThread.java
@@ -0,0 +1,156 @@
+/* QtRepaintThread.java -- Repaint thread implementation
+ 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.peer.qt;
+
+/**
+ * This class does repainting of Component back-buffers. It is undesirable to
+ * do this directly from the paint callback in QtComponentPeer, because that
+ * is executed from the main thread. Thus, if a call is made at the same time
+ * which requires execution by the main thread, and this is sharing a lock with
+ * paint(), then a deadlock will occur, which must be avoided. In general,
+ * the main Qt thread should avoid calling into java code as far as possible.
+ *
+ */
+public class QtRepaintThread extends Thread
+{
+ static class RepaintComponent
+ {
+ public QtComponentPeer curr;
+ public RepaintComponent next;
+ public boolean paintAll;
+ public int x, y, w, h;
+
+ public RepaintComponent(QtComponentPeer p)
+ {
+ curr = p;
+ next = null;
+ paintAll = true;
+ }
+
+ public RepaintComponent(QtComponentPeer p, int x, int y, int w, int h)
+ {
+ this(p);
+ paintAll = false;
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ }
+
+ RepaintComponent component;
+ boolean busy;
+
+ public QtRepaintThread()
+ {
+ component = null;
+ }
+
+ public void run()
+ {
+ while( true )
+ {
+ try
+ {
+ busy = false;
+ // Wait for a repaint
+ sleep(100);
+ busy = true;
+ }
+ catch (InterruptedException ie)
+ {
+ while( component != null )
+ {
+ try
+ {
+ if( component.paintAll )
+ {
+ // update the back-buffer.
+ component.curr.paintBackBuffer();
+ component.curr.QtUpdate(); // trigger a native repaint event
+ }
+ else
+ {
+ component.curr.paintBackBuffer(component.x, component.y,
+ component.w, component.h);
+ component.curr.QtUpdateArea(component.x, component.y,
+ component.w, component.h);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+ component = component.next;
+ }
+ }
+ }
+ }
+
+ /**
+ * Enqueue a component for repainting.
+ */
+ public synchronized void queueComponent(QtComponentPeer p)
+ {
+ if( component == null )
+ component = new RepaintComponent(p);
+ else
+ {
+ RepaintComponent r = component;
+ while( r.next != null ) r = r.next;
+ r.next = new RepaintComponent(p);
+ }
+ interrupt();
+ }
+
+ /**
+ * Enqueue a component for repainting.
+ */
+ public synchronized void queueComponent(QtComponentPeer p, int x, int y,
+ int w, int h)
+ {
+ if( component == null )
+ component = new RepaintComponent(p, x, y, w, h);
+ else
+ {
+ RepaintComponent r = component;
+ while( r.next != null ) r = r.next;
+ r.next = new RepaintComponent(p, x, y, w, h);
+ }
+ interrupt();
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDevice.java b/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDevice.java
new file mode 100644
index 000000000..c7d8a4784
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDevice.java
@@ -0,0 +1,115 @@
+/* QtScreenDevice.java -- Wrapper on a Qt screen Widget
+ 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.peer.qt;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.DisplayMode;
+import java.awt.GraphicsConfigTemplate;
+import java.awt.Rectangle;
+import java.awt.Window;
+
+public class QtScreenDevice extends GraphicsDevice
+{
+ private long nativeObject;
+ private int id;
+ private String IDstring;
+ QtScreenDeviceConfiguration config;
+
+ public QtScreenDevice(int id)
+ {
+ this.id = id;
+ IDstring = "QtScreen" + id;
+ init( id );
+ config = new QtScreenDeviceConfiguration(this);
+ }
+
+ public native void init( int id );
+ public native void dispose();
+
+ // Package-private methods used by QtScreenDeviceConfiguration
+ native Rectangle getBounds();
+ native int getDpiX();
+ native int getDpiY();
+ native int depth();
+
+ // ****************** Public methods ***********************
+
+ public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct)
+ {
+ return config;
+ }
+
+ public GraphicsConfiguration[] getConfigurations()
+ {
+ return new GraphicsConfiguration[]{ config };
+ }
+
+ public GraphicsConfiguration getDefaultConfiguration()
+ {
+ return config;
+ }
+
+ public String getIDstring()
+ {
+ return IDstring;
+ }
+
+ public int getType()
+ {
+ return TYPE_RASTER_SCREEN;
+ }
+
+ public boolean isDisplayChangeSupported()
+ {
+ return false;
+ }
+
+ public boolean isFullScreenSupported()
+ {
+ return false;
+ }
+
+ public void setDisplayMode(DisplayMode dm)
+ {
+ }
+
+ public void setFullScreenWindow(Window w)
+ {
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java b/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
new file mode 100644
index 000000000..34de36c09
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java
@@ -0,0 +1,145 @@
+/* QtScreenDeviceConfiguration.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.ImageCapabilities;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+import java.awt.geom.AffineTransform;
+
+public class QtScreenDeviceConfiguration extends GraphicsConfiguration {
+
+ private QtScreenDevice owner;
+ private Rectangle bounds;
+ private double dpiX, dpiY;
+ private int depth;
+
+ public QtScreenDeviceConfiguration(QtScreenDevice owner)
+ {
+ this.owner = owner;
+ bounds = owner.getBounds();
+ dpiX = owner.getDpiX();
+ dpiY = owner.getDpiY();
+ depth = owner.depth();
+ }
+
+ public BufferedImage createCompatibleImage(int width, int height)
+ {
+ switch( depth )
+ {
+ case 24:
+ return new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
+ case 16:
+ return new BufferedImage(width, height,
+ BufferedImage.TYPE_USHORT_565_RGB);
+ case 8:
+ return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);
+ default:
+ case 32:
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ }
+ }
+
+ public BufferedImage createCompatibleImage(int width, int height, int transparency)
+ {
+ // FIXME: Take the transpareny flag into account?
+ // For now, ignore it and just use an alpha channel.
+ if(depth == 32)
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ return createCompatibleImage(width, height);
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height)
+ {
+ return new QtVolatileImage( width, height );
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ ImageCapabilities caps)
+ {
+ return createCompatibleVolatileImage( width, height );
+ }
+
+ public Rectangle getBounds()
+ {
+ return bounds;
+ }
+
+ public ColorModel getColorModel()
+ {
+ // FIXME?
+ return QtToolkit.getDefaultToolkit().getColorModel();
+ }
+
+ public ColorModel getColorModel(int transparency)
+ {
+ // FIXME?
+ return QtToolkit.getDefaultToolkit().getColorModel();
+ }
+
+ public AffineTransform getDefaultTransform()
+ {
+ return new AffineTransform();
+ }
+
+ public GraphicsDevice getDevice()
+ {
+ return owner;
+ }
+
+ /**
+ * Returns the transform which transforms from this display's resolution
+ * to a 72 DPI resolution.
+ */
+ public AffineTransform getNormalizingTransform()
+ {
+ AffineTransform nTrans = new AffineTransform();
+ nTrans.scale( 72.0 / dpiX, 72.0 / dpiY );
+ return nTrans;
+ }
+
+ public VolatileImage createCompatibleVolatileImage(int width, int height,
+ int transparency)
+ {
+ return createCompatibleVolatileImage(width, height);
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java
new file mode 100644
index 000000000..079d06de7
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtScrollPanePeer.java
@@ -0,0 +1,90 @@
+/* QtScrollPanePeer.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Adjustable;
+import java.awt.Insets;
+import java.awt.ScrollPane;
+import java.awt.peer.ScrollPanePeer;
+
+public class QtScrollPanePeer extends QtContainerPeer implements ScrollPanePeer
+{
+ public QtScrollPanePeer( QtToolkit kit, ScrollPane owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setPolicy( ((ScrollPane)owner).getScrollbarDisplayPolicy() );
+ }
+
+ private native void setPolicy(int policy);
+
+ // ************ Public methods *********************
+
+ public native void childResized(int width, int height);
+
+ public native int getHScrollbarHeight();
+
+ public native int getVScrollbarWidth();
+
+ public native void setScrollPosition(int x, int y);
+
+ public Insets getInsets()
+ {
+ // FIXME : more accurate?
+ return new Insets(5 + getHScrollbarHeight(), // Top
+ 5 + getVScrollbarWidth(), // Left
+ 5, // Bottom
+ 5); // Right
+ }
+
+ public void setUnitIncrement(Adjustable item, int inc)
+ {
+ // FIXME
+ }
+
+ public void setValue(Adjustable item, int value)
+ {
+ // FIXME
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtScrollbarPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtScrollbarPeer.java
new file mode 100644
index 000000000..694287131
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtScrollbarPeer.java
@@ -0,0 +1,80 @@
+/* QtScrollbarPeer.java --
+ 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.peer.qt;
+
+import java.awt.Scrollbar;
+import java.awt.event.AdjustmentEvent;
+import java.awt.peer.ScrollbarPeer;
+
+public class QtScrollbarPeer extends QtComponentPeer implements ScrollbarPeer
+{
+ public QtScrollbarPeer( QtToolkit kit, Scrollbar owner )
+ {
+ super( kit, owner );
+ }
+
+ public native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ Scrollbar o = (Scrollbar)owner;
+ setValues(o.getValue(), o.getVisible(), o.getMinimum(), o.getMaximum());
+ setOrientation(o.getOrientation());
+ setLineIncrement(o.getLineIncrement());
+ setPageIncrement(o.getPageIncrement());
+ }
+
+ private native void setOrientation(int orientation);
+
+ private void fireMoved(int type, int value)
+ {
+ AdjustmentEvent e = new AdjustmentEvent((Scrollbar)owner,
+ AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
+ type, value);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public native void setLineIncrement(int inc);
+
+ public native void setPageIncrement(int inc);
+
+ public native void setValues(int value, int visible, int min, int max);
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtTextAreaPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtTextAreaPeer.java
new file mode 100644
index 000000000..a5aff58ef
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtTextAreaPeer.java
@@ -0,0 +1,179 @@
+/* QtTextAreaPeer.java --
+ 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.peer.qt;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextArea;
+import java.awt.event.TextEvent;
+import java.awt.im.InputMethodRequests;
+import java.awt.peer.TextAreaPeer;
+
+public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
+{
+ public QtTextAreaPeer( QtToolkit kit, TextArea owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText(((TextArea)owner).getText());
+ setEditable(((TextArea)owner).isEditable());
+ }
+
+ /**
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+ private native int getSelection(boolean start);
+
+ /**
+ * Called back on a text edit.
+ */
+ private void textChanged()
+ {
+ TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ // ************ Public methods *********************
+
+ public long filterEvents(long filter)
+ {
+ return filter;
+ }
+
+ public native int getCaretPosition();
+
+ public Rectangle getCharacterBounds(int pos)
+ {
+ // FIXME
+ return new Rectangle(0,0,0,0);
+ }
+
+ /**
+ * Implemented, but who uses it?
+ */
+ public native int getIndexAtPoint(int x, int y);
+
+// public void reshape(int x, int y,
+// int width, int height)
+// {
+// if(width != 0 || height != 0)
+// super.reshape(x, y, width, height);
+// else
+// super.reshape(x, y, 10, 10);
+// }
+
+ public Dimension getMinimumSize(int rows, int cols)
+ {
+ // FIXME
+ return getMinimumSize();
+ }
+
+ public Dimension getPreferredSize(int rows, int cols)
+ {
+ // FIXME
+ return getPreferredSize();
+ }
+
+ public int getSelectionEnd()
+ {
+ return getSelection(false);
+ }
+
+ public int getSelectionStart()
+ {
+ return getSelection(true);
+ }
+
+ public native String getText();
+
+ public void insert(String text, int pos)
+ {
+ // Not very efficient, no.
+ String s = getText();
+ setText(s.substring(0, pos) + text + s.substring(pos));
+ }
+
+ public void insertText(String text, int pos)
+ {
+ insert(text, pos);
+ }
+
+ public Dimension minimumSize(int rows, int cols)
+ {
+ return getMinimumSize(rows, cols);
+ }
+
+ public Dimension preferredSize(int rows, int cols)
+ {
+ return getPreferredSize(rows, cols);
+ }
+
+ public void replaceRange(String insert, int start_pos, int end_pos)
+ {
+ // Not very efficient, no.
+ String text = getText();
+ String right = text.substring(0, start_pos);
+ String left = text.substring(end_pos);
+ setText(right + insert + left);
+ }
+
+ public void replaceText(String text, int start_pos, int end_pos)
+ {
+ replaceRange(text, start_pos, end_pos);
+ }
+
+ public native void setText(String text);
+
+ public native void select(int start_pos, int end_pos);
+
+ public native void setEditable(boolean editable);
+
+ public native void setCaretPosition(int pos);
+
+ public InputMethodRequests getInputMethodRequests()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtTextFieldPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtTextFieldPeer.java
new file mode 100644
index 000000000..f92943202
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtTextFieldPeer.java
@@ -0,0 +1,159 @@
+/* QtTextFieldPeer.java --
+ 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.peer.qt;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.TextField;
+import java.awt.event.TextEvent;
+import java.awt.im.InputMethodRequests;
+import java.awt.peer.TextFieldPeer;
+
+public class QtTextFieldPeer extends QtComponentPeer implements TextFieldPeer
+{
+ public QtTextFieldPeer( QtToolkit kit, TextField owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ setText(((TextField)owner).getText());
+ setEditable(((TextField)owner).isEditable());
+ }
+
+ /**
+ * Called back on a text edit.
+ */
+ private void textChanged()
+ {
+ TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
+ QtToolkit.eventQueue.postEvent(e);
+ }
+
+ /**
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+ private native int getSelection(boolean start);
+
+ private native Dimension getMinimumSizeNative(int columns);
+
+ private native Dimension getPreferredSizeNative(int columns);
+
+ // ************ Public methods *********************
+
+ public long filterEvents(long e)
+ {
+ return e;
+ }
+
+ public native int getCaretPosition();
+
+ public Rectangle getCharacterBounds(int i)
+ {
+ return new Rectangle(0,0,0,0);
+ }
+
+ public int getIndexAtPoint(int x, int y)
+ {
+ // FIXME
+ return 0;
+ }
+
+ public Dimension getMinimumSize(int columns)
+ {
+ Dimension d = getMinimumSizeNative( columns );
+ if ( d == null )
+ return new Dimension(10, 10);
+ return d;
+ }
+
+ public Dimension getPreferredSize(int columns)
+ {
+ Dimension d = getPreferredSizeNative( columns );
+ if ( d == null )
+ return owner.getSize();
+ return d;
+ }
+
+ public int getSelectionEnd()
+ {
+ return getSelection(false);
+ }
+
+ public int getSelectionStart()
+ {
+ return getSelection(true);
+ }
+
+ public native String getText();
+
+ public Dimension minimumSize(int cols)
+ {
+ return getMinimumSize(cols);
+ }
+
+ public Dimension preferredSize(int cols)
+ {
+ return getPreferredSize(cols);
+ }
+
+ public native void select(int selStart, int selEnd);
+
+ public native void setCaretPosition(int pos);
+
+ public void setEchoCharacter(char c)
+ {
+ setEchoChar(c);
+ }
+
+ public native void setEchoChar(char echoChar);
+
+ public native void setEditable(boolean editable);
+
+ public native void setText(String l);
+
+ public InputMethodRequests getInputMethodRequests()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java b/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java
new file mode 100644
index 000000000..9f8a691c6
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtToolkit.java
@@ -0,0 +1,470 @@
+/* QtToolkit.java --
+ Copyright (C) 2005, 2006, 2007 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.peer.qt;
+
+import gnu.java.awt.ClasspathToolkit;
+import gnu.java.awt.EmbeddedWindow;
+import gnu.java.awt.peer.ClasspathFontPeer;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.FileDialog;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.ScrollPane;
+import java.awt.Scrollbar;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.Window;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.event.AWTEventListener;
+import java.awt.im.InputMethodHighlight;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.WindowPeer;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class QtToolkit extends ClasspathToolkit
+{
+ public static EventQueue eventQueue = null; // the native event queue
+ public static QtRepaintThread repaintThread = null;
+ public static MainQtThread guiThread = null;
+ public static QtGraphicsEnvironment graphicsEnv = null;
+
+ private static void initToolkit()
+ {
+ eventQueue = new EventQueue();
+ repaintThread = new QtRepaintThread();
+ System.loadLibrary("qtpeer");
+
+ String theme = null;
+ try
+ {
+ String style = System.getProperty("qtoptions.style");
+ if(style != null)
+ theme = style;
+ }
+ catch(SecurityException e)
+ {
+ }
+ catch(IllegalArgumentException e)
+ {
+ }
+
+ boolean doublebuffer = true;
+ try
+ {
+ String style = System.getProperty("qtoptions.nodoublebuffer");
+ if(style != null)
+ doublebuffer = false;
+ }
+ catch(SecurityException e)
+ {
+ }
+ catch(IllegalArgumentException e)
+ {
+ }
+
+ guiThread = new MainQtThread( theme, doublebuffer );
+ guiThread.start();
+ repaintThread.start();
+ }
+
+ /**
+ * Construct the toolkit!
+ */
+ public QtToolkit()
+ {
+ if( guiThread == null )
+ initToolkit();
+
+ // make sure the GUI thread has started.
+ while (!guiThread.isRunning())
+ ;
+
+ if( graphicsEnv == null )
+ graphicsEnv = new QtGraphicsEnvironment( this );
+ }
+
+ native String[] nativeFontFamilies();
+
+ native int numScreens();
+
+ native int defaultScreen();
+
+ // ************ Public methods *********************
+
+ public synchronized native void beep();
+
+ public int checkImage(Image image, int w, int h, ImageObserver observer)
+ {
+ if(image instanceof QtImage)
+ return ((QtImage)image).checkImage(observer);
+
+ return ImageObserver.ERROR; // FIXME
+ }
+
+ protected ButtonPeer createButton( Button target )
+ {
+ return new QtButtonPeer( this, target );
+ }
+
+ protected CanvasPeer createCanvas(Canvas target)
+ {
+ return new QtCanvasPeer( this, target );
+ }
+
+ protected CheckboxPeer createCheckbox(Checkbox target)
+ {
+ return new QtCheckboxPeer( this, target );
+ }
+
+ protected ChoicePeer createChoice(Choice target)
+ {
+ return new QtChoicePeer( this, target );
+ }
+
+ protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
+ {
+ return new QtMenuItemPeer( this, target );
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected FramePeer createFrame(Frame target)
+ {
+ return new QtFramePeer( this, target );
+ }
+
+ protected FileDialogPeer createFileDialog(FileDialog target)
+ {
+ return new QtFileDialogPeer( this, target );
+ }
+
+ public Image createImage(ImageProducer producer)
+ {
+ return new QtImage( producer );
+ }
+
+ public Image createImage(byte[] imageData,
+ int imageOffset,
+ int imageLength)
+ {
+ byte[] dataCopy = new byte[imageLength];
+ System.arraycopy(imageData, imageOffset, dataCopy, 0, imageLength);
+ return new QtImage( dataCopy );
+ }
+
+ public Image createImage(String filename)
+ {
+ return new QtImage( filename );
+ }
+
+ public Image createImage(URL url)
+ {
+ return new QtImage( url );
+ }
+
+ protected TextFieldPeer createTextField(TextField target)
+ {
+ return new QtTextFieldPeer(this,target);
+ }
+
+ protected LabelPeer createLabel(Label target)
+ {
+ return new QtLabelPeer( this, target );
+ }
+
+ protected ListPeer createList(List target)
+ {
+ return new QtListPeer( this, target );
+ }
+
+ protected ScrollbarPeer createScrollbar(Scrollbar target)
+ {
+ return new QtScrollbarPeer( this, target );
+ }
+
+ protected ScrollPanePeer createScrollPane(ScrollPane target)
+ {
+ return new QtScrollPanePeer( this, target );
+ }
+
+ protected TextAreaPeer createTextArea(TextArea target)
+ {
+ return new QtTextAreaPeer( this, target );
+ }
+
+ protected PanelPeer createPanel(Panel target)
+ {
+ return new QtPanelPeer( this, target);
+ }
+
+ protected WindowPeer createWindow(Window target)
+ {
+ return new QtWindowPeer( this, target );
+ }
+
+ protected DialogPeer createDialog(Dialog target)
+ {
+ return new QtDialogPeer( this, target );
+ }
+
+ protected MenuBarPeer createMenuBar(MenuBar target)
+ {
+ return new QtMenuBarPeer( this, target );
+ }
+
+ protected MenuPeer createMenu(Menu target)
+ {
+ return new QtMenuPeer( this, target );
+ }
+
+ protected PopupMenuPeer createPopupMenu(PopupMenu target)
+ {
+ return new QtPopupMenuPeer( this, target );
+ }
+
+ protected MenuItemPeer createMenuItem(MenuItem target)
+ {
+ return new QtMenuItemPeer( this, target );
+ }
+
+ /**
+ * @since 1.4
+ */
+ public AWTEventListener[] getAWTEventListeners()
+ {
+ return null; // FIXME
+ }
+
+ /**
+ * @since 1.4
+ */
+ public AWTEventListener[] getAWTEventListeners(long mask)
+ {
+ return null; // FIXME
+ }
+
+ public ColorModel getColorModel()
+ {
+ return new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ }
+
+ /**
+ * Just return the defaults.
+ */
+ public String[] getFontList()
+ {
+ String[] builtIn = new String[] { "Dialog",
+ "DialogInput",
+ "Monospaced",
+ "Serif",
+ "SansSerif" };
+ String[] nat = nativeFontFamilies();
+ String[] allFonts = new String[ nat.length + 5 ];
+ System.arraycopy(builtIn, 0, allFonts, 0, 5);
+ System.arraycopy(nat, 0, allFonts, 5, nat.length);
+ return allFonts;
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return new QtFontMetrics(font);
+ }
+
+ protected FontPeer getFontPeer(String name,
+ int style)
+ {
+ Map attrs = new HashMap ();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12.
+ return getClasspathFontPeer (name, attrs);
+ }
+
+ public Image getImage(String filename)
+ {
+ return new QtImage(filename);
+ }
+
+ public Image getImage(URL url)
+ {
+ return createImage( url );
+ }
+
+ public PrintJob getPrintJob(Frame frame,
+ String jobtitle,
+ Properties props)
+ {
+ SecurityManager sm;
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
+ throw new RuntimeException("Not implemented");
+ }
+
+ public Clipboard getSystemClipboard()
+ {
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected EventQueue getSystemEventQueueImpl()
+ {
+ return eventQueue;
+ }
+
+ public native Dimension getScreenSize();
+
+ public native int getScreenResolution();
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ {
+ return null; // FIXME
+ }
+
+ public boolean prepareImage(Image image, int w, int h, ImageObserver observer)
+ {
+ if(image instanceof QtImage)
+ return true;
+ return false; // FIXME?
+ }
+
+ public native void sync();
+
+ // ********************** ClasspathToolkit methods
+
+ public GraphicsEnvironment getLocalGraphicsEnvironment()
+ {
+ return graphicsEnv;
+ }
+
+ public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs)
+ {
+ return new QtFontPeer (name, attrs);
+ }
+
+ // FIXME
+ public Font createFont(int format, InputStream stream)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ // FIXME
+ public RobotPeer createRobot (GraphicsDevice screen) throws AWTException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public EmbeddedWindowPeer createEmbeddedWindow(EmbeddedWindow w)
+ {
+ // return new QtEmbeddedWindowPeer( this, w );
+ return null;
+ }
+
+ @Override
+ public boolean isModalExclusionTypeSupported
+ (Dialog.ModalExclusionType modalExclusionType)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isModalityTypeSupported(Dialog.ModalityType modalityType)
+ {
+ return false;
+ }
+
+
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java b/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java
new file mode 100644
index 000000000..a203de0d0
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtVolatileImage.java
@@ -0,0 +1,434 @@
+/* QtVolatileImage.java --
+ Copyright (C) 2005, 2006 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.peer.qt;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.ImageCapabilities;
+import java.awt.GraphicsConfiguration;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.MemoryImageSource;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.VolatileImage;
+import java.util.Hashtable;
+import java.util.WeakHashMap;
+
+/**
+ * QtVolatileImage - wraps a QImage
+ *
+ */
+public class QtVolatileImage extends VolatileImage
+{
+ int width = -1, height = -1;
+
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Pointer to the QImage
+ */
+ long nativeObject;
+
+ /*
+ * The 32-bit AARRGGBB format the uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+
+ /**
+ * Clears the image to RGBA 0
+ */
+ public native void clear();
+
+ /**
+ * Returns a copy of the pixel data as a java array.
+ */
+ private native int[] getPixels();
+
+ /**
+ * Allocates a QImage
+ */
+ private native void createImage();
+
+ /**
+ * HashMap of Graphics objects painting on this Image.
+ */
+ WeakHashMap painters;
+
+ /**
+ * Flags if this image is to be destroyed.
+ */
+ boolean killFlag;
+
+ /**
+ * Frees the above.
+ */
+ private native void freeImage();
+
+ /**
+ * Blit a QImage
+ */
+ public native void blit(QtImage i);
+ public native void blit(QtImage i, int x, int y, int w, int h);
+
+ /**
+ * Sets the image to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledImage(QtVolatileImage src, int hints);
+
+ /**
+ * Draws the image optionally composited.
+ */
+ private native void drawPixels (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y,
+ boolean composite);
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (QtGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image transformed.
+ */
+ private native void drawPixelsTransformed (QtGraphics gc, QMatrix transform);
+
+ /**
+ * Draws the image scaled flipped and optionally composited.
+ */
+ native void drawPixelsScaledFlipped (QtGraphics gc,
+ int bg_red, int bg_green,
+ int bg_blue,
+ boolean flipX, boolean flipY,
+ int srcX, int srcY,
+ int srcWidth, int srcHeight,
+ int dstX, int dstY,
+ int dstWidth, int dstHeight,
+ boolean composite);
+
+ /**
+ * Constructs an empty QtVolatileImage.
+ */
+ public QtVolatileImage (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ createImage();
+ clear();
+ }
+
+ /**
+ * Constructs a scaled version of the src bitmap, using Qt
+ */
+ private QtVolatileImage (QtVolatileImage src, int width, int height,
+ int hints)
+ {
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+
+ createScaledImage(src, hints);
+ }
+
+
+ public void finalize()
+ {
+ dispose();
+ }
+
+ public void dispose()
+ {
+ if( painters == null || painters.isEmpty() )
+ freeImage();
+ else
+ killFlag = true; // can't destroy image yet.
+ // Do so when all painters are gone.
+ }
+
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public int getWidth (ImageObserver observer)
+ {
+ return getWidth();
+ }
+
+ public int getHeight (ImageObserver observer)
+ {
+ return getHeight();
+ }
+
+ public Object getProperty (String name, ImageObserver observer)
+ {
+ Object value = props.get (name);
+ return (value == null) ? UndefinedProperty : value;
+ }
+
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
+ {
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
+ }
+
+ void putPainter(QtImageGraphics g)
+ {
+ if( painters == null )
+ painters = new WeakHashMap();
+ painters.put( g, "dummy" );
+ }
+
+ void removePainter(QtImageGraphics g)
+ {
+ painters.remove( g );
+ if( killFlag && painters.isEmpty() )
+ freeImage();
+ }
+
+ /**
+ * Creates a Graphics context for this image.
+ */
+ public Graphics getGraphics ()
+ {
+ QtImageGraphics g = new QtImageGraphics( this );
+ putPainter( g );
+ return g;
+ }
+
+ /**
+ * Returns a scaled instance of this image.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
+
+ return new QtVolatileImage(this, width, height, hints);
+ }
+
+ /**
+ */
+ public void flush ()
+ {
+ // FIXME ?
+ }
+
+ /**
+ * Returns the image status, used by QtToolkit
+ */
+ public int checkImage (ImageObserver observer)
+ {
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
+ }
+
+ // Drawing methods ////////////////////////////////////////////////
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, QMatrix matrix,
+ ImageObserver observer)
+ {
+ drawPixelsTransformed (g, matrix);
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) with optional
+ * compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y,
+ Color bgcolor, ImageObserver observer)
+ {
+ if(bgcolor != null)
+ drawPixels(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, true);
+ else
+ drawPixels(g, 0, 0, 0, x, y, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image to the QtGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (QtGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
+ {
+ if(bgcolor != null)
+ drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, width, height, true);
+ else
+ drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false);
+
+ return true;
+ }
+
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (QtGraphics g, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ boolean flipX = (dx1 > dx2)^(sx1 > sx2);
+ boolean flipY = (dy1 > dy2)^(sy1 > sy2);
+ int dstWidth = Math.abs (dx2 - dx1);
+ int dstHeight = Math.abs (dy2 - dy1);
+ int srcWidth = Math.abs (sx2 - sx1);
+ int srcHeight = Math.abs (sy2 - sy1);
+ int srcX = (sx1 < sx2) ? sx1 : sx2;
+ int srcY = (sy1 < sy2) ? sy1 : sy2;
+ int dstX = (dx1 < dx2) ? dx1 : dx2;
+ int dstY = (dy1 < dy2) ? dy1 : dy2;
+
+ // Clipping. This requires the dst to be scaled as well,
+ if (srcWidth > width)
+ {
+ dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight > height)
+ {
+ dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
+ srcHeight = height - srcY;
+ }
+
+ if (srcWidth + srcX > width)
+ {
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
+
+ if (srcHeight + srcY > height)
+ {
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
+ }
+
+ if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
+ return true;
+
+ if(bgcolor != null)
+ drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (),
+ flipX, flipY,
+ srcX, srcY,
+ srcWidth, srcHeight,
+ dstX, dstY,
+ dstWidth, dstHeight,
+ true);
+ else
+ drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY,
+ srcX, srcY, srcWidth, srcHeight,
+ dstX, dstY, dstWidth, dstHeight,
+ false);
+ return true;
+ }
+
+ public native void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ //******************** VolatileImage stuff ********************
+
+ public boolean contentsLost()
+ {
+ return false;
+ }
+
+ public Graphics2D createGraphics()
+ {
+ QtImageGraphics g = new QtImageGraphics(this);
+ putPainter( g );
+ return g;
+ }
+
+ public ImageCapabilities getCapabilities()
+ {
+ return new ImageCapabilities(false)
+ {
+ public boolean isTrueVolatile()
+ {
+ return false;
+ }
+ };
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public BufferedImage getSnapshot()
+ {
+ BufferedImage bi = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ bi.setRGB( 0, 0, width, height, getPixels(), 0, width);
+ return bi;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public int validate(GraphicsConfiguration gc)
+ {
+ return IMAGE_OK;
+ }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/qt/QtWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/qt/QtWindowPeer.java
new file mode 100644
index 000000000..2dfe2ec5a
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/qt/QtWindowPeer.java
@@ -0,0 +1,105 @@
+/* QtWindowPeer.java --
+ 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.peer.qt;
+
+import java.awt.Component;
+import java.awt.peer.WindowPeer;
+
+public class QtWindowPeer extends QtContainerPeer implements WindowPeer
+{
+ public QtWindowPeer( QtToolkit kit, Component owner )
+ {
+ super( kit, owner );
+ }
+
+ protected native void init();
+
+ protected void setup()
+ {
+ super.setup();
+ }
+
+ // ************ Public methods *********************
+
+ public native void toBack();
+
+ public native void toFront();
+
+ /*
+ * Belongs to Frame and Dialog, but no sense in duplicating code.
+ */
+ public native void setTitle(String title);
+
+ public void updateAlwaysOnTop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean requestWindowFocus()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void updateIconImages()
+ {
+ // TODO: Implement properly.
+ }
+
+ public void updateMinimumSize()
+ {
+ // TODO: Implement properly.
+ }
+
+ public void setModalBlocked(java.awt.Dialog d, boolean b)
+ {
+ // TODO: Implement properly.
+ }
+
+ public void updateFocusableWindowState()
+ {
+ // TODO: Implement properly.
+ }
+
+ public void setAlwaysOnTop(boolean b)
+ {
+ // TODO: Implement properly.
+ }
+
+}