Mercurial > projects > dwt-win
diff dwt/dnd/TreeDropTargetEffect.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | 35669d0d0dc5 |
children | e2affbeb686d |
line wrap: on
line diff
--- a/dwt/dnd/TreeDropTargetEffect.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/dnd/TreeDropTargetEffect.d Sat May 17 17:34:28 2008 +0200 @@ -12,8 +12,10 @@ *******************************************************************************/ module dwt.dnd.TreeDropTargetEffect; +import dwt.DWT; import dwt.graphics.Point; import dwt.internal.win32.OS; +import dwt.widgets.Event; import dwt.widgets.Tree; import dwt.widgets.TreeItem; @@ -59,10 +61,10 @@ static final int SCROLL_HYSTERESIS = 200; // milli seconds static final int EXPAND_HYSTERESIS = 1000; // milli seconds - int dropIndex; + int /*long*/ dropIndex; int scrollIndex; long scrollBeginTime; - int expandIndex; + int /*long*/ expandIndex; long expandBeginTime; TreeItem insertItem; bool insertBefore; @@ -171,22 +173,21 @@ lpht.pt.x = coordinates.x; lpht.pt.y = coordinates.y; OS.SendMessage (handle, OS.TVM_HITTEST, 0, &lpht); - int hItem = cast(int) lpht.hItem; + auto hItem = lpht.hItem; if ((effect & DND.FEEDBACK_SCROLL) is 0) { scrollBeginTime = 0; scrollIndex = -1; } else { - if (hItem !is -1 && scrollIndex is hItem && scrollBeginTime !is 0) { + if (hItem !is cast(HTREEITEM)-1 && cast(HTREEITEM)scrollIndex is hItem && scrollBeginTime !is 0) { if (System.currentTimeMillis() >= scrollBeginTime) { - int topItem = OS.SendMessage(handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0); - int nextItem = OS.SendMessage(handle, OS.TVM_GETNEXTITEM, hItem is topItem ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE, hItem); + auto topItem = cast(HTREEITEM)OS.SendMessage(handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0); + auto nextItem = cast(HTREEITEM)OS.SendMessage(handle, OS.TVM_GETNEXTITEM, hItem is topItem ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE, hItem); bool scroll = true; if (hItem is topItem) { - scroll = nextItem !is 0; + scroll = nextItem !is null; } else { RECT itemRect; - itemRect.left = nextItem; - if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, &itemRect) !is 0) { + if (OS.TreeView_GetItemRect (handle, nextItem, &itemRect, true)) { RECT rect; OS.GetClientRect (handle, &rect); POINT pt; @@ -207,23 +208,23 @@ } } else { scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS; - scrollIndex = hItem; + scrollIndex = cast(int)hItem; } } if ((effect & DND.FEEDBACK_EXPAND) is 0) { expandBeginTime = 0; expandIndex = -1; } else { - if (hItem !is -1 && expandIndex is hItem && expandBeginTime !is 0) { + if (cast(int)hItem !is -1 && expandIndex is cast(int)hItem && expandBeginTime !is 0) { if (System.currentTimeMillis() >= expandBeginTime) { if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem) !is 0) { - TVITEM tvItem; - tvItem.hItem = cast(HANDLE) hItem; - tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; - OS.SendMessage (handle, OS.TVM_GETITEM, 0, &tvItem); - if ((tvItem.state & OS.TVIS_EXPANDED) is 0) { - OS.SendMessage (handle, OS.TVM_EXPAND, OS.TVE_EXPAND, hItem); + TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem); + if (item !is null && !item.getExpanded()) { + item.setExpanded(true); tree.redraw(); + Event expandEvent = new Event (); + expandEvent.item = item; + tree.notifyListeners(DWT.Expand, expandEvent); } } expandBeginTime = 0; @@ -231,10 +232,10 @@ } } else { expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS; - expandIndex = hItem; + expandIndex = cast(int)hItem; } } - if (dropIndex !is -1 && (dropIndex !is hItem || (effect & DND.FEEDBACK_SELECT) is 0)) { + if (dropIndex !is -1 && (dropIndex !is cast(int)hItem || (effect & DND.FEEDBACK_SELECT) is 0)) { TVITEM tvItem; tvItem.hItem = cast(HANDLE) dropIndex; tvItem.mask = OS.TVIF_STATE; @@ -243,14 +244,14 @@ OS.SendMessage (handle, OS.TVM_SETITEM, 0, &tvItem); dropIndex = -1; } - if (hItem !is -1 && hItem !is dropIndex && (effect & DND.FEEDBACK_SELECT) !is 0) { + if (cast(int)hItem !is -1 && cast(int)hItem !is dropIndex && (effect & DND.FEEDBACK_SELECT) !is 0) { TVITEM tvItem; tvItem.hItem = cast(HANDLE) hItem; tvItem.mask = OS.TVIF_STATE; tvItem.stateMask = OS.TVIS_DROPHILITED; tvItem.state = OS.TVIS_DROPHILITED; OS.SendMessage (handle, OS.TVM_SETITEM, 0, &tvItem); - dropIndex = hItem; + dropIndex = cast(int)hItem; } if ((effect & DND.FEEDBACK_INSERT_BEFORE) !is 0 || (effect & DND.FEEDBACK_INSERT_AFTER) !is 0) { bool before = (effect & DND.FEEDBACK_INSERT_BEFORE) !is 0; @@ -263,7 +264,7 @@ * Since the insert mark can not be queried from the tree, * use the Tree API rather than calling the OS directly. */ - TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, hItem); + TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem); if (item !is null) { if (item !is insertItem || before !is insertBefore) { tree.setInsertMark(item, before);