summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven de Marothy <sven@physto.se>2005-08-16 23:22:09 +0000
committerSven de Marothy <sven@physto.se>2005-08-16 23:22:09 +0000
commit636a84d9480d60c2652e71f5c36081d12a4a0cac (patch)
treeab8571b728fb1726a7a4843d7b51063fe951d23f
parent96e661c677fe4d83b71ea52844f4160bf18572c4 (diff)
downloadclasspath-636a84d9480d60c2652e71f5c36081d12a4a0cac.tar.gz
2005-08-16 Sven de Marothy <sven@physto.se>
* gnu/java/awt/peer/qt/QtButtonPeer.java * gnu/java/awt/peer/qt/QtCheckboxPeer.java * gnu/java/awt/peer/qt/QtChoicePeer.java * gnu/java/awt/peer/qt/QtComponentGraphics.java * gnu/java/awt/peer/qt/QtComponentPeer.java * gnu/java/awt/peer/qt/QtContainerPeer.java * gnu/java/awt/peer/qt/QtDialogPeer.java * gnu/java/awt/peer/qt/QtFontPeer.java * gnu/java/awt/peer/qt/QtFramePeer.java * gnu/java/awt/peer/qt/QtGraphics.java * gnu/java/awt/peer/qt/QtImage.java * gnu/java/awt/peer/qt/QtImageGraphics.java * gnu/java/awt/peer/qt/QtListPeer.java * gnu/java/awt/peer/qt/QtMenuBarPeer.java * gnu/java/awt/peer/qt/QtMenuItemPeer.java * gnu/java/awt/peer/qt/QtMenuPeer.java * gnu/java/awt/peer/qt/QtScrollbarPeer.java * gnu/java/awt/peer/qt/QtTextAreaPeer.java * gnu/java/awt/peer/qt/QtTextFieldPeer.java * gnu/java/awt/peer/qt/QtToolkit.java * gnu/java/awt/peer/qt/QtWindowPeer.java * native/jni/qt-peer/keybindings.cpp * native/jni/qt-peer/keybindings.h * native/jni/qt-peer/qtbuttonpeer.cpp * native/jni/qt-peer/qtcanvaspeer.cpp * native/jni/qt-peer/qtcheckboxpeer.cpp * native/jni/qt-peer/qtchoicepeer.cpp * native/jni/qt-peer/qtcomponent.cpp * native/jni/qt-peer/qtcomponentpeer.cpp * native/jni/qt-peer/qtdialogpeer.cpp * native/jni/qt-peer/qtframepeer.cpp * native/jni/qt-peer/qtgraphics.cpp * native/jni/qt-peer/qtimage.cpp * native/jni/qt-peer/qtlabelpeer.cpp * native/jni/qt-peer/qtlistpeer.cpp * native/jni/qt-peer/qtmenupeer.cpp * native/jni/qt-peer/qtpanelpeer.cpp * native/jni/qt-peer/qtscrollbarpeer.cpp * native/jni/qt-peer/qtscrollpanepeer.cpp * native/jni/qt-peer/qttextareapeer.cpp * native/jni/qt-peer/qttextfieldpeer.cpp * native/jni/qt-peer/qtwindowpeer.cpp * native/jni/qt-peer/slotcallbacks.cpp * native/jni/qt-peer/slotcallbacks.h Reindented, Transmogrified and Wielaardituded. * gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java * native/jni/qt-peer/eventmethods.h * native/jni/qt-peer/qtembeddedwindowpeer.cpp * native/jni/qt-peer/slotcallbacks.moc.h New files * native/jni/qt-peer/eventmethods.cpp * native/jni/qt-peer/slotcallbacks.moc Removed.
-rw-r--r--ChangeLog57
-rw-r--r--gnu/java/awt/peer/qt/QtButtonPeer.java4
-rw-r--r--gnu/java/awt/peer/qt/QtCheckboxPeer.java2
-rw-r--r--gnu/java/awt/peer/qt/QtChoicePeer.java2
-rw-r--r--gnu/java/awt/peer/qt/QtComponentGraphics.java6
-rw-r--r--gnu/java/awt/peer/qt/QtComponentPeer.java115
-rw-r--r--gnu/java/awt/peer/qt/QtContainerPeer.java3
-rw-r--r--gnu/java/awt/peer/qt/QtDialogPeer.java1
-rw-r--r--gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java61
-rw-r--r--gnu/java/awt/peer/qt/QtFontPeer.java1
-rw-r--r--gnu/java/awt/peer/qt/QtFramePeer.java24
-rw-r--r--gnu/java/awt/peer/qt/QtGraphics.java7
-rw-r--r--gnu/java/awt/peer/qt/QtImage.java21
-rw-r--r--gnu/java/awt/peer/qt/QtImageGraphics.java11
-rw-r--r--gnu/java/awt/peer/qt/QtListPeer.java58
-rw-r--r--gnu/java/awt/peer/qt/QtMenuBarPeer.java5
-rw-r--r--gnu/java/awt/peer/qt/QtMenuItemPeer.java14
-rw-r--r--gnu/java/awt/peer/qt/QtMenuPeer.java2
-rw-r--r--gnu/java/awt/peer/qt/QtScrollbarPeer.java2
-rw-r--r--gnu/java/awt/peer/qt/QtTextAreaPeer.java24
-rw-r--r--gnu/java/awt/peer/qt/QtTextFieldPeer.java10
-rw-r--r--gnu/java/awt/peer/qt/QtToolkit.java3
-rw-r--r--gnu/java/awt/peer/qt/QtWindowPeer.java4
-rw-r--r--native/jni/qt-peer/eventmethods.h240
-rw-r--r--native/jni/qt-peer/keybindings.cpp26
-rw-r--r--native/jni/qt-peer/keybindings.h1
-rw-r--r--native/jni/qt-peer/qtbuttonpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtcanvaspeer.cpp2
-rw-r--r--native/jni/qt-peer/qtcheckboxpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtchoicepeer.cpp1
-rw-r--r--native/jni/qt-peer/qtcomponent.cpp4
-rw-r--r--native/jni/qt-peer/qtcomponentpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtdialogpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtembeddedwindowpeer.cpp113
-rw-r--r--native/jni/qt-peer/qtframepeer.cpp31
-rw-r--r--native/jni/qt-peer/qtgraphics.cpp21
-rw-r--r--native/jni/qt-peer/qtimage.cpp12
-rw-r--r--native/jni/qt-peer/qtlabelpeer.cpp3
-rw-r--r--native/jni/qt-peer/qtlistpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtmenupeer.cpp2
-rw-r--r--native/jni/qt-peer/qtpanelpeer.cpp5
-rw-r--r--native/jni/qt-peer/qtscrollbarpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtscrollpanepeer.cpp5
-rw-r--r--native/jni/qt-peer/qttextareapeer.cpp55
-rw-r--r--native/jni/qt-peer/qttextfieldpeer.cpp2
-rw-r--r--native/jni/qt-peer/qtwindowpeer.cpp13
-rw-r--r--native/jni/qt-peer/slotcallbacks.cpp65
-rw-r--r--native/jni/qt-peer/slotcallbacks.h6
-rw-r--r--native/jni/qt-peer/slotcallbacks.moc.h80
49 files changed, 932 insertions, 204 deletions
diff --git a/ChangeLog b/ChangeLog
index c4a3bfb98..a933ae921 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,59 @@
+2005-08-16 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/qt/QtButtonPeer.java
+ * gnu/java/awt/peer/qt/QtCheckboxPeer.java
+ * gnu/java/awt/peer/qt/QtChoicePeer.java
+ * gnu/java/awt/peer/qt/QtComponentGraphics.java
+ * gnu/java/awt/peer/qt/QtComponentPeer.java
+ * gnu/java/awt/peer/qt/QtContainerPeer.java
+ * gnu/java/awt/peer/qt/QtDialogPeer.java
+ * gnu/java/awt/peer/qt/QtFontPeer.java
+ * gnu/java/awt/peer/qt/QtFramePeer.java
+ * gnu/java/awt/peer/qt/QtGraphics.java
+ * gnu/java/awt/peer/qt/QtImage.java
+ * gnu/java/awt/peer/qt/QtImageGraphics.java
+ * gnu/java/awt/peer/qt/QtListPeer.java
+ * gnu/java/awt/peer/qt/QtMenuBarPeer.java
+ * gnu/java/awt/peer/qt/QtMenuItemPeer.java
+ * gnu/java/awt/peer/qt/QtMenuPeer.java
+ * gnu/java/awt/peer/qt/QtScrollbarPeer.java
+ * gnu/java/awt/peer/qt/QtTextAreaPeer.java
+ * gnu/java/awt/peer/qt/QtTextFieldPeer.java
+ * gnu/java/awt/peer/qt/QtToolkit.java
+ * gnu/java/awt/peer/qt/QtWindowPeer.java
+ * native/jni/qt-peer/keybindings.cpp
+ * native/jni/qt-peer/keybindings.h
+ * native/jni/qt-peer/qtbuttonpeer.cpp
+ * native/jni/qt-peer/qtcanvaspeer.cpp
+ * native/jni/qt-peer/qtcheckboxpeer.cpp
+ * native/jni/qt-peer/qtchoicepeer.cpp
+ * native/jni/qt-peer/qtcomponent.cpp
+ * native/jni/qt-peer/qtcomponentpeer.cpp
+ * native/jni/qt-peer/qtdialogpeer.cpp
+ * native/jni/qt-peer/qtframepeer.cpp
+ * native/jni/qt-peer/qtgraphics.cpp
+ * native/jni/qt-peer/qtimage.cpp
+ * native/jni/qt-peer/qtlabelpeer.cpp
+ * native/jni/qt-peer/qtlistpeer.cpp
+ * native/jni/qt-peer/qtmenupeer.cpp
+ * native/jni/qt-peer/qtpanelpeer.cpp
+ * native/jni/qt-peer/qtscrollbarpeer.cpp
+ * native/jni/qt-peer/qtscrollpanepeer.cpp
+ * native/jni/qt-peer/qttextareapeer.cpp
+ * native/jni/qt-peer/qttextfieldpeer.cpp
+ * native/jni/qt-peer/qtwindowpeer.cpp
+ * native/jni/qt-peer/slotcallbacks.cpp
+ * native/jni/qt-peer/slotcallbacks.h
+ Reindented, Transmogrified and Wielaardituded.
+ * gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
+ * native/jni/qt-peer/eventmethods.h
+ * native/jni/qt-peer/qtembeddedwindowpeer.cpp
+ * native/jni/qt-peer/slotcallbacks.moc.h
+ New files
+ * native/jni/qt-peer/eventmethods.cpp
+ * native/jni/qt-peer/slotcallbacks.moc
+ Removed.
+
2005-08-16 Tom Tromey <tromey@redhat.com>
* .project: Fixed typo. Added builder for native code.
@@ -593,7 +649,6 @@
native/jni/qt-peer/qtcomponent.cpp,
native/jni/qt-peer/qtmenupeer.cpp,
native/jni/qt-peer/qtlabelpeer.cpp,
- native/jni/qt-peer/slotcallbacks.moc
native/jni/qt-peer/qtcanvaspeer.cpp,
native/jni/qt-peer/qtgraphics.h,
* include/gnu_java_awt_peer_qt_QtCheckboxPeer.h,
diff --git a/gnu/java/awt/peer/qt/QtButtonPeer.java b/gnu/java/awt/peer/qt/QtButtonPeer.java
index 3dd607b19..e8db3452a 100644
--- a/gnu/java/awt/peer/qt/QtButtonPeer.java
+++ b/gnu/java/awt/peer/qt/QtButtonPeer.java
@@ -65,8 +65,8 @@ public class QtButtonPeer extends QtComponentPeer implements ButtonPeer
ActionEvent.ACTION_PERFORMED,
((Button)owner).getActionCommand(),
System.currentTimeMillis(),
- (modifiers & 0x2FF));
- QtToolkit.eventQueue.postEvent(e);
+ modifiers);
+ toolkit.eventQueue.postEvent(e);
}
// ************ Public methods *********************
diff --git a/gnu/java/awt/peer/qt/QtCheckboxPeer.java b/gnu/java/awt/peer/qt/QtCheckboxPeer.java
index 788e08ee1..df023606a 100644
--- a/gnu/java/awt/peer/qt/QtCheckboxPeer.java
+++ b/gnu/java/awt/peer/qt/QtCheckboxPeer.java
@@ -84,7 +84,7 @@ public class QtCheckboxPeer extends QtComponentPeer implements CheckboxPeer
ItemEvent.ITEM_STATE_CHANGED,
((Checkbox)owner).getLabel(),
sel);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
// ************ Public methods *********************
diff --git a/gnu/java/awt/peer/qt/QtChoicePeer.java b/gnu/java/awt/peer/qt/QtChoicePeer.java
index 30674b36e..10e75c11a 100644
--- a/gnu/java/awt/peer/qt/QtChoicePeer.java
+++ b/gnu/java/awt/peer/qt/QtChoicePeer.java
@@ -68,7 +68,7 @@ public class QtChoicePeer extends QtComponentPeer implements ChoicePeer
ItemEvent.ITEM_STATE_CHANGED,
((Choice)owner).getItem(index),
ItemEvent.SELECTED);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
// ************ Public methods *********************
diff --git a/gnu/java/awt/peer/qt/QtComponentGraphics.java b/gnu/java/awt/peer/qt/QtComponentGraphics.java
index 4f3803dc6..b19db37f7 100644
--- a/gnu/java/awt/peer/qt/QtComponentGraphics.java
+++ b/gnu/java/awt/peer/qt/QtComponentGraphics.java
@@ -74,7 +74,7 @@ public class QtComponentGraphics extends QtGraphics
r.setLocation(0, 0);
initialClip = r;
- currentAlpha = 1.0;
+ setAlpha( 1.0 );
Color c = component.owner.getBackground();
if(c == null)
setBackground(Color.white);
@@ -86,9 +86,8 @@ public class QtComponentGraphics extends QtGraphics
setColor( Color.black );
else
setColor( c );
-
setup();
- setClip( initialClip );
+ // setClip( initialClip );
}
/**
@@ -101,6 +100,7 @@ public class QtComponentGraphics extends QtGraphics
public Graphics create()
{
+ System.out.println("Componentgraphics.create()");
return new QtComponentGraphics( this );
}
diff --git a/gnu/java/awt/peer/qt/QtComponentPeer.java b/gnu/java/awt/peer/qt/QtComponentPeer.java
index bfebdfdd4..48c44b96d 100644
--- a/gnu/java/awt/peer/qt/QtComponentPeer.java
+++ b/gnu/java/awt/peer/qt/QtComponentPeer.java
@@ -123,7 +123,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
{
this.owner = owner;
this.toolkit = kit;
- qtApp = QtToolkit.guiThread.QApplicationPointer;
+ qtApp = toolkit.guiThread.QApplicationPointer;
nativeObject = 0;
callInit(); // Calls the init method FROM THE MAIN THREAD.
setup();
@@ -145,9 +145,9 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
settingUp = true;
if (owner != null)
{
-// if (owner.getBackground() != null)
-// setBackground(owner.getBackground());
-// else
+ if (owner instanceof javax.swing.JComponent)
+ setBackground(owner.getBackground());
+ else
owner.setBackground(getNativeBackground());
if (owner.getForeground() != null)
@@ -163,15 +163,12 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
setFont(owner.getFont());
setEnabled( owner.isEnabled() );
- setVisible( owner.isVisible() );
-
- Rectangle r = owner.getBounds();
- setBounds( r.x, r.y, r.width, r.height );
- if( drawableComponent() )
- backBuffer = new QtImage( r.width, r.height );
- else
- backBuffer = null;
+
+ backBuffer = null;
dirtyBackBuffer = true;
+ updateBounds();
+
+ setVisible( owner.isVisible() );
}
settingUp = false;
}
@@ -193,6 +190,12 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
(this instanceof QtCanvasPeer));
}
+ void updateBounds()
+ {
+ Rectangle r = owner.getBounds();
+ setBounds( r.x, r.y, r.width, r.height );
+ }
+
// ************ Event methods *********************
/**
@@ -204,7 +207,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
{
WindowEvent e = new WindowEvent((Window)owner,
WindowEvent.WINDOW_CLOSING);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
}
@@ -214,19 +217,19 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
MouseEvent.MOUSE_ENTERED,
System.currentTimeMillis(),
(modifiers & 0x2FF), x, y, 0, false);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void focusInEvent()
{
FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_GAINED);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void focusOutEvent()
{
FocusEvent e = new FocusEvent(owner, FocusEvent.FOCUS_LOST);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void keyPressEvent(int modifiers, int code, int unicode, int dummy)
@@ -238,7 +241,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
modifiers, code, (char)(unicode & 0xFFFF),
KeyEvent.KEY_LOCATION_UNKNOWN);
if (!manager.dispatchEvent (e))
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void keyReleaseEvent(int modifiers, int code, int unicode, int dummy)
@@ -248,7 +251,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
System.currentTimeMillis(),
modifiers, code, (char)(unicode & 0xFFFF),
KeyEvent.KEY_LOCATION_UNKNOWN);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void leaveEvent(int modifiers, int x, int y, int dummy)
@@ -257,7 +260,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
MouseEvent.MOUSE_EXITED,
System.currentTimeMillis(),
(modifiers & 0x2FF), x, y, 0, false);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
// FIXME: Coalesce press-release events into clicks.
@@ -277,7 +280,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
System.currentTimeMillis(),
(modifiers & 0x2FF), x, y, clickCount,
false, button);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void mouseMoveEvent( int modifiers, int x, int y, int clickCount)
@@ -303,15 +306,15 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
timeStamp,
(modifiers & 0x2FF), x, y, clickCount,
false, button);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
lastMME = timeStamp;
}
protected void mousePressEvent( int modifiers, int x, int y, int clickCount)
{
- // if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
- // return;
+ if( (eventMask & AWTEvent.MOUSE_EVENT_MASK) == 0 )
+ return;
int button = 0;
if((modifiers & InputEvent.BUTTON1_DOWN_MASK) ==
InputEvent.BUTTON1_DOWN_MASK) button = 1;
@@ -325,7 +328,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
(modifiers & 0x2FF), x, y, clickCount,
( button == POPUP_TRIGGER ),
button);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void mouseReleaseEvent( int modifiers, int x, int y, int clickCount)
@@ -345,30 +348,14 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
System.currentTimeMillis(),
(modifiers & 0x2FF), x, y, clickCount,
false, button);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void moveEvent()
{
ComponentEvent e = new ComponentEvent(owner,
ComponentEvent.COMPONENT_MOVED);
- QtToolkit.eventQueue.postEvent(e);
- }
-
- protected void paintEvent(QtGraphics g)
- {
- if (backBuffer != null)
- {
- if (dirtyBackBuffer)
- {
- backBuffer.clear();
- Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
- owner.paint(bbg);
- bbg.dispose();
- dirtyBackBuffer = false;
- }
- backBuffer.drawPixels(g, 0, 0, 0, 0, 0, false );
- }
+ toolkit.eventQueue.postEvent(e);
}
protected void resizeEvent(int oldWidth, int oldHeight,
@@ -376,11 +363,14 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
{
dirtyBackBuffer = true;
if( drawableComponent() )
- backBuffer = new QtImage(width, height);
+ {
+ // backBuffer.dispose();
+ backBuffer = new QtImage(width, height);
+ }
owner.setSize(width, height);
ComponentEvent e = new ComponentEvent(owner,
ComponentEvent.COMPONENT_RESIZED);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
protected void showEvent()
@@ -389,13 +379,13 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
{
WindowEvent e = new WindowEvent((Window)owner,
WindowEvent.WINDOW_OPENED);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
else
{
ComponentEvent e = new ComponentEvent(owner,
ComponentEvent.COMPONENT_SHOWN);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
}
@@ -403,7 +393,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
{
ComponentEvent e = new ComponentEvent(owner,
ComponentEvent.COMPONENT_HIDDEN);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
private native Dimension getMinimumSizeNative();
@@ -485,7 +475,6 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
public void flip(BufferCapabilities.FlipContents contents)
{
- // FIXME
}
public Image getBackBuffer()
@@ -510,14 +499,13 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
Rectangle r = owner.getBounds();
backBuffer = new QtImage( r.width, r.height );
}
- dirtyBackBuffer = true;
return backBuffer.getGraphics();
}
public GraphicsConfiguration getGraphicsConfiguration()
{
int id = whichScreen(); // get the ID of the screen the widget is on.
- GraphicsDevice[] devs = QtToolkit.graphicsEnv.getScreenDevices();
+ GraphicsDevice[] devs = toolkit.graphicsEnv.getScreenDevices();
return devs[id].getDefaultConfiguration();
}
@@ -598,7 +586,7 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
public void setBounds(int x, int y, int width, int height)
{
- if(width > 0 && height > 0)
+ if(width > 0 && height > 0 && (drawableComponent() || backBuffer != null))
backBuffer = new QtImage(width, height);
setBoundsNative(x, y, width, height);
}
@@ -639,22 +627,35 @@ public class QtComponentPeer extends NativeWrapper implements ComponentPeer
{
case ComponentEvent.COMPONENT_SHOWN:
case PaintEvent.PAINT:
- case PaintEvent.UPDATE:
+ case PaintEvent.UPDATE:
dirtyBackBuffer = true;
- QtUpdate();
+ QtUpdate();
break;
case KeyEvent.KEY_PRESSED:
- // FIXME
break;
case KeyEvent.KEY_RELEASED:
- // FIXME
break;
}
}
-
+
+ /**
+ * Paint() is called back from the native side in response to a native
+ * repaint event.
+ */
public void paint(Graphics g)
{
- // We don't need to do anything here.
+ if (backBuffer != null)
+ {
+ if (dirtyBackBuffer)
+ {
+ backBuffer.clear();
+ Graphics2D bbg = (Graphics2D)backBuffer.getGraphics();
+ owner.paint(bbg);
+ bbg.dispose();
+ dirtyBackBuffer = false;
+ }
+ backBuffer.drawPixels((QtGraphics)g, 0, 0, 0, 0, 0, false );
+ }
}
public boolean prepareImage(Image img,
diff --git a/gnu/java/awt/peer/qt/QtContainerPeer.java b/gnu/java/awt/peer/qt/QtContainerPeer.java
index 25b5c1786..c906d7a1e 100644
--- a/gnu/java/awt/peer/qt/QtContainerPeer.java
+++ b/gnu/java/awt/peer/qt/QtContainerPeer.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
+import java.awt.Container;
import java.awt.Component;
import java.awt.Insets;
import java.awt.peer.ContainerPeer;
@@ -60,6 +61,7 @@ public class QtContainerPeer extends QtComponentPeer implements ContainerPeer
// ************ Public methods *********************
public void beginLayout()
{
+ // FIXME
}
public void beginValidate()
@@ -68,7 +70,6 @@ public class QtContainerPeer extends QtComponentPeer implements ContainerPeer
public void endLayout()
{
- // FIXME
QtUpdate();
}
diff --git a/gnu/java/awt/peer/qt/QtDialogPeer.java b/gnu/java/awt/peer/qt/QtDialogPeer.java
index 0da2e4ebc..95f3b3c30 100644
--- a/gnu/java/awt/peer/qt/QtDialogPeer.java
+++ b/gnu/java/awt/peer/qt/QtDialogPeer.java
@@ -56,6 +56,7 @@ public class QtDialogPeer extends QtWindowPeer implements DialogPeer
super.setup();
setTitle( ((Dialog)owner).getTitle() );
setResizable( ((Dialog)owner).isResizable() );
+ System.out.println("New dialog, modal:"+((Dialog)owner).isModal() );
setModal( ((Dialog)owner).isModal() );
}
diff --git a/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java b/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
new file mode 100644
index 000000000..7fed456f8
--- /dev/null
+++ b/gnu/java/awt/peer/qt/QtEmbeddedWindowPeer.java
@@ -0,0 +1,61 @@
+/* QtEmbeddedWindowPeer.java -- embedded window peer
+ 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;
+import gnu.java.awt.peer.EmbeddedWindowPeer;
+
+public class QtEmbeddedWindowPeer extends QtWindowPeer implements WindowPeer
+{
+ 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/gnu/java/awt/peer/qt/QtFontPeer.java b/gnu/java/awt/peer/qt/QtFontPeer.java
index ce63577a8..4633a65a8 100644
--- a/gnu/java/awt/peer/qt/QtFontPeer.java
+++ b/gnu/java/awt/peer/qt/QtFontPeer.java
@@ -65,6 +65,7 @@ public class QtFontPeer extends ClasspathFontPeer
public QtFontPeer (String name, int style, int size)
{
super(name, style, size);
+ System.out.println("New Font:"+name);
init();
}
diff --git a/gnu/java/awt/peer/qt/QtFramePeer.java b/gnu/java/awt/peer/qt/QtFramePeer.java
index 56f6132e5..4898f598e 100644
--- a/gnu/java/awt/peer/qt/QtFramePeer.java
+++ b/gnu/java/awt/peer/qt/QtFramePeer.java
@@ -61,6 +61,8 @@ public class QtFramePeer extends QtWindowPeer implements FramePeer
{
super.setup();
setTitle( ((Frame)owner).getTitle() );
+ if( ((Frame)owner).getMenuBar() != null )
+ setMenuBar( ((Frame)owner).getMenuBar() );
}
private native void setIcon(QtImage image);
@@ -86,14 +88,10 @@ public class QtFramePeer extends QtWindowPeer implements FramePeer
public Insets getInsets()
{
- int mbHeight;
- if( ((Frame)owner).getMenuBar() != null )
- mbHeight = menuBarHeight();
- else
- mbHeight = 0;
+ int mbHeight = ( ((Frame)owner).getMenuBar() != null ) ?
+ menuBarHeight() : 0;
- // FIXME : more accurate?
- return new Insets(0, 0, mbHeight, 0);
+ return new Insets(mbHeight, 0, 0, 0);
}
public void setIconImage(Image im)
@@ -110,14 +108,18 @@ public class QtFramePeer extends QtWindowPeer implements FramePeer
public void setMenuBar(MenuBar mb)
{
- if( mb != null)
+ if( mb != null )
{
QtMenuBarPeer mbpeer = (QtMenuBarPeer)mb.getPeer();
- if( mbpeer != null)
+ if( mbpeer == null )
{
- mbpeer.addMenus();
- setMenu( mbpeer );
+ mb.addNotify();
+ mbpeer = (QtMenuBarPeer)mb.getPeer();
+ if( mbpeer == null )
+ throw new IllegalStateException("No menu bar peer.");
}
+ mbpeer.addMenus();
+ setMenu( mbpeer );
}
else
setMenu( null );
diff --git a/gnu/java/awt/peer/qt/QtGraphics.java b/gnu/java/awt/peer/qt/QtGraphics.java
index 8fada89a0..e1a9b8507 100644
--- a/gnu/java/awt/peer/qt/QtGraphics.java
+++ b/gnu/java/awt/peer/qt/QtGraphics.java
@@ -143,7 +143,10 @@ public abstract class QtGraphics extends Graphics2D
}
public synchronized native void delete();
- public synchronized native void dispose();
+
+ public void dispose()
+ {
+ }
// ********************** etc *******************************
@@ -179,7 +182,7 @@ public abstract class QtGraphics extends Graphics2D
private native void setFontNative(QtFontPeer font);
private native QPainterPath getClipNative();
- private void setAlpha(double alpha)
+ void setAlpha(double alpha)
{
currentAlpha = alpha;
setAlphaNative(currentAlpha);
diff --git a/gnu/java/awt/peer/qt/QtImage.java b/gnu/java/awt/peer/qt/QtImage.java
index 6289f2825..53381ceee 100644
--- a/gnu/java/awt/peer/qt/QtImage.java
+++ b/gnu/java/awt/peer/qt/QtImage.java
@@ -100,6 +100,7 @@ public class QtImage extends Image
0x0000FF00,
0x000000FF,
0xFF000000);
+ Vector painters;
/**
* Clears the image to RGBA 0
@@ -245,7 +246,6 @@ public class QtImage extends Image
isLoaded = false;
return;
}
-
errorLoading = false;
isLoaded = true;
}
@@ -364,7 +364,11 @@ public class QtImage extends Image
if (!isLoaded)
return null;
- return new QtImageGraphics(this);
+ QtImageGraphics qig = new QtImageGraphics(this);
+ if( painters == null )
+ painters = new Vector();
+ painters.add( qig );
+ return qig;
}
/**
@@ -403,7 +407,12 @@ public class QtImage extends Image
public void finalize()
{
if (isLoaded)
- freeImage();
+ {
+ if( painters != null )
+ for(int i = 0; i < painters.size(); i++)
+ ((QtImageGraphics)painters.elementAt(i)).dispose();
+ freeImage();
+ }
}
public void dispose()
@@ -585,4 +594,10 @@ public class QtImage extends Image
}
return false;
}
+
+ public String toString()
+ {
+ return "QtImage [isLoaded="+isLoaded+", width="+width+", height="+height
+ +"]";
+ }
}
diff --git a/gnu/java/awt/peer/qt/QtImageGraphics.java b/gnu/java/awt/peer/qt/QtImageGraphics.java
index 1f866a489..c80e6bcda 100644
--- a/gnu/java/awt/peer/qt/QtImageGraphics.java
+++ b/gnu/java/awt/peer/qt/QtImageGraphics.java
@@ -93,20 +93,15 @@ public class QtImageGraphics extends QtGraphics
{
super( g );
parentImage = g.parentImage;
- if( g.topParent == null )
- topParent = g;
- else
- topParent = g.topParent;
- topParent.owners.push( this );
+ if( parentImage instanceof QtImage )
+ ((QtImage)parentImage).painters.add( this );
}
public void dispose()
{
- while(!owners.empty())
- ((QtImageGraphics)owners.pop()).delete();
+ delete();
}
-
/**
* Create a copy of this context.
*/
diff --git a/gnu/java/awt/peer/qt/QtListPeer.java b/gnu/java/awt/peer/qt/QtListPeer.java
index 0ea00ca4c..b1148ae9e 100644
--- a/gnu/java/awt/peer/qt/QtListPeer.java
+++ b/gnu/java/awt/peer/qt/QtListPeer.java
@@ -39,6 +39,8 @@ 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
@@ -54,13 +56,55 @@ public class QtListPeer extends QtComponentPeer implements ListPeer
{
super.setup();
List o = (List)owner;
- String[] items = o.getItems();
+ // 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);
+ toolkit.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);
+ toolkit.eventQueue.postEvent(e);
}
private native void select(int index, boolean selected);
@@ -85,8 +129,11 @@ public class QtListPeer extends QtComponentPeer implements ListPeer
public native void delItems(int start_index, int end_index);
public void deselect(int index)
- {
- select(index, false);
+ {
+ if( ignoreNextSelect == true )
+ ignoreNextSelect = false;
+ else
+ select(index, false);
}
public native int[] getSelectedIndexes();
@@ -110,7 +157,10 @@ public class QtListPeer extends QtComponentPeer implements ListPeer
public void select(int index)
{
- select(index, true);
+ if( ignoreNextSelect == true )
+ ignoreNextSelect = false;
+ else
+ select(index, true);
}
/**
diff --git a/gnu/java/awt/peer/qt/QtMenuBarPeer.java b/gnu/java/awt/peer/qt/QtMenuBarPeer.java
index 7c71da01e..07a8c0b65 100644
--- a/gnu/java/awt/peer/qt/QtMenuBarPeer.java
+++ b/gnu/java/awt/peer/qt/QtMenuBarPeer.java
@@ -62,6 +62,7 @@ public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
void addMenus()
{
MenuBar o = (MenuBar)owner;
+ System.out.println("addMenus:"+o.getMenuCount());
int help = (o.getHelpMenu() != null) ? 1 : 0;
for (int i = 0; i < o.getMenuCount() - help; i++)
addMenu( o.getMenu(i) );
@@ -80,7 +81,7 @@ public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
public void addMenu( Menu m )
{
if (m.getPeer() == null)
- return; // throw null pointer exception? illegalstateexception?
+ m.addNotify();
((QtMenuPeer)m.getPeer()).addItems();
addMenu( (QtMenuPeer)m.getPeer() );
}
@@ -88,7 +89,7 @@ public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
public void addHelpMenu( Menu m )
{
if (m.getPeer() == null)
- return;
+ m.addNotify();
((QtMenuPeer)m.getPeer()).addItems();
addHelpMenu( (QtMenuPeer)m.getPeer() );
}
diff --git a/gnu/java/awt/peer/qt/QtMenuItemPeer.java b/gnu/java/awt/peer/qt/QtMenuItemPeer.java
index 5baf74029..1fea29840 100644
--- a/gnu/java/awt/peer/qt/QtMenuItemPeer.java
+++ b/gnu/java/awt/peer/qt/QtMenuItemPeer.java
@@ -71,12 +71,14 @@ public class QtMenuItemPeer extends QtMenuComponentPeer
public native void dispose();
- private void fireClick()
+ private void fireClick(int modifiers)
{
ActionEvent e = new ActionEvent(owner,
ActionEvent.ACTION_PERFORMED,
- ((MenuItem)owner).getActionCommand());
- QtToolkit.eventQueue.postEvent(e);
+ ((MenuItem)owner).getActionCommand(),
+ System.currentTimeMillis(),
+ (modifiers & 0x2FF));
+ toolkit.eventQueue.postEvent(e);
}
// ************ Public methods *********************
@@ -98,3 +100,9 @@ public class QtMenuItemPeer extends QtMenuComponentPeer
public native void setState(boolean state);
}
+
+
+
+
+
+
diff --git a/gnu/java/awt/peer/qt/QtMenuPeer.java b/gnu/java/awt/peer/qt/QtMenuPeer.java
index 2ad05ced5..fba63d10f 100644
--- a/gnu/java/awt/peer/qt/QtMenuPeer.java
+++ b/gnu/java/awt/peer/qt/QtMenuPeer.java
@@ -88,7 +88,7 @@ public class QtMenuPeer extends QtMenuComponentPeer implements MenuPeer
ActionEvent e = new ActionEvent(owner,
ActionEvent.ACTION_PERFORMED,
((Menu)owner).getActionCommand());
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
private native void allowTearOff();
diff --git a/gnu/java/awt/peer/qt/QtScrollbarPeer.java b/gnu/java/awt/peer/qt/QtScrollbarPeer.java
index 838cca62d..0e203c540 100644
--- a/gnu/java/awt/peer/qt/QtScrollbarPeer.java
+++ b/gnu/java/awt/peer/qt/QtScrollbarPeer.java
@@ -67,7 +67,7 @@ public class QtScrollbarPeer extends QtComponentPeer implements ScrollbarPeer
AdjustmentEvent e = new AdjustmentEvent((Scrollbar)owner,
AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
type, value);
- QtToolkit.eventQueue.postEvent(e);
+ toolkit.eventQueue.postEvent(e);
}
// ************ Public methods *********************
diff --git a/gnu/java/awt/peer/qt/QtTextAreaPeer.java b/gnu/java/awt/peer/qt/QtTextAreaPeer.java
index 7f023f1e3..833ee5e9a 100644
--- a/gnu/java/awt/peer/qt/QtTextAreaPeer.java
+++ b/gnu/java/awt/peer/qt/QtTextAreaPeer.java
@@ -40,6 +40,7 @@ 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.peer.TextAreaPeer;
public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
@@ -54,8 +55,8 @@ public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
protected void setup()
{
super.setup();
-// setText(((TextArea)owner).getText());
-// setEditable(((TextArea)owner).isEditable());
+ setText(((TextArea)owner).getText());
+ setEditable(((TextArea)owner).isEditable());
}
/**
@@ -63,6 +64,15 @@ public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
*/
private native int getSelection(boolean start);
+ /**
+ * Called back on a text edit.
+ */
+ private void textChanged()
+ {
+ TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
+ toolkit.eventQueue.postEvent(e);
+ }
+
// ************ Public methods *********************
public long filterEvents(long filter)
@@ -78,6 +88,9 @@ public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
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,
@@ -113,7 +126,12 @@ public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
public native String getText();
- public native void insert(String text, int pos);
+ 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)
{
diff --git a/gnu/java/awt/peer/qt/QtTextFieldPeer.java b/gnu/java/awt/peer/qt/QtTextFieldPeer.java
index 151adb064..498ad22be 100644
--- a/gnu/java/awt/peer/qt/QtTextFieldPeer.java
+++ b/gnu/java/awt/peer/qt/QtTextFieldPeer.java
@@ -40,6 +40,7 @@ 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.peer.TextFieldPeer;
public class QtTextFieldPeer extends QtComponentPeer implements TextFieldPeer
@@ -59,6 +60,15 @@ public class QtTextFieldPeer extends QtComponentPeer implements TextFieldPeer
}
/**
+ * Called back on a text edit.
+ */
+ private void textChanged()
+ {
+ TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
+ toolkit.eventQueue.postEvent(e);
+ }
+
+ /**
* Returns the start (start = true) or end (start = false) of the selection.
*/
private native int getSelection(boolean start);
diff --git a/gnu/java/awt/peer/qt/QtToolkit.java b/gnu/java/awt/peer/qt/QtToolkit.java
index 5a57b8551..3e94c09ba 100644
--- a/gnu/java/awt/peer/qt/QtToolkit.java
+++ b/gnu/java/awt/peer/qt/QtToolkit.java
@@ -133,7 +133,6 @@ public class QtToolkit extends ClasspathToolkit
private static void initToolkit()
{
eventQueue = new EventQueue();
-
System.loadLibrary("qtpeer");
String theme = null;
@@ -465,7 +464,7 @@ public class QtToolkit extends ClasspathToolkit
public boolean nativeQueueEmpty()
{
- return true;
+ return false;
}
public void wakeNativeQueue()
diff --git a/gnu/java/awt/peer/qt/QtWindowPeer.java b/gnu/java/awt/peer/qt/QtWindowPeer.java
index e64ee65a1..1706137d4 100644
--- a/gnu/java/awt/peer/qt/QtWindowPeer.java
+++ b/gnu/java/awt/peer/qt/QtWindowPeer.java
@@ -37,12 +37,12 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
-import java.awt.Window;
+import java.awt.Component;
import java.awt.peer.WindowPeer;
public class QtWindowPeer extends QtContainerPeer implements WindowPeer
{
- public QtWindowPeer( QtToolkit kit, Window owner )
+ public QtWindowPeer( QtToolkit kit, Component owner )
{
super( kit, owner );
}
diff --git a/native/jni/qt-peer/eventmethods.h b/native/jni/qt-peer/eventmethods.h
new file mode 100644
index 000000000..deb578480
--- /dev/null
+++ b/native/jni/qt-peer/eventmethods.h
@@ -0,0 +1,240 @@
+/* eventmethods.cpp --
+ 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. */
+
+#ifdef I_KNOW_WHAT_IM_DOING
+
+bool draw;
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+
+ void setup(JNIEnv *env, jobject obj)
+ {
+ env->GetJavaVM(&vm);
+ componentCls = NULL;
+ target = env->NewGlobalRef(obj);
+ componentCls = (jclass)env->NewGlobalRef(env->GetObjectClass( target ));
+ setMouseTracking( true );
+ draw = true;
+ }
+
+ void destroy()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ env->DeleteGlobalRef(componentCls);
+ }
+
+ void callVoidMethod(char *methodName)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ }
+
+ void callMouseMethod(char *methodName,
+ int modifiers, int x, int y, int clickCount)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "(IIII)V" );
+ env->CallVoidMethod( target, fireEventID, modifiers, x, y, clickCount );
+ }
+
+protected:
+
+ void closeEvent( QCloseEvent *e )
+ {
+ PARENT::closeEvent(e);
+ callVoidMethod("closeEvent");
+ }
+
+ void focusInEvent( QFocusEvent *e )
+ {
+ PARENT::focusInEvent(e);
+ callVoidMethod("focusInEvent");
+ }
+
+ void focusOutEvent( QFocusEvent *e )
+ {
+ PARENT::focusOutEvent(e);
+ callVoidMethod("focusOutEvent");
+ }
+
+ void enterEvent( QEvent *e )
+ {
+ PARENT::enterEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("enterEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void keyPressEvent( QKeyEvent *e )
+ {
+ PARENT::keyPressEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyPressEvent", modifiers, x, y, 0);
+ }
+
+ void keyReleaseEvent( QKeyEvent *e )
+ {
+ PARENT::keyReleaseEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyReleaseEvent", modifiers, x, y, 0);
+ }
+
+ void leaveEvent( QEvent *e )
+ {
+ PARENT::leaveEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("leaveEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void mouseDoubleClickEvent( QMouseEvent *e )
+ {
+ PARENT::mouseDoubleClickEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 2;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseDoubleClickEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseMoveEvent( QMouseEvent *e )
+ {
+ PARENT::mouseMoveEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseMoveEvent", modifiers, x, y, clickCount);
+ }
+
+ void mousePressEvent( QMouseEvent *e )
+ {
+ PARENT::mousePressEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mousePressEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseReleaseEvent( QMouseEvent *e )
+ {
+ PARENT::mouseReleaseEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseReleaseEvent", modifiers, x, y, clickCount);
+ }
+
+ void moveEvent( QMoveEvent *e )
+ {
+ PARENT::moveEvent(e);
+ callVoidMethod("moveEvent");
+ }
+
+ void resizeEvent( QResizeEvent *e )
+ {
+ PARENT::resizeEvent(e);
+ callMouseMethod("resizeEvent",
+ e->oldSize().width(), e->oldSize().height(),
+ e->size().width(), e->size().height());
+ }
+
+ void hideEvent( QHideEvent *e )
+ {
+ PARENT::hideEvent(e);
+ callVoidMethod("hideEvent");
+ }
+
+ void showEvent( QShowEvent *e )
+ {
+ PARENT::showEvent(e);
+ callVoidMethod("showEvent");
+ }
+
+ void paintEvent ( QPaintEvent * e )
+ {
+ PARENT::paintEvent( e );
+ if ( draw )
+ {
+ // Create a QPainter
+ GraphicsPainter painter( this );
+
+ // Get the environment.
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+
+ // create a QtGraphics wrapper for the QPainter
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtComponentGraphics" );
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(JLgnu/java/awt/peer/qt/QtComponentPeer;)V");
+ jobject graphics = env->NewObject(cls, mid, (jlong)&painter, target);
+
+ // call QtComponentPeer.paintEvent()
+ jmethodID paintEventID = env->GetMethodID( componentCls,
+ "paint",
+ "(Ljava/awt/Graphics;)V" );
+ env->CallVoidMethod( target, paintEventID, graphics );
+ env->DeleteLocalRef( cls );
+ env->DeleteLocalRef( graphics );
+ painter.end();
+ }
+ }
+
+#endif
diff --git a/native/jni/qt-peer/keybindings.cpp b/native/jni/qt-peer/keybindings.cpp
index ff2a8a461..ec2d3f3f0 100644
--- a/native/jni/qt-peer/keybindings.cpp
+++ b/native/jni/qt-peer/keybindings.cpp
@@ -501,6 +501,9 @@ int getUnicode(QKeyEvent *key)
return (int)c.unicode();
}
+/**
+ * Returns the key modifiers in KeyEvent format
+ */
int getKeyModifiers(Qt::KeyboardModifiers state)
{
int modifier = 0;
@@ -516,10 +519,31 @@ int getKeyModifiers(Qt::KeyboardModifiers state)
return modifier;
}
+/**
+ * Returns the key modifiers in ActionEvent format
+ */
+int getAEKeyModifiers(Qt::KeyboardModifiers state)
+{
+ int modifier = 0;
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_MASK;
+
+ return modifier;
+}
+
+/**
+ * Returns the mouse modifiers in InputEvent format
+ */
int getMouseModifiers(QMouseEvent *e)
{
int modifier = 0;
- int buttons = e->buttons();
+ int buttons = e->button();
int state = e->modifiers();
if( buttons & Qt::LeftButton )
diff --git a/native/jni/qt-peer/keybindings.h b/native/jni/qt-peer/keybindings.h
index 02ff894bd..f509c8c62 100644
--- a/native/jni/qt-peer/keybindings.h
+++ b/native/jni/qt-peer/keybindings.h
@@ -13,6 +13,7 @@
int mapKeyCode(QKeyEvent *key);
int getUnicode(QKeyEvent *key);
int getKeyModifiers(Qt::KeyboardModifiers state);
+int getAEKeyModifiers(Qt::KeyboardModifiers state);
int getMouseModifiers(QMouseEvent *event);
#endif
diff --git a/native/jni/qt-peer/qtbuttonpeer.cpp b/native/jni/qt-peer/qtbuttonpeer.cpp
index 6ec90e2c4..b807ed466 100644
--- a/native/jni/qt-peer/qtbuttonpeer.cpp
+++ b/native/jni/qt-peer/qtbuttonpeer.cpp
@@ -61,7 +61,7 @@ public:
}
#define I_KNOW_WHAT_IM_DOING
#define PARENT QPushButton
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
/**
diff --git a/native/jni/qt-peer/qtcanvaspeer.cpp b/native/jni/qt-peer/qtcanvaspeer.cpp
index 1d3fcb338..9cdbaef8a 100644
--- a/native/jni/qt-peer/qtcanvaspeer.cpp
+++ b/native/jni/qt-peer/qtcanvaspeer.cpp
@@ -57,7 +57,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QWidget
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
/*
diff --git a/native/jni/qt-peer/qtcheckboxpeer.cpp b/native/jni/qt-peer/qtcheckboxpeer.cpp
index 46329cb43..c7bbe5511 100644
--- a/native/jni/qt-peer/qtcheckboxpeer.cpp
+++ b/native/jni/qt-peer/qtcheckboxpeer.cpp
@@ -81,7 +81,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QCheckBox
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
/**
diff --git a/native/jni/qt-peer/qtchoicepeer.cpp b/native/jni/qt-peer/qtchoicepeer.cpp
index 2a194cdf5..f77d3a0cf 100644
--- a/native/jni/qt-peer/qtchoicepeer.cpp
+++ b/native/jni/qt-peer/qtchoicepeer.cpp
@@ -89,7 +89,6 @@ class RemoveSelectEvent : public AWTEvent {
}
};
-
/*
* Constructs tha QComboBox object
*/
diff --git a/native/jni/qt-peer/qtcomponent.cpp b/native/jni/qt-peer/qtcomponent.cpp
index d9ddd7e20..fc7480091 100644
--- a/native/jni/qt-peer/qtcomponent.cpp
+++ b/native/jni/qt-peer/qtcomponent.cpp
@@ -49,10 +49,10 @@ exception statement from your version. */
*/
void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer )
{
- jclass componentCls = env->FindClass( COMPONENT_CLASS );
+ jclass componentCls = env->GetObjectClass( qtcomponentpeer );
jfieldID ownerField = env->GetFieldID( componentCls,
"owner", "Ljava/awt/Component;" );
-
+ assert( ownerField );
jobject owner = env->GetObjectField( qtcomponentpeer, ownerField );
if (owner == NULL)
return NULL;
diff --git a/native/jni/qt-peer/qtcomponentpeer.cpp b/native/jni/qt-peer/qtcomponentpeer.cpp
index 931423644..c940574fa 100644
--- a/native/jni/qt-peer/qtcomponentpeer.cpp
+++ b/native/jni/qt-peer/qtcomponentpeer.cpp
@@ -82,7 +82,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_callInit
env->MonitorEnter( obj );
p = getNativeObject(env, obj);
env->MonitorExit( obj );
- } while( p == NULL);
+ } while( p == NULL );
}
/*
diff --git a/native/jni/qt-peer/qtdialogpeer.cpp b/native/jni/qt-peer/qtdialogpeer.cpp
index e3ec88111..0eb709443 100644
--- a/native/jni/qt-peer/qtdialogpeer.cpp
+++ b/native/jni/qt-peer/qtdialogpeer.cpp
@@ -59,7 +59,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QDialog
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
class DialogSettingsEvent : public AWTEvent {
diff --git a/native/jni/qt-peer/qtembeddedwindowpeer.cpp b/native/jni/qt-peer/qtembeddedwindowpeer.cpp
new file mode 100644
index 000000000..dbbf87ea4
--- /dev/null
+++ b/native/jni/qt-peer/qtembeddedwindowpeer.cpp
@@ -0,0 +1,113 @@
+/* qtembeddedwindowpeer.cpp --
+ 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. */
+
+#include <assert.h>
+#include <QWidget>
+#include <QX11EmbedWidget>
+#include <gnu_java_awt_peer_qt_QtEmbeddedWindowPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+/**
+ * Event wrapper for embedding.
+ */
+class EmbedEvent : public AWTEvent {
+
+ private:
+ QX11EmbedWidget *widget;
+ WId id;
+
+ public:
+ EmbedEvent(QX11EmbedWidget *w, WId i) : AWTEvent()
+ {
+ widget = w;
+ id = i;
+ }
+
+ void runEvent()
+ {
+ widget->embedInto( id );
+ }
+};
+
+
+class MyEmbeddedPanel : public QX11EmbedWidget
+{
+public:
+ MyEmbeddedPanel(JNIEnv *env, jobject obj, QWidget *parent) : QX11EmbedWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyEmbeddedPanel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QX11EmbedWidget
+#include "eventmethods.h"
+#undef I_KNOW_WHAT_IM_DOING
+#undef PARENT
+};
+
+/**
+ * Init
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QWidget *panel = new MyEmbeddedPanel( env, obj, parentWidget );
+ assert( panel );
+
+ setNativeObject( env, obj, panel );
+}
+
+/**
+ * Embed the thing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_embed
+(JNIEnv *env, jobject obj, jlong wid)
+{
+ MyEmbeddedPanel *panel = (MyEmbeddedPanel *)getNativeObject( env, obj );
+ assert( panel );
+
+ mainThread->postEventToMain( new EmbedEvent( panel, (WId)wid ) );
+}
+
diff --git a/native/jni/qt-peer/qtframepeer.cpp b/native/jni/qt-peer/qtframepeer.cpp
index 9005311b0..e4060c684 100644
--- a/native/jni/qt-peer/qtframepeer.cpp
+++ b/native/jni/qt-peer/qtframepeer.cpp
@@ -68,7 +68,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QMainWindow
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
/**
@@ -104,10 +104,10 @@ class FrameGetMenuHeightEvent : public AWTEvent {
private:
QMainWindow *frame;
- int *value;
+ int **value;
public:
- FrameGetMenuHeightEvent(QMainWindow *w, int *v) : AWTEvent()
+ FrameGetMenuHeightEvent(QMainWindow *w, int **v) : AWTEvent()
{
frame = w;
value = v;
@@ -117,13 +117,8 @@ public:
{
QMenuBar *mb = frame->menuBar();
assert( mb );
- int v;
- if( mb->isVisible() )
- v = mb->size().height();
-
- if(v <= 0 || v >= 0xFFFFF ) // Work around for strange values.
- v = MenuSizeDefault;
-
+ int *v = (int *)malloc( sizeof( int ) );
+ *v = mb->sizeHint().height();
*value = v;
}
};
@@ -139,11 +134,14 @@ QWidget *frameChildWidget( JNIEnv *env, jobject component )
"getPeer",
"()Ljava/awt/peer/ComponentPeer;" );
assert(getPeerMID);
- jobject framepeerobj = env->CallObjectMethod( component, getPeerMID, 0);
- QMainWindow *window = (QMainWindow *)getNativeObject(env, framepeerobj);
+ jobject framepeerobj = env->CallObjectMethod( component, getPeerMID, 0);
+ if( framepeerobj == NULL )
+ return (QWidget *)NULL;
- return window->centralWidget();
+ MyWindow *window = (MyWindow *)getNativeObject(env, framepeerobj);
+ assert( window );
+ return window;
}
/*
@@ -158,7 +156,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init
QWidget *central = new QWidget( frame );
assert( central );
- frame->setCentralWidget( central );
setNativeObject( env, obj, frame );
}
@@ -171,13 +168,13 @@ JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_menuBarHeight
QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
assert( frame );
- int value = 0;
+ int *value = NULL;
mainThread->postEventToMain( new FrameGetMenuHeightEvent( frame, &value ) );
- while(value == 0); // (Busy) wait for the value to
+ while(value == NULL); // (Busy) wait for the value to
// get set by the main thread.
- return (jint)value;
+ return (jint)(*value);
}
/*
diff --git a/native/jni/qt-peer/qtgraphics.cpp b/native/jni/qt-peer/qtgraphics.cpp
index 1abcc9f08..502cbedf8 100644
--- a/native/jni/qt-peer/qtgraphics.cpp
+++ b/native/jni/qt-peer/qtgraphics.cpp
@@ -119,6 +119,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initImage
painter->setRenderHint(QPainter::TextAntialiasing);
}
+/**
+ * Deletes the QPainter
+ */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_delete
(JNIEnv *env, jobject obj)
{
@@ -132,19 +135,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_delete
}
}
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_dispose
-(JNIEnv *env, jobject obj)
-{
-// GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
-// setNativePtr( env, obj, NULL );
-// if( painter )
-// {
-// if( painter->isActive() )
-// painter->end();
-// delete painter;
-// }
-}
-
///////////////////////////////////////////////////////////
/*
* Sets the clip to a path.
@@ -412,11 +402,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeComposite
painter->setCompositionMode( mode );
}
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getFontMetrics
-(JNIEnv *env, jobject obj, jobject font)
-{
-}
-
/**
* Sets the current brush to a linear gradient.
*/
diff --git a/native/jni/qt-peer/qtimage.cpp b/native/jni/qt-peer/qtimage.cpp
index 778ab5af8..4d2b5b90a 100644
--- a/native/jni/qt-peer/qtimage.cpp
+++ b/native/jni/qt-peer/qtimage.cpp
@@ -292,10 +292,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixels
assert( image );
QPainter *painter = getPainter( env, graphics );
assert( painter );
-
if(composite == JNI_TRUE)
painter->fillRect ( x, y, image->width(), image->height(),
- QColor(bg_red, bg_green, bg_blue ) );
+ QColor(bg_red, bg_green, bg_blue ) );
painter->drawImage ( QPoint(x, y), *image );
}
@@ -371,8 +370,13 @@ Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaledFlipped
QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
(qreal)dstwidth, (qreal)dstheight);
- QImage image = originalImage->mirrored ( (flipx == JNI_TRUE),
- (flipy == JNI_TRUE) );
+ QImage image;
+ if( flipx == JNI_TRUE || flipy == JNI_TRUE)
+ image = originalImage->mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ else
+ image = *originalImage;
+
if(composite == JNI_TRUE)
painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
diff --git a/native/jni/qt-peer/qtlabelpeer.cpp b/native/jni/qt-peer/qtlabelpeer.cpp
index 895994e80..196f0cdd5 100644
--- a/native/jni/qt-peer/qtlabelpeer.cpp
+++ b/native/jni/qt-peer/qtlabelpeer.cpp
@@ -64,7 +64,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QLabel
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
class LabelTitle : public AWTEvent {
@@ -103,7 +103,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_init
(JNIEnv *env, jobject obj)
{
QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
- // QLabel *label = new QLabel( parentWidget );
QLabel *label = new MyLabel( env, obj, parentWidget );
assert( label );
setNativeObject( env, obj, label );
diff --git a/native/jni/qt-peer/qtlistpeer.cpp b/native/jni/qt-peer/qtlistpeer.cpp
index b702d7bca..027d47880 100644
--- a/native/jni/qt-peer/qtlistpeer.cpp
+++ b/native/jni/qt-peer/qtlistpeer.cpp
@@ -42,6 +42,7 @@ exception statement from your version. */
#include "qtcomponent.h"
#include "qtstrings.h"
#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
class ListInsert : public AWTEvent {
@@ -119,6 +120,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_init
assert( list );
setNativeObject( env, obj, list );
+ connectList(list, env, obj);
}
/*
diff --git a/native/jni/qt-peer/qtmenupeer.cpp b/native/jni/qt-peer/qtmenupeer.cpp
index 568074b17..fc8b0a5d6 100644
--- a/native/jni/qt-peer/qtmenupeer.cpp
+++ b/native/jni/qt-peer/qtmenupeer.cpp
@@ -104,7 +104,7 @@ public:
*newAction = menu->addAction(action->text());
(*newAction)->setSeparator(action->isSeparator());
(*newAction)->setCheckable(action->isCheckable());
- delete action;
+ // delete action;
break;
case ADDSEPA:
*newAction = menu->addSeparator();
diff --git a/native/jni/qt-peer/qtpanelpeer.cpp b/native/jni/qt-peer/qtpanelpeer.cpp
index 41ee1a28c..68aef4864 100644
--- a/native/jni/qt-peer/qtpanelpeer.cpp
+++ b/native/jni/qt-peer/qtpanelpeer.cpp
@@ -56,11 +56,14 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QWidget
-#include "eventmethods.cpp"
+#include "eventmethods.h"
#undef I_KNOW_WHAT_IM_DOING
#undef PARENT
};
+/**
+ * Init
+ */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPanelPeer_init
(JNIEnv *env, jobject obj)
{
diff --git a/native/jni/qt-peer/qtscrollbarpeer.cpp b/native/jni/qt-peer/qtscrollbarpeer.cpp
index 1af3db7fc..0649ebd17 100644
--- a/native/jni/qt-peer/qtscrollbarpeer.cpp
+++ b/native/jni/qt-peer/qtscrollbarpeer.cpp
@@ -61,7 +61,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QScrollBar
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
/*
diff --git a/native/jni/qt-peer/qtscrollpanepeer.cpp b/native/jni/qt-peer/qtscrollpanepeer.cpp
index 417c182a3..246155cdf 100644
--- a/native/jni/qt-peer/qtscrollpanepeer.cpp
+++ b/native/jni/qt-peer/qtscrollpanepeer.cpp
@@ -66,7 +66,7 @@ public:
#define I_KNOW_WHAT_IM_DOING
#define PARENT QScrollArea
-#include "eventmethods.cpp"
+#include "eventmethods.h"
};
@@ -128,9 +128,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_childResized
{
QScrollArea *view = (QScrollArea *) getNativeObject( env, obj );
assert( view );
+ printf("XXX: child size: %i %i\n", w, h);
QWidget *child = view->viewport();
assert( child );
+ // child->setGeometry( 0, 0, w, h );
+// child->update();
mainThread->postEventToMain( new AWTResizeEvent(child, 0, 0, w, h) );
}
diff --git a/native/jni/qt-peer/qttextareapeer.cpp b/native/jni/qt-peer/qttextareapeer.cpp
index ceb3847da..50f85b861 100644
--- a/native/jni/qt-peer/qttextareapeer.cpp
+++ b/native/jni/qt-peer/qttextareapeer.cpp
@@ -40,10 +40,30 @@ exception statement from your version. */
#include <QTextEdit>
#include <QTextCursor>
#include <gnu_java_awt_peer_qt_QtTextAreaPeer.h>
+#include "mainthreadinterface.h"
+#include "componentevent.h"
+#include "slotcallbacks.h"
#include "qtcomponent.h"
#include "qtstrings.h"
-// FIXME: This stuff ain't thread safe.
+class TASetText : public AWTEvent {
+ private:
+ QTextEdit *area;
+ QString *text;
+
+ public:
+ TASetText(QTextEdit *w, QString *t) : AWTEvent()
+ {
+ area = w;
+ text = t;
+ }
+
+ void runEvent()
+ {
+ area->setPlainText( *text );
+ delete text;
+ }
+};
/*
* Construct a QTextEdit object
@@ -58,8 +78,10 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_init
assert( editor );
// setLineWrapColumnOrWidth ( int w );
-
setNativeObject( env, obj, editor );
+
+ // Connect TextChanged events.
+ connectTextEdit(editor, env, obj);
}
/*
@@ -124,24 +146,6 @@ JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getText
}
/*
- * Inserts text.
- */
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_insert
-(JNIEnv *env, jobject obj, jstring str, jint index)
-{
- QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
- assert( editor );
-
- QTextCursor curs = editor->textCursor();
- int oldPos = curs.position();
- curs.setPosition( index );
- QString *qStr = getQString(env, str);
- curs.insertText( *qStr );
- delete qStr;
- curs.setPosition( oldPos );
-}
-
-/*
* Sets the editor text.
*/
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText
@@ -151,8 +155,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText
assert( editor );
QString *qStr = getQString(env, str);
- editor->setPlainText( *qStr );
- delete qStr;
+ mainThread->postEventToMain( new TASetText( editor, qStr ) );
}
/*
@@ -163,9 +166,11 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_select
{
QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
assert( editor );
- // FIXME
-// QTextCursor curs = editor->textCursor();
-// editor->setSelection ( 0, startpos, 0, endpos );
+
+ QTextCursor curs(editor->document());
+ curs.setPosition(startpos);
+ curs.setPosition(endpos, QTextCursor::KeepAnchor);
+ editor->setTextCursor( curs );
}
/*
diff --git a/native/jni/qt-peer/qttextfieldpeer.cpp b/native/jni/qt-peer/qttextfieldpeer.cpp
index da128fb41..5c7113379 100644
--- a/native/jni/qt-peer/qttextfieldpeer.cpp
+++ b/native/jni/qt-peer/qttextfieldpeer.cpp
@@ -41,6 +41,7 @@ exception statement from your version. */
#include <gnu_java_awt_peer_qt_QtTextFieldPeer.h>
#include "qtcomponent.h"
#include "qtstrings.h"
+#include "slotcallbacks.h"
#include "mainthreadinterface.h"
class TFEchoChar : public AWTEvent {
@@ -147,6 +148,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_init
assert( line );
setNativeObject( env, obj, line );
+ connectLineEdit(line, env, obj);
}
diff --git a/native/jni/qt-peer/qtwindowpeer.cpp b/native/jni/qt-peer/qtwindowpeer.cpp
index 8257051e0..4808ac3be 100644
--- a/native/jni/qt-peer/qtwindowpeer.cpp
+++ b/native/jni/qt-peer/qtwindowpeer.cpp
@@ -99,19 +99,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_init
}
/*
- * Destructor
- */
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_destroy
-(JNIEnv *env, jobject obj)
-{
- QWidget *window = (QWidget *) getNativeObject( env, obj );
- assert( window );
-
- setNativeObject(env, obj, NULL);
- delete window;
-}
-
-/*
* Lower the window.
*/
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toBack
diff --git a/native/jni/qt-peer/slotcallbacks.cpp b/native/jni/qt-peer/slotcallbacks.cpp
index 38a22b16a..3e0820477 100644
--- a/native/jni/qt-peer/slotcallbacks.cpp
+++ b/native/jni/qt-peer/slotcallbacks.cpp
@@ -40,7 +40,10 @@ exception statement from your version. */
#include <QAbstractSlider>
#include <QAction>
#include <QComboBox>
+#include <QListWidget>
+#include <QLineEdit>
#include <QPushButton>
+#include <QTextEdit>
#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
#include "qtcomponent.h"
#include "qtstrings.h"
@@ -67,6 +70,7 @@ private:
public:
QScrollBar *sb; // used only by the scrollbar method.
+ QListWidget *lw; // used only by the listitemclicked method
SlotCallback(JNIEnv *env, jobject t)
{
@@ -82,7 +86,8 @@ public:
env->DeleteGlobalRef(target);
}
-public slots:
+ public slots:
+
void buttonClicked()
{
JNIEnv *env;
@@ -91,7 +96,7 @@ public slots:
fireEventID = env->GetMethodID( componentCls,
"fireClick",
"(I)V" );
- int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
env->CallVoidMethod( target, fireEventID, modifiers );
env->DeleteLocalRef( componentCls );
}
@@ -110,7 +115,8 @@ public slots:
env->CallVoidMethod( target, fireEventID, JNI_FALSE );
env->DeleteLocalRef( componentCls );
}
-
+
+ // Used for List and Choice
void choiceActivated( int index )
{
JNIEnv *env;
@@ -123,6 +129,18 @@ public slots:
env->DeleteLocalRef( componentCls );
}
+ void textChanged()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "textChanged",
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ env->DeleteLocalRef( componentCls );
+ }
+
void scrollBarAction( int action )
{
JNIEnv *env;
@@ -163,9 +181,23 @@ public slots:
env->CallVoidMethod( target, fireEventID, (jint)type, (jint)index );
env->DeleteLocalRef( componentCls );
}
+
+ void listItemClicked( QListWidgetItem * item )
+ {
+ int index = lw->row( item );
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "itemDoubleClicked",
+ "(II)V" );
+ int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
+ env->CallVoidMethod( target, fireEventID, index, modifiers );
+ env->DeleteLocalRef( componentCls );
+ }
};
-#include "slotcallbacks.moc"
+#include "slotcallbacks.moc.h"
void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj)
{
@@ -179,6 +211,16 @@ void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj)
QObject::connect( choice, SIGNAL( activated(int) ), scb, SLOT( choiceActivated(int) ) );
}
+void connectList(QListWidget *list, JNIEnv *env, jobject listobj)
+{
+ SlotCallback *scb = new SlotCallback(env, listobj);
+ scb->lw = list;
+ QObject::connect( list, SIGNAL( currentRowChanged(int) ),
+ scb, SLOT( choiceActivated(int) ) );
+ QObject::connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem * )),
+ scb, SLOT( listItemClicked( QListWidgetItem * )));
+}
+
void connectAction(QAction *action, JNIEnv *env, jobject obj)
{
SlotCallback *scb = new SlotCallback(env, obj);
@@ -197,3 +239,18 @@ void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj)
scb->sb = scroll;
QObject::connect( scroll, SIGNAL( actionTriggered(int) ), scb, SLOT( scrollBarAction(int) ) );
}
+
+void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( edit, SIGNAL( textChanged() ),
+ scb, SLOT( textChanged() ) );
+}
+
+void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( edit, SIGNAL(textChanged( QString ) ),
+ scb, SLOT( textChanged() ) );
+}
+
diff --git a/native/jni/qt-peer/slotcallbacks.h b/native/jni/qt-peer/slotcallbacks.h
index 3929bde7a..88c292ce7 100644
--- a/native/jni/qt-peer/slotcallbacks.h
+++ b/native/jni/qt-peer/slotcallbacks.h
@@ -5,8 +5,11 @@
#include <QAbstractSlider>
#include <QAction>
#include <QComboBox>
+#include <QListWidget>
+#include <QLineEdit>
#include <QPushButton>
#include <QScrollBar>
+#include <QTextEdit>
#include <jni.h>
void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj);
@@ -14,5 +17,8 @@ void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj);
void connectAction(QAction *action, JNIEnv *env, jobject obj);
void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj);
void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj);
+void connectList(QListWidget *list, JNIEnv *env, jobject choiceobj);
+void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj);
+void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj);
#endif
diff --git a/native/jni/qt-peer/slotcallbacks.moc.h b/native/jni/qt-peer/slotcallbacks.moc.h
new file mode 100644
index 000000000..dd69e1f6c
--- /dev/null
+++ b/native/jni/qt-peer/slotcallbacks.moc.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'slotcallbacks.cpp'
+**
+** Created: Tue Aug 16 00:30:30 2005
+** by: The Qt Meta Object Compiler version 58 (Qt 4.0.0)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'slotcallbacks.cpp' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 58
+#error "This file was generated using the moc from 4.0.0. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+static const uint qt_meta_data_SlotCallback[] = {
+
+ // content:
+ 1, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 6, 10, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+ 14, 13, 13, 13, 0x0a,
+ 38, 30, 13, 13, 0x0a,
+ 64, 58, 13, 13, 0x0a,
+ 85, 13, 13, 13, 0x0a,
+ 106, 99, 13, 13, 0x0a,
+ 132, 127, 13, 13, 0x0a,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_SlotCallback[] = {
+ "SlotCallback\0\0buttonClicked()\0checked\0buttonToggled(bool)\0index\0"
+ "choiceActivated(int)\0textChanged()\0action\0scrollBarAction(int)\0item\0"
+ "listItemClicked(QListWidgetItem*)\0"
+};
+
+const QMetaObject SlotCallback::staticMetaObject = {
+ { &QObject::staticMetaObject, qt_meta_stringdata_SlotCallback,
+ qt_meta_data_SlotCallback, 0 }
+};
+
+const QMetaObject *SlotCallback::metaObject() const
+{
+ return &staticMetaObject;
+}
+
+void *SlotCallback::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_SlotCallback))
+ return static_cast<void*>(const_cast<SlotCallback*>(this));
+ return QObject::qt_metacast(_clname);
+}
+
+int SlotCallback::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QObject::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: buttonClicked(); break;
+ case 1: buttonToggled(*(bool*)_a[1]); break;
+ case 2: choiceActivated(*(int*)_a[1]); break;
+ case 3: textChanged(); break;
+ case 4: scrollBarAction(*(int*)_a[1]); break;
+ case 5: listItemClicked(*(QListWidgetItem**)_a[1]); break;
+ }
+ _id -= 6;
+ }
+ return _id;
+}