changeset 92:370410b7852f

Ported dwt.dnd.DND
author Jacob Carlborg <doob@me.com>
date Tue, 30 Dec 2008 19:08:20 +0100
parents a7e41c09df9e
children b28f69fee882
files dwt/dnd/DND.d
diffstat 1 files changed, 42 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dnd/DND.d	Tue Dec 30 19:04:59 2008 +0100
+++ b/dwt/dnd/DND.d	Tue Dec 30 19:08:20 2008 +0100
@@ -7,6 +7,9 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <doob@me.com>
  *******************************************************************************/
 module dwt.dnd.DND;
 
@@ -34,7 +37,7 @@
      * 
      * @since 3.1
      */
-    public final static int CLIPBOARD = 1 << 0;
+    public const static int CLIPBOARD = 1 << 0;
     
     /**
      * The transfer mechanism for clients that use the selection 
@@ -44,31 +47,31 @@
      *
      * @since 3.1
      */
-    public final static int SELECTION_CLIPBOARD = 1 << 1;
+    public const static int SELECTION_CLIPBOARD = 1 << 1;
 
     /**
      * Drag and Drop Operation: no drag/drop operation performed
      * (value is 0).
      */
-    public final static int DROP_NONE = 0;
+    public const static int DROP_NONE = 0;
     
     /**
      * Drag and Drop Operation: a copy of the data in the drag source is 
      * added to the drop target (value is 1 &lt;&lt; 0).
      */
-    public final static int DROP_COPY = 1 << 0;
+    public const static int DROP_COPY = 1 << 0;
     
     /**
      * Drag and Drop Operation: a copy of the data is added to the drop target and 
      * the original data is removed from the drag source (value is 1 &lt;&lt; 1).
      */
-    public final static int DROP_MOVE = 1 << 1;
+    public const static int DROP_MOVE = 1 << 1;
     
     /**
      * Drag and Drop Operation: the drop target makes a link to the data in 
      * the drag source (value is 1 &lt;&lt; 2).
      */
-    public final static int DROP_LINK = 1 << 2;
+    public const static int DROP_LINK = 1 << 2;
     
     /**
      * Drag and Drop Operation: the drop target moves the data and the drag source removes 
@@ -79,7 +82,7 @@
      * 
      * @see DragSourceListener#dragFinished
      */
-    public final static int DROP_TARGET_MOVE = 1 << 3;
+    public const static int DROP_TARGET_MOVE = 1 << 3;
     
     /**
      * Drag and Drop Operation: During a dragEnter event or a dragOperationChanged, if no modifier keys
@@ -91,112 +94,112 @@
      * @see DropTargetListener#dragOperationChanged
      * @since 2.0 
      */
-    public final static int DROP_DEFAULT = 1 << 4;
+    public const static int DROP_DEFAULT = 1 << 4;
     
     /**
      * DragSource Event: the drop has successfully completed or has been terminated (such as hitting 
      * the ESC key); perform cleanup such as removing data on a move operation (value is 2000).
      */
-    public static final int DragEnd     = 2000;
+    public static const int DragEnd     = 2000;
     
     /**
      * DragSource Event: the data to be dropped is required from the drag source (value is 2001).
      */
-    public static final int DragSetData = 2001;
+    public static const int DragSetData = 2001;
     
     /**
      * DropTarget Event: the cursor has entered the drop target boundaries (value is 2002).
      */
-    public static final int DragEnter   = 2002;
+    public static const int DragEnter   = 2002;
     
     /**
      * DropTarget Event: the cursor has left the drop target boundaries OR the drop
      * operation has been cancelled (such as by hitting ECS) OR the drop is about to 
      * happen (user has released the mouse button over this target) (value is 2003).
      */
-    public static final int DragLeave   = 2003;
+    public static const int DragLeave   = 2003;
     
     /**
      * DropTarget Event: the cursor is over the drop target (value is 2004).
      */
-    public static final int DragOver    = 2004;
+    public static const int DragOver    = 2004;
     
     /**
      * DropTarget Event: the operation being performed has changed usually due to the user 
      * changing the selected modifier keys while dragging (value is 2005).
      */
-    public static final int DragOperationChanged = 2005;
+    public static const int DragOperationChanged = 2005;
     
     /**
      * DropTarget Event: the data has been dropped (value is 2006).
      */
-    public static final int Drop = 2006;
+    public static const int Drop = 2006;
     
     /**
      * DropTarget Event: the drop target is given a last chance to modify the drop (value is 2007).
      */
-    public static final int DropAccept  = 2007;
+    public static const int DropAccept  = 2007;
     
     /**
      * DragSource Event: a drag is about to begin (value is 2008).
      */
-    public static final int DragStart = 2008;
+    public static const int DragStart = 2008;
 
     /**
      * DropTarget drag under effect: No effect is shown (value is 0).
      */
-    public static final int FEEDBACK_NONE = 0;
+    public static const int FEEDBACK_NONE = 0;
     
     /**
      * DropTarget drag under effect: The item under the cursor is selected; applies to tables
      * and trees (value is 1).
      */
-    public static final int FEEDBACK_SELECT = 1;
+    public static const int FEEDBACK_SELECT = 1;
     
     /**
      * DropTarget drag under effect: An insertion mark is shown before the item under the cursor; applies to 
      * trees (value is 2).
      */
-    public static final int FEEDBACK_INSERT_BEFORE = 2;
+    public static const int FEEDBACK_INSERT_BEFORE = 2;
     
     /**
      * DropTarget drag under effect:An insertion mark is shown after the item under the cursor; applies to
      * trees (value is 4).
      */ 
-    public static final int FEEDBACK_INSERT_AFTER = 4;
+    public static const int FEEDBACK_INSERT_AFTER = 4;
     
     /**
      * DropTarget drag under effect: The widget is scrolled up or down to allow the user to drop on items that 
      * are not currently visible;  applies to tables and trees (value is 8).
      */ 
-    public static final int FEEDBACK_SCROLL = 8;
+    public static const int FEEDBACK_SCROLL = 8;
     
     /**
      * DropTarget drag under effect: The item currently under the cursor is expanded to allow the user to 
      * select a drop target from a sub item; applies to trees (value is 16).
      */ 
-    public static final int FEEDBACK_EXPAND = 16;
+    public static const int FEEDBACK_EXPAND = 16;
 
     /**
      * Error code: drag source can not be initialized (value is 2000).
      */
-    public static final int ERROR_CANNOT_INIT_DRAG = 2000;
+    public static const int ERROR_CANNOT_INIT_DRAG = 2000;
     
     /**
      * Error code: drop target cannot be initialized (value is 2001).
      */
-    public static final int ERROR_CANNOT_INIT_DROP = 2001;
+    public static const int ERROR_CANNOT_INIT_DROP = 2001;
     
     /**
      * Error code: Data can not be set on system clipboard (value is 2002).
      */
-    public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
+    public static const int ERROR_CANNOT_SET_CLIPBOARD = 2002;
     
     /**
      * Error code: Data does not have correct format for type (value is 2003).
      * @since 3.1
      */
-    public static final int ERROR_INVALID_DATA = 2003;
+    public static const int ERROR_INVALID_DATA = 2003;
     
     /**
      * DropTarget Key: The string constant for looking up the drop target 
@@ -206,7 +209,7 @@
      * 
      * @since 3.4
      */
-    public static final String DROP_TARGET_KEY = "DropTarget"; //$NON-NLS-1$
+    public static const String DROP_TARGET_KEY = "DropTarget"; //$NON-NLS-1$
     
     /**
      * DragSource Key: The string constant for looking up the drag source 
@@ -216,12 +219,12 @@
      * 
      * @since 3.4
      */
-    public static final String DRAG_SOURCE_KEY = "DragSource"; //$NON-NLS-1$
+    public static const String DRAG_SOURCE_KEY = "DragSource"; //$NON-NLS-1$
 
-    static final String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
-    static final String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
-    static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Cannot set data in clipboard"; //$NON-NLS-1$
-    static final String INVALID_DATA_MESSAGE = "Data does not have correct format for type"; //$NON-NLS-1$
+    static const String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
+    static const String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
+    static const String CANNOT_SET_CLIPBOARD_MESSAGE = "Cannot set data in clipboard"; //$NON-NLS-1$
+    static const String INVALID_DATA_MESSAGE = "Data does not have correct format for type"; //$NON-NLS-1$
 
 /**
  * Throws an appropriate exception based on the passed in error code.
@@ -262,24 +265,26 @@
         /* OS Failure/Limit (fatal, may occur only on some platforms) */
         case DND.ERROR_CANNOT_INIT_DRAG:{
             String msg = DND.INIT_DRAG_MESSAGE;
-            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            if (hresult !is 0) msg ~= " result = "~Integer.toString(hresult); //$NON-NLS-1$
             throw new DWTError (code, msg);
         }
         case DND.ERROR_CANNOT_INIT_DROP:{
             String msg = DND.INIT_DROP_MESSAGE;
-            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            if (hresult !is 0) msg += " result = "~Integer.toString(hresult); //$NON-NLS-1$
             throw new DWTError (code, msg);
         }
         case DND.ERROR_CANNOT_SET_CLIPBOARD:{
             String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
-            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            if (hresult !is 0) msg += " result = "~Integer.toString(hresult); //$NON-NLS-1$
             throw new DWTError (code, msg);
         }
         case DND.ERROR_INVALID_DATA:{
             String msg = DND.INVALID_DATA_MESSAGE;
-            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            if (hresult !is 0) msg += " result = "~Integer.toString(hresult); //$NON-NLS-1$
             throw new DWTException (code, msg);
         }
+        
+        default:
     }
             
     /* Unknown/Undefined Error */