diff dwt/dnd/DropTarget.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children fd9c62a2998e
line wrap: on
line diff
--- a/dwt/dnd/DropTarget.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/dnd/DropTarget.d	Sat May 17 17:34:28 2008 +0200
@@ -15,6 +15,7 @@
 import dwt.DWT;
 import dwt.DWTError;
 import dwt.DWTException;
+import dwt.internal.C;
 import dwt.internal.ole.win32.COM;
 import dwt.internal.ole.win32.extras;
 import dwt.internal.ole.win32.OBJIDL;
@@ -115,7 +116,6 @@
     int refCount;
 
     static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
-    static final String DROPTARGETID = "DropTarget"; //$NON-NLS-1$
 
 /**
  * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
@@ -151,10 +151,10 @@
 public this(Control control, int style) {
     super (control, checkStyle(style));
     this.control = control;
-    if (control.getData(DROPTARGETID) !is null) {
+    if (control.getData(DND.DROP_TARGET_KEY) !is null) {
         DND.error(DND.ERROR_CANNOT_INIT_DROP);
     }
-    control.setData(DROPTARGETID, this);
+    control.setData(DND.DROP_TARGET_KEY, this);
     createCOMInterfaces();
     this.AddRef();
 
@@ -222,6 +222,7 @@
  * </ul>
  *
  * @see DropTargetListener
+ * @see #getDropListeners
  * @see #removeDropListener
  * @see DropTargetEvent
  */
@@ -259,6 +260,12 @@
     iDropTarget = null;
 }
 
+int DragEnter_64(IDataObject pDataObject, DWORD grfKeyState, long pt, DWORD* pdwEffect) {
+    POINTL point;
+    OS.MoveMemory( &point, &pt, 8);
+    return DragEnter(pDataObject, grfKeyState, point, pdwEffect);
+}
+
 HRESULT DragEnter(IDataObject pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) {
     selectedDataType = null;
     selectedOperation = DND.DROP_NONE;
@@ -318,6 +325,12 @@
     return COM.S_OK;
 }
 
+int DragOver_64(int grfKeyState, long pt, DWORD* pdwEffect) {
+    POINTL point;
+    OS.MoveMemory(&point, &pt, 8);
+    return DragOver(grfKeyState, point, pdwEffect);
+}
+
 HRESULT DragOver(int grfKeyState, POINTL pt, DWORD* pdwEffect) {
     if (iDataObject is null) return COM.S_FALSE;
     int oldKeyOperation = keyOperation;
@@ -364,6 +377,12 @@
     return COM.S_OK;
 }
 
+int Drop_64(IDataObject pDataObject, int grfKeyState, long pt, DWORD* pdwEffect) {
+    POINTL point;
+    OS.MoveMemory(&point, &pt, 8);
+    return Drop(pDataObject, grfKeyState, point, pdwEffect);
+}
+
 HRESULT Drop(IDataObject pDataObject, int grfKeyState, POINTL pt, DWORD* pdwEffect) {
     DNDEvent event = new DNDEvent();
     event.widget = this;
@@ -450,6 +469,41 @@
 }
 
 /**
+ * Returns an array of listeners who will be notified when a drag and drop
+ * operation is in progress, by sending it one of the messages defined in
+ * the <code>DropTargetListener</code> interface.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ *
+ * @since 3.4
+ */
+public DropTargetListener[] getDropListeners() {
+    Listener[] listeners = getListeners(DND.DragEnter);
+    int length = listeners.length;
+    DropTargetListener[] dropListeners = new DropTargetListener[length];
+    int count = 0;
+    for (int i = 0; i < length; i++) {
+        Listener listener = listeners[i];
+        if (auto l = cast(DNDListener)listener ) {
+            dropListeners[count] = cast(DropTargetListener) (l.getEventListener());
+            count++;
+        }
+    }
+    if (count is length) return dropListeners;
+    DropTargetListener[] result = new DropTargetListener[count];
+    SimpleType!(DropTargetListener).arraycopy(dropListeners, 0, result, 0, count);
+    return result;
+}
+
+/**
  * Returns the drop effect for this DropTarget.  This drop effect will be
  * used during a drag and drop to display the drag under effect on the
  * target widget.
@@ -493,7 +547,7 @@
     if (controlListener !is null)
         control.removeListener(DWT.Dispose, controlListener);
     controlListener = null;
-    control.setData(DROPTARGETID, null);
+    control.setData(DND.DROP_TARGET_KEY, null);
     transferAgents = null;
     control = null;
 
@@ -588,6 +642,7 @@
  *
  * @see DropTargetListener
  * @see #addDropListener
+ * @see #getDropListeners
  */
 public void removeDropListener(DropTargetListener listener) {
     if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);