# HG changeset patch # User Jacob Carlborg # Date 1230732546 -3600 # Node ID 2d6116ea306ea8af96140af8cf3f2f8c09803a65 # Parent a84f60dde47ea537ca88c6cb1744471818dbfdf2 Ported dwt.dnd.TreeDropTargetEffect diff -r a84f60dde47e -r 2d6116ea306e dwt/dnd/TreeDropTargetEffect.d --- a/dwt/dnd/TreeDropTargetEffect.d Wed Dec 31 15:02:49 2008 +0100 +++ b/dwt/dnd/TreeDropTargetEffect.d Wed Dec 31 15:09:06 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.dnd.TreeDropTargetEffect; @@ -19,6 +22,11 @@ import dwt.widgets.Tree; import dwt.widgets.TreeItem; +import dwt.dnd.DND; +import dwt.dnd.DropTarget; +import dwt.dnd.DropTargetEffect; +import dwt.dnd.DropTargetEvent; + /** * This class provides a default drag under effect (eg. select, insert, scroll and expand) * when a drag occurs over a Tree. @@ -52,9 +60,9 @@ * * @since 3.3 */ -public class TreeDropTargetEffect extends DropTargetEffect { - static final int SCROLL_HYSTERESIS = 150; // milli seconds - static final int EXPAND_HYSTERESIS = 1000; // milli seconds +public class TreeDropTargetEffect : DropTargetEffect { + static const int SCROLL_HYSTERESIS = 150; // milli seconds + static const int EXPAND_HYSTERESIS = 1000; // milli seconds int currentEffect = DND.FEEDBACK_NONE; TreeItem currentItem; @@ -102,7 +110,7 @@ * * @param tree the Tree over which the user positions the cursor to drop the data */ - public TreeDropTargetEffect(Tree tree) { + public this(Tree tree) { super(tree); } @@ -157,7 +165,7 @@ * @see DropTargetEvent */ public void dragLeave(DropTargetEvent event) { - Tree tree = (Tree) control; + Tree tree = cast(Tree) control; if (insertItem !is null) { setInsertMark(tree, null, false); insertItem = null; @@ -187,21 +195,21 @@ * @see DND#FEEDBACK_SCROLL */ public void dragOver(DropTargetEvent event) { - Tree tree = (Tree) control; - TreeItem item = (TreeItem)getItem(tree, event.x, event.y); + Tree tree = cast(Tree) control; + TreeItem item = cast(TreeItem)getItem(tree, event.x, event.y); int effect = checkEffect(event.feedback); if ((effect & DND.FEEDBACK_EXPAND) is 0) { expandBeginTime = 0; expandItem = null; } else { - if (item !is null && item.equals(expandItem) && expandBeginTime !is 0) { + if (item !is null && item.opEquals(expandItem) && expandBeginTime !is 0) { if (System.currentTimeMillis() >= expandBeginTime) { if (item.getItemCount() > 0 && !item.getExpanded()) { Event e = new Event(); e.x = event.x; e.y = event.y; e.item = item; - e.time = (int) System.currentTimeMillis(); + e.time = cast(int) System.currentTimeMillis(); tree.notifyListeners(DWT.Expand, e); if (item.isDisposed()) return; item.setExpanded(true); @@ -219,21 +227,21 @@ scrollBeginTime = 0; scrollItem = null; } else { - if (item !is null && item.equals(scrollItem) && scrollBeginTime !is 0) { + if (item !is null && item.opEquals(scrollItem) && scrollBeginTime !is 0) { if (System.currentTimeMillis() >= scrollBeginTime) { Rectangle area = tree.getClientArea(); int headerHeight = tree.getHeaderHeight(); int itemHeight= tree.getItemHeight(); Point pt = new Point(event.x, event.y); pt = tree.getDisplay().map(null, tree, pt); - TreeItem nextItem = null; + TreeItem nextItem_ = null; if (pt.y < area.y + headerHeight + 2 * itemHeight) { - nextItem = previousItem(tree, item); + nextItem_ = previousItem(tree, item); } if (pt.y > area.y + area.height - 2 * itemHeight) { - nextItem = nextItem(tree, item); + nextItem_ = nextItem(tree, item); } - if (nextItem !is null) tree.showItem(nextItem); + if (nextItem_ !is null) tree.showItem(nextItem_); scrollBeginTime = 0; scrollItem = null; } @@ -256,7 +264,7 @@ setInsertMark(tree, null, false); } // save current effect for selection feedback - ((DropTarget)event.widget).feedback = effect; + (cast(DropTarget)event.widget).feedback = effect; } void setInsertMark(Tree tree, TreeItem item, bool before) {