summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2006-02-08 19:52:18 +0000
committerVeronika Irvine <veronika>2006-02-08 19:52:18 +0000
commit67ca7cc4f3dbbc15230a02c87fdbb628c3cffaf8 (patch)
tree24c88ff9c39dc51e757da3cf8688c1ae1ed6c164
parent39d61b5391cf07bddd35d606c65cb7060269fb46 (diff)
downloadeclipse.platform.swt-67ca7cc4f3dbbc15230a02c87fdbb628c3cffaf8.tar.gz
eclipse.platform.swt-67ca7cc4f3dbbc15230a02c87fdbb628c3cffaf8.tar.xz
eclipse.platform.swt-67ca7cc4f3dbbc15230a02c87fdbb628c3cffaf8.zip
add support for drag source image
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragAndDropEffect.java (renamed from bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragUnderEffect.java)11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragAndDropEffect.java (renamed from bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java)24
4 files changed, 37 insertions, 23 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
index 178b3bb52b..637b226050 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
@@ -12,6 +12,7 @@ package org.eclipse.swt.dnd;
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
@@ -104,6 +105,7 @@ public class DragSource extends Widget {
//workaround - remember action performed for DragEnd
boolean moveData = false;
+ DragAndDropEffect effect;
static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$
static Callback DragGetData;
@@ -179,6 +181,15 @@ public DragSource(Control control, int style) {
control.addListener (SWT.Dispose, controlListener);
control.addListener (SWT.DragDetect, controlListener);
+ // DND effect
+ if (control instanceof Tree) {
+ effect = new TreeDragAndDropEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragAndDropEffect((Table)control);
+ } else {
+ effect = new NoDragAndDropEffect(control);
+ }
+
this.addListener(SWT.Dispose, new Listener() {
public void handleEvent(Event e) {
onDispose();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
index 18c6efe76b..2f684fbead 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
@@ -73,7 +73,7 @@ public class DropTarget extends Widget {
Control control;
Listener controlListener;
Transfer[] transferAgents = new Transfer[0];
- DragUnderEffect effect;
+ DragAndDropEffect effect;
// Track application selections
TransferData selectedDataType;
@@ -176,11 +176,11 @@ public DropTarget(Control control, int style) {
// Drag under effect
if (control instanceof Tree) {
- effect = new TreeDragUnderEffect((Tree)control);
+ effect = new TreeDragAndDropEffect((Tree)control);
} else if (control instanceof Table) {
- effect = new TableDragUnderEffect((Table)control);
+ effect = new TableDragAndDropEffect((Table)control);
} else {
- effect = new NoDragUnderEffect(control);
+ effect = new NoDragAndDropEffect(control);
}
dragOverHeartbeat = new Runnable() {
@@ -212,7 +212,7 @@ public DropTarget(Control control, int style) {
selectedDataType = null;
selectedOperation = DND.DROP_NONE;
notifyListeners(DND.DragOver, event);
- effect.show(event.feedback, event.x, event.y);
+ effect.showDropTargetEffect(event.feedback, event.x, event.y);
if (event.dataType != null) {
for (int i = 0; i < allowedTypes.length; i++) {
if (allowedTypes[i].type == event.dataType.type) {
@@ -405,7 +405,7 @@ boolean drag_drop(int /*long*/ widget, int /*long*/ context, int x, int y, int t
void drag_leave ( int /*long*/ widget, int /*long*/ context, int time){
updateDragOverHover(0, null);
- effect.show(DND.FEEDBACK_NONE, 0, 0);
+ effect.showDropTargetEffect(DND.FEEDBACK_NONE, 0, 0);
if (keyOperation == -1) return;
keyOperation = -1;
@@ -466,7 +466,7 @@ boolean drag_motion ( int /*long*/ widget, int /*long*/ context, int x, int y, i
if (selectedDataType != null && (allowedOperations & event.detail) != 0) {
selectedOperation = event.detail;
}
- effect.show(event.feedback, event.x, event.y);
+ effect.showDropTargetEffect(event.feedback, event.x, event.y);
switch (selectedOperation) {
case DND.DROP_NONE:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragAndDropEffect.java
index f7a7302e15..aca66deefa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragUnderEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragAndDropEffect.java
@@ -11,20 +11,21 @@
package org.eclipse.swt.dnd;
+import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.gtk.OS;
-class TableDragUnderEffect extends DragUnderEffect {
+class TableDragAndDropEffect extends DragAndDropEffect {
private Table table;
private int scrollIndex = -1;
private long scrollBeginTime;
private static final int SCROLL_HYSTERESIS = 150; // milli seconds
-TableDragUnderEffect(Table table) {
+TableDragAndDropEffect(Table table) {
this.table = table;
}
-private int checkEffect(int effect) {
+int checkEffect(int effect) {
// Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
if ((effect & DND.FEEDBACK_SELECT) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE;
if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER;
@@ -51,7 +52,7 @@ Widget getItem(int x, int y) {
return item;
}
-void show(int effect, int x, int y) {
+void showDropTargetEffect(int effect, int x, int y) {
effect = checkEffect(effect);
int /*long*/ handle = table.handle;
Point coordinates = new Point(x, y);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragAndDropEffect.java
index 26589e00b7..3ce446d6f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragUnderEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragAndDropEffect.java
@@ -14,22 +14,23 @@ import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.widgets.*;
-class TreeDragUnderEffect extends DragUnderEffect {
- private Tree tree;
+class TreeDragAndDropEffect extends DragAndDropEffect {
+ Tree tree;
- private int scrollIndex = -1;
- private long scrollBeginTime;
+ int scrollIndex = -1;
+ long scrollBeginTime;
- private int expandIndex = -1;
- private long expandBeginTime;
+ int expandIndex = -1;
+ long expandBeginTime;
- private static final int SCROLL_HYSTERESIS = 150; // milli seconds
- private static final int EXPAND_HYSTERESIS = 300; // milli seconds
+ static final int SCROLL_HYSTERESIS = 150; // milli seconds
+ static final int EXPAND_HYSTERESIS = 300; // milli seconds
-TreeDragUnderEffect(Tree tree) {
+TreeDragAndDropEffect(Tree tree) {
this.tree = tree;
}
-private int checkEffect(int effect) {
+
+int checkEffect(int effect) {
// Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
if ((effect & DND.FEEDBACK_SELECT) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE;
if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER;
@@ -55,7 +56,8 @@ Widget getItem(int x, int y) {
}
return item;
}
-void show(int effect, int x, int y) {
+
+void showDropTargetEffect(int effect, int x, int y) {
effect = checkEffect(effect);
int /*long*/ handle = tree.handle;
Point coordinates = new Point(x, y);