changeset 101:43123e716bda

Ported dwt.dnd.DropTargetEffect
author Jacob Carlborg <doob@me.com>
date Wed, 31 Dec 2008 13:21:58 +0100
parents c2f1ba00473b
children 1c12673c65ca
files dwt/dnd/DropTargetEffect.d dwt/dnd/DropTargetListener.d
diffstat 2 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dnd/DropTargetEffect.d	Wed Dec 31 13:17:35 2008 +0100
+++ b/dwt/dnd/DropTargetEffect.d	Wed Dec 31 13:21:58 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.DropTargetEffect;
 
@@ -22,6 +25,8 @@
 import dwt.widgets.TreeItem;
 import dwt.widgets.Widget;
 
+import dwt.dnd.DropTargetAdapter;
+
 
 /**
  * This class provides a default drag under effect during a drag and drop. 
@@ -56,7 +61,7 @@
  * 
  * @since 3.3
  */
-public class DropTargetEffect extends DropTargetAdapter {
+public class DropTargetEffect : DropTargetAdapter {
     Control control;
 
     /**
@@ -69,7 +74,7 @@
      *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
      * </ul>
      */
-    public DropTargetEffect(Control control) {
+    public this(Control control) {
         if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
         this.control = control;
     }
@@ -94,11 +99,11 @@
      * @return the item at the given x-y coordinate, or null if the coordinate is not in a selectable item
      */
     public Widget getItem(int x, int y) {
-        if (control instanceof Table) {
-            return getItem((Table) control, x, y);
+        if (cast(Table) control) {
+            return getItem(cast(Table) control, x, y);
         }
-        if (control instanceof Tree) {
-            return getItem((Tree) control, x, y);
+        if (cast(Tree) control) {
+            return getItem(cast(Tree) control, x, y);
         }           
         return null;
     }
@@ -167,12 +172,12 @@
         TreeItem parentItem = childItem.getParentItem();
         int index = parentItem is null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
         if (index is 0) return parentItem;
-        TreeItem nextItem = parentItem is null ? tree.getItem(index-1) : parentItem.getItem(index-1);
-        int count = nextItem.getItemCount();
-        while (count > 0 && nextItem.getExpanded()) {
-            nextItem = nextItem.getItem(count - 1);
-            count = nextItem.getItemCount();
+        TreeItem nextItem_ = parentItem is null ? tree.getItem(index-1) : parentItem.getItem(index-1);
+        int count = nextItem_.getItemCount();
+        while (count > 0 && nextItem_.getExpanded()) {
+            nextItem_ = nextItem_.getItem(count - 1);
+            count = nextItem_.getItemCount();
         }
-        return nextItem;
+        return nextItem_;
     }
 }
--- a/dwt/dnd/DropTargetListener.d	Wed Dec 31 13:17:35 2008 +0100
+++ b/dwt/dnd/DropTargetListener.d	Wed Dec 31 13:21:58 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.DropTargetListener;
 
@@ -14,6 +17,8 @@
 
 import dwt.internal.DWTEventListener;
 
+import dwt.dnd.DropTargetEvent;
+
 /**
  * The <code>DropTargetListener</code> class provides event notification to the application 
  * for DropTarget events.
@@ -35,7 +40,7 @@
  * @see DropTargetEvent
  *
  */
-public interface DropTargetListener extends DWTEventListener {
+public interface DropTargetListener : DWTEventListener {
     
 /**
  * The cursor has entered the drop target boundaries.