I have started to implemented the peers for Drag and Drop. It is coming along :)
Most of the functions in the peers are still not implemented. I am working on it. 2006-07-06 Lillian Angel <[EMAIL PROTECTED]> * gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java: New class not fully implemented. * gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java: New class not fully implemented. * gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java: New class not fully implemented. * gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java: New class not fully implemented. * nu/java/awt/peer/gtk/GtkToolkit.java: Fixed Imports. (createDragSourceContextPeer): Implemented. (createDragGestureRecognizer): New function to override java.awt.Toolkit.createDragGestureRecognizer. * java/awt/dnd/DragSource.java (NoDragGestureRecognizer): Removed inner class. (createDragGestureRecognizer): Re-Implemented to call Toolkit's createDragGestureRecognizer. (createDefaultDragGestureRecognizer): Re-Implemented to call Toolkit's createDragGestureRecognizer. * java/awt/dnd/DropTarget.java (addNotify): Added check to determine type of peer and call addDropTarget. (removeNotify): Added call to removeDropTarget.
Index: gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java =================================================================== RCS file: gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java diff -N gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/java/awt/dnd/GtkMouseDragGestureRecognizer.java 6 Jul 2006 19:40:20 -0000 @@ -0,0 +1,110 @@ +/* GtkMouseDragGestureRecognizer.java -- + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.dnd; + +import java.awt.Component; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.MouseDragGestureRecognizer; +import java.awt.event.MouseEvent; + +public class GtkMouseDragGestureRecognizer + extends MouseDragGestureRecognizer +{ + + DragSource ds; + Component c; + int actions; + DragGestureListener dgl; + + GtkMouseDragGestureRecognizer() + { + super(null); + } + + public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act, + DragGestureListener dgl) + { + super (ds, c, act, dgl); + + registerListeners(); + + this.ds = ds; + this.c = c; + this.actions = act; + this.dgl = dgl; + } + + public void mouseClicked (MouseEvent e) + { + // FIXME: Not Implemented + } + + public void mousePressed (MouseEvent e) + { + // FIXME: Not Implemented + } + + public void mouseReleased (MouseEvent e) + { + // FIXME: Not Implemented + } + + public void mouseEntered (MouseEvent e) + { + // FIXME: Not Implemented + } + + public void mouseExited (MouseEvent e) + { + // FIXME: Not Implemented + } + + public void mouseDragged(MouseEvent e) + { + dgl.dragGestureRecognized(new DragGestureEvent(this, actions, e.getPoint(), + events)); + } + + public void mouseMoved (MouseEvent e) + { + // FIXME: Not Implemented + } +} Index: gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java =================================================================== RCS file: gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java diff -N gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java 6 Jul 2006 19:40:20 -0000 @@ -0,0 +1,81 @@ +/* GtkDragSourceContextPeer.java -- + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.dnd.peer.gtk; + +import java.awt.Cursor; +import java.awt.Image; +import java.awt.Point; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragSourceContext; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; + +public class GtkDragSourceContextPeer + implements DragSourceContextPeer +{ + + private DragGestureEvent dge; + + public GtkDragSourceContextPeer(DragGestureEvent e) + { + dge = e; + } + + public void startDrag(DragSourceContext context, Cursor c, Image i, Point p) + throws InvalidDnDOperationException + { + // FIXME: Not Implemented + } + + public Cursor getCursor() + { + // FIXME: Not Implemented + return null; + } + + public void setCursor(Cursor c) throws InvalidDnDOperationException + { + // FIXME: Not Implemented + } + + public void transferablesFlavorsChanged() + { + // FIXME: Not Implemented + } +} Index: gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java =================================================================== RCS file: gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java diff -N gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/java/awt/dnd/peer/gtk/GtkDropTargetContextPeer.java 6 Jul 2006 19:40:20 -0000 @@ -0,0 +1,117 @@ +/* GtkDropTargetContextPeer.java -- + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.dnd.peer.gtk; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DropTargetContextPeer; + +public class GtkDropTargetContextPeer + implements DropTargetContextPeer +{ + + public void setTargetActions(int actions) + { + // FIXME: Not Implemented + + } + + public int getTargetActions() + { + // FIXME: Not Implemented + return 0; + } + + public DropTarget getDropTarget() + { + // FIXME: Not Implemented + return null; + } + + public DataFlavor[] getTransferDataFlavors() + { + // FIXME: Not Implemented + return null; + } + + public Transferable getTransferable() throws InvalidDnDOperationException + { + // FIXME: Not Implemented + return null; + } + + public boolean isTransferableJVMLocal() + { + // FIXME: Not Implemented + return false; + } + + public void acceptDrag(int dragAction) + { + // FIXME: Not Implemented + + } + + public void rejectDrag() + { + // FIXME: Not Implemented + + } + + public void acceptDrop(int dropAction) + { + // FIXME: Not Implemented + + } + + public void rejectDrop() + { + // FIXME: Not Implemented + + } + + public void dropComplete(boolean success) + { + // FIXME: Not Implemented + + } + +} Index: gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java =================================================================== RCS file: gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java diff -N gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/java/awt/dnd/peer/gtk/GtkDropTargetPeer.java 6 Jul 2006 19:40:20 -0000 @@ -0,0 +1,60 @@ +/* GtkDropTargetPeer.java -- + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.java.awt.dnd.peer.gtk; + +import java.awt.dnd.DropTarget; +import java.awt.dnd.peer.DropTargetPeer; + +public class GtkDropTargetPeer + implements DropTargetPeer +{ + + public void addDropTarget(DropTarget target) + { + // FIXME: Not Implemented + + } + + public void removeDropTarget(DropTarget target) + { + // FIXME: Not Implemented + + } + +} Index: gnu/java/awt/peer/gtk/GtkToolkit.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,v retrieving revision 1.89 diff -u -r1.89 GtkToolkit.java --- gnu/java/awt/peer/gtk/GtkToolkit.java 30 Jun 2006 18:20:06 -0000 1.89 +++ gnu/java/awt/peer/gtk/GtkToolkit.java 6 Jul 2006 19:40:20 -0000 @@ -39,31 +39,82 @@ package gnu.java.awt.peer.gtk; -import gnu.classpath.Configuration; import gnu.java.awt.EmbeddedWindow; +import gnu.java.awt.dnd.GtkMouseDragGestureRecognizer; +import gnu.java.awt.dnd.peer.gtk.GtkDragSourceContextPeer; import gnu.java.awt.peer.ClasspathFontPeer; import gnu.java.awt.peer.EmbeddedWindowPeer; -import java.awt.*; +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.CheckboxMenuItem; +import java.awt.Choice; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FileDialog; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.Point; +import java.awt.PopupMenu; +import java.awt.PrintJob; +import java.awt.Rectangle; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.Window; import java.awt.datatransfer.Clipboard; import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.font.FontRenderContext; import java.awt.im.InputMethodHighlight; -import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DirectColorModel; -import java.awt.image.ImageConsumer; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; -import java.awt.peer.*; +import java.awt.peer.ButtonPeer; +import java.awt.peer.CanvasPeer; +import java.awt.peer.CheckboxMenuItemPeer; +import java.awt.peer.CheckboxPeer; +import java.awt.peer.ChoicePeer; +import java.awt.peer.DialogPeer; +import java.awt.peer.FileDialogPeer; +import java.awt.peer.FontPeer; +import java.awt.peer.FramePeer; +import java.awt.peer.LabelPeer; +import java.awt.peer.ListPeer; +import java.awt.peer.MenuBarPeer; +import java.awt.peer.MenuItemPeer; +import java.awt.peer.MenuPeer; +import java.awt.peer.PanelPeer; +import java.awt.peer.PopupMenuPeer; +import java.awt.peer.RobotPeer; +import java.awt.peer.ScrollPanePeer; +import java.awt.peer.ScrollbarPeer; +import java.awt.peer.TextAreaPeer; +import java.awt.peer.TextFieldPeer; +import java.awt.peer.WindowPeer; import java.io.InputStream; import java.net.URL; -import java.text.AttributedString; import java.util.HashMap; -import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; @@ -553,7 +604,18 @@ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e) { - throw new Error("not implemented"); + return new GtkDragSourceContextPeer(e); + } + + public DragGestureRecognizer createDragGestureRecognizer(Class recognizer, + DragSource ds, + Component comp, + int actions, + DragGestureListener l) + { + if (recognizer.getName().equals("java.awt.dnd.MouseDragGestureRecognizer")) + return new GtkMouseDragGestureRecognizer(ds, comp, actions, l); + return null; } public Map mapInputMethodHighlight(InputMethodHighlight highlight) Index: java/awt/dnd/DragSource.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/dnd/DragSource.java,v retrieving revision 1.8 diff -u -r1.8 DragSource.java --- java/awt/dnd/DragSource.java 6 Jul 2006 17:41:08 -0000 1.8 +++ java/awt/dnd/DragSource.java 6 Jul 2006 19:40:20 -0000 @@ -51,6 +51,7 @@ import java.awt.datatransfer.SystemFlavorMap; import java.awt.datatransfer.Transferable; import java.awt.dnd.peer.DragSourceContextPeer; +import java.awt.event.MouseMotionListener; import java.io.Serializable; import java.util.EventListener; @@ -222,48 +224,22 @@ return flavorMap; } - /** - * Dummy DragGestureRecognizer when Toolkit doesn't support drag and drop. - */ - static class NoDragGestureRecognizer - extends DragGestureRecognizer - { - NoDragGestureRecognizer(DragSource ds, Component c, int actions, - DragGestureListener dgl) - { - super(ds, c, actions, dgl); - } - - protected void registerListeners() - { - } - - protected void unregisterListeners() - { - } - } - - public DragGestureRecognizer - createDragGestureRecognizer(Class recognizer, Component c, int actions, - DragGestureListener dgl) - { - DragGestureRecognizer dgr; - dgr = Toolkit.getDefaultToolkit () - .createDragGestureRecognizer (recognizer, this, c, actions, - dgl); - - if (dgr == null) - dgr = new NoDragGestureRecognizer(this, c, actions, dgl); - - return dgr; - } - - public DragGestureRecognizer - createDefaultDragGestureRecognizer(Component c, int actions, - DragGestureListener dgl) + public DragGestureRecognizer createDragGestureRecognizer(Class recognizer, + Component c, + int actions, + DragGestureListener dgl) + { + return Toolkit.getDefaultToolkit().createDragGestureRecognizer(recognizer, + this, c, + actions, dgl); + } + + public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, + int actions, + DragGestureListener dgl) { - return createDragGestureRecognizer (MouseDragGestureRecognizer.class, c, - actions, dgl); + return createDragGestureRecognizer(MouseDragGestureRecognizer.class, c, + actions, dgl); } /** Index: java/awt/dnd/DropTarget.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/dnd/DropTarget.java,v retrieving revision 1.13 diff -u -r1.13 DropTarget.java --- java/awt/dnd/DropTarget.java 5 Jul 2006 17:45:50 -0000 1.13 +++ java/awt/dnd/DropTarget.java 6 Jul 2006 19:40:20 -0000 @@ -275,12 +275,20 @@ public void addNotify(ComponentPeer p) { - peer = (DropTargetPeer) p; + if (p instanceof DropTargetPeer) + { + peer = (DropTargetPeer) p; + peer.addDropTarget(this); + } + else + peer = null; } - public void removeNotify(ComponentPeer peer) + public void removeNotify(ComponentPeer p) { + ((DropTargetPeer) peer).removeDropTarget(this); peer = null; + p = null; } public DropTargetContext getDropTargetContext()