diff dwt/dnd/TableDropTargetEffect.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents e831403a80a9
children 23a31de4a3ab
line wrap: on
line diff
--- a/dwt/dnd/TableDropTargetEffect.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/dnd/TableDropTargetEffect.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,14 +8,14 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
-module dwt.dnd;
+module dwt.dnd.TableDropTargetEffect;
+
+import dwt.dwthelper.utils;
 
-import dwt.DWT;
-import dwt.graphics.*;
-import dwt.internal.Callback;
-import dwt.internal.carbon.DataBrowserCallbacks;
-import dwt.internal.carbon.OS;
-import dwt.widgets.*;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Table;
+import dwt.widgets.TableItem;
 
 /**
  * This class provides a default drag under effect (eg. select, insert and scroll) 
@@ -43,37 +43,38 @@
  * 
  * @see DropTargetAdapter
  * @see DropTargetEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  * 
  * @since 3.3
  */
-public class TableDropTargetEffect : DropTargetEffect {
+public class TableDropTargetEffect extends DropTargetEffect {
     static final int SCROLL_HYSTERESIS = 150; // milli seconds
 
     TableItem scrollItem;
     long scrollBeginTime;
-    DataBrowserCallbacks callbacks = null;
+//  DataBrowserCallbacks callbacks = null;
 
-    static Callback AcceptDragProc;
-    static {
-        AcceptDragProc = new Callback(TableDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
-        int acceptDragProc = AcceptDragProc.getAddress();
-        if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
-    }
+//  static Callback AcceptDragProc;
+//  static {
+//      AcceptDragProc = new Callback(TableDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
+//      int acceptDragProc = AcceptDragProc.getAddress();
+//      if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+//  }
 
-    static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
-        DropTarget target = FindDropTarget(theControl, theDrag);
-        if (target is null) return 0;
-        return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
-    }
+//  static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
+//      DropTarget target = FindDropTarget(theControl, theDrag);
+//      if (target is null) return 0;
+//      return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
+//  }
     
-    static DropTarget FindDropTarget(int theControl, int theDrag) {
-        if (theControl is 0) return null;
-        Display display = Display.findDisplay(Thread.currentThread());
-        if (display is null || display.isDisposed()) return null;
-        Widget widget = display.findWidget(theControl);
-        if (widget is null) return null;
-        return cast(DropTarget)widget.getData(DND.DROP_TARGET_KEY); 
-    }
+//  static DropTarget FindDropTarget(int theControl, int theDrag) {
+//      if (theControl is 0) return null;
+//      Display display = Display.findDisplay(Thread.currentThread());
+//      if (display is null || display.isDisposed()) return null;
+//      Widget widget = display.findWidget(theControl);
+//      if (widget is null) return null;
+//      return (DropTarget)widget.getData(DND.DROP_TARGET_KEY); 
+//  }
     
     /**
      * Creates a new <code>TableDropTargetEffect</code> to handle the drag under effect on the specified 
@@ -81,7 +82,7 @@
      * 
      * @param table the <code>Table</code> over which the user positions the cursor to drop the data
      */
-    public this(Table table) {
+    public TableDropTargetEffect(Table table) {
         super(table);
     }
 
@@ -107,13 +108,13 @@
      * @see DropTargetEvent
      */
     public void dragEnter(DropTargetEvent event) {
-        if (callbacks is null) {
-            Table table = cast(Table) control;
-            DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
-            OS.GetDataBrowserCallbacks (table.handle, callbacks);
-            callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
-            OS.SetDataBrowserCallbacks(table.handle, callbacks);
-        }
+//      if (callbacks is null) {
+//          Table table = (Table) control;
+//          DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+//          OS.GetDataBrowserCallbacks (table.handle, callbacks);
+//          callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
+//          OS.SetDataBrowserCallbacks(table.handle, callbacks);
+//      }
         scrollBeginTime = 0;
         scrollItem = null;
     }
@@ -155,16 +156,16 @@
      * @see DND#FEEDBACK_SCROLL
      */
     public void dragOver(DropTargetEvent event) {
-        Table table = cast(Table) control;
+        Table table = (Table) control;
         int effect = checkEffect(event.feedback);
 
-        TableItem item = cast(TableItem)getItem(table, event.x, event.y);
+        TableItem item = (TableItem)getItem(table, event.x, event.y);
 
         if ((effect & DND.FEEDBACK_SCROLL) is 0) {
             scrollBeginTime = 0;
             scrollItem = null;
         } else {
-            if (item !is null && item.opEquals(scrollItem)  && scrollBeginTime !is 0) {
+            if (item !is null && item.equals(scrollItem)  && scrollBeginTime !is 0) {
                 if (System.currentTimeMillis() >= scrollBeginTime) {
                     Rectangle area = table.getClientArea();
                     int headerHeight = table.getHeaderHeight();
@@ -191,6 +192,6 @@
         }
         
         // store current effect for selection feedback
-        (cast(DropTarget)event.widget).feedback = effect;
+        ((DropTarget)event.widget).feedback = effect;
     }
 }