diff options
Diffstat (limited to 'gnu/java/awt/peer')
22 files changed, 273 insertions, 107 deletions
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 ); } |