summaryrefslogtreecommitdiff
path: root/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java')
-rw-r--r--gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java121
1 files changed, 112 insertions, 9 deletions
diff --git a/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java b/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
index 873027290..b68fa1058 100644
--- a/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
+++ b/gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
@@ -38,44 +38,147 @@ exception statement from your version. */
package gnu.java.awt.dnd.peer.gtk;
+import gnu.java.awt.peer.gtk.GtkGenericPeer;
+
+import java.awt.Component;
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.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;
+import java.awt.peer.LightweightPeer;
public class GtkDragSourceContextPeer
+ extends GtkGenericPeer
implements DragSourceContextPeer
{
-
- private DragGestureEvent dge;
+ private ComponentPeer peer;
+ private Cursor cursor;
+ private DragSourceContext context;
+ public static Component target;
+
+ native void nativeStartDrag(Image i, int x, int y, int action, String target);
+ native void connectSignals(ComponentPeer comp);
+ native void create(ComponentPeer comp);
+ native void nativeSetCursor(int cursor);
+ native void setTarget(GtkDropTargetContextPeer target);
public GtkDragSourceContextPeer(DragGestureEvent e)
{
- dge = e;
+ super(e.getComponent());
+ Component comp = e.getComponent();
+ peer = getComponentPeer(comp);
+
+ create(peer);
+ connectSignals(peer);
+ cursor = comp.getCursor();
+
+ // FIXME: Where do we set the target?
+
+ if ((target != null))
+ setTarget(new GtkDropTargetContextPeer(target));
+ }
+
+ ComponentPeer getComponentPeer(Component c)
+ {
+ if (c == null)
+ return null;
+
+ Component curr = c;
+ while (curr.getPeer() instanceof LightweightPeer)
+ curr = curr.getParent();
+
+ if (curr != null)
+ return curr.getPeer();
+ return null;
}
public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
throws InvalidDnDOperationException
- {
- // FIXME: Not Implemented
+ {
+ this.context = context;
+
+ if (p == null)
+ p = new Point();
+
+ // FIXME: use proper DataFlavor, not "text/plain".
+ // Also, add check to determine if dragging.
+
+ setCursor(c);
+ nativeStartDrag(i, p.x, p.y, context.getTrigger().getDragAction(),
+ "text/plain");
}
public Cursor getCursor()
{
- // FIXME: Not Implemented
- return null;
+ return cursor;
}
public void setCursor(Cursor c) throws InvalidDnDOperationException
{
- // FIXME: Not Implemented
+ if (c != null)
+ {
+ nativeSetCursor(c.getType());
+ cursor = c;
+ }
}
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));
}
}