Implemented a few more functions in GtkDragSourceContextPeer.

2006-07-19  Lillian Angel  <[EMAIL PROTECTED]>

        * examples/gnu/classpath/examples/awt/Demo.java
        (DragDropWindow): Fixed typo in Label text.
        * gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
        (GtkDragSourceContextPeer): Removed unneeded initialization for 
        field.
        (startDrag): Initialized context field.
        (transferablesFlavorsChanged): Removed FIXME. Nothing is done 
        in this function.
        (dragEnter): New function.
        (dragExit): Likewise.
        (dragDropEnd): Likewise.
        (dragMouseMoved): Likewise.
        (dragOver): Likewise.
        (dragActionChanged): Likewise.

Index: examples/gnu/classpath/examples/awt/Demo.java
===================================================================
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/awt/Demo.java,v
retrieving revision 1.7
diff -u -r1.7 Demo.java
--- examples/gnu/classpath/examples/awt/Demo.java	17 Jul 2006 18:37:19 -0000	1.7
+++ examples/gnu/classpath/examples/awt/Demo.java	19 Jul 2006 15:59:17 -0000
@@ -863,8 +863,7 @@
       extends SubFrame
       implements ActionListener, DropTargetListener
   {
-    DragLabel source = new DragLabel(
-                                     "Drag and drop me to the following JButton",
+    DragLabel source = new DragLabel("Drag and drop me to the following Button",
                                      Label.CENTER);
 
     Button target = new Button();
Index: gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java,v
retrieving revision 1.2
diff -u -r1.2 GtkDragSourceContextPeer.java
--- gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java	17 Jul 2006 18:37:19 -0000	1.2
+++ gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java	19 Jul 2006 15:59:17 -0000
@@ -44,9 +44,11 @@
 import java.awt.Cursor;
 import java.awt.Image;
 import java.awt.Point;
-import java.awt.Window;
 import java.awt.dnd.DragGestureEvent;
 import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
 import java.awt.dnd.InvalidDnDOperationException;
 import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.peer.ComponentPeer;
@@ -56,10 +58,9 @@
     extends GtkGenericPeer
     implements DragSourceContextPeer
 {
-
-  private DragGestureEvent dge;
   private ComponentPeer peer;
   private Cursor cursor;
+  private DragSourceContext context;
   
   native void nativeStartDrag(Image i, int x, int y, int action, String target);
   native void connectSignals(ComponentPeer comp);
@@ -69,11 +70,9 @@
   public GtkDragSourceContextPeer(DragGestureEvent e)
   {
     super(e.getComponent());
-    dge = e;
-    
     Component comp = e.getComponent();
-    
     peer = getComponentPeer(comp);
+    
     create(peer);
     connectSignals(peer);
     cursor = comp.getCursor();
@@ -93,6 +92,8 @@
   public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
       throws InvalidDnDOperationException
   {   
+    this.context = context;
+    
     if (p == null)
       p = new Point();
     
@@ -120,6 +121,54 @@
 
   public void transferablesFlavorsChanged()
   {
-    // FIXME: Not Implemented
+    // Nothing to do here.
+  }
+  
+  /**
+   * Called from native code.
+   */
+
+  public void dragEnter(int action, int modifiers)
+  {
+    context.dragEnter(new DragSourceDragEvent(context, action,
+                                              action
+                                                  & context.getSourceActions(),
+                                              modifiers));
+  }
+
+  public void dragExit(int action, int x, int y)
+  {
+    context.dragExit(new DragSourceEvent(context, x, y));
+  }
+
+  public void dragDropEnd(int action, boolean success, int x, int y)
+  {
+    context.dragDropEnd(new DragSourceDropEvent(context, action, success, x, y));
+  }
+
+  public void dragMouseMoved(int action, int modifiers)
+  {
+    context.dragMouseMoved(new DragSourceDragEvent(context,
+                                                   action,
+                                                   action
+                                                       & context.getSourceActions(),
+                                                   modifiers));
+  }
+
+  public void dragOver(int action, int modifiers)
+  {
+    context.dragOver(new DragSourceDragEvent(context, action,
+                                             action
+                                                 & context.getSourceActions(),
+                                             modifiers));
+  }
+
+  public void dragActionChanged(int newAction, int modifiers)
+  {
+    context.dropActionChanged(new DragSourceDragEvent(context,
+                                                      newAction,
+                                                      newAction
+                                                          & context.getSourceActions(),
+                                                      modifiers));
   }
 }

Reply via email to