Changeset 213:36f5cb12e1a2 for dwt/dnd/TreeDropTargetEffect.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/dnd/TreeDropTargetEffect.d (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/dnd/TreeDropTargetEffect.d
r144 r213 13 13 module dwt.dnd.TreeDropTargetEffect; 14 14 15 import dwt.DWT; 15 16 import dwt.graphics.Point; 16 17 import dwt.internal.win32.OS; 18 import dwt.widgets.Event; 17 19 import dwt.widgets.Tree; 18 20 import dwt.widgets.TreeItem; … … 60 62 static final int EXPAND_HYSTERESIS = 1000; // milli seconds 61 63 62 int dropIndex;64 int /*long*/ dropIndex; 63 65 int scrollIndex; 64 66 long scrollBeginTime; 65 int expandIndex;67 int /*long*/ expandIndex; 66 68 long expandBeginTime; 67 69 TreeItem insertItem; … … 172 174 lpht.pt.y = coordinates.y; 173 175 OS.SendMessage (handle, OS.TVM_HITTEST, 0, &lpht); 174 int hItem = cast(int)lpht.hItem;176 auto hItem = lpht.hItem; 175 177 if ((effect & DND.FEEDBACK_SCROLL) is 0) { 176 178 scrollBeginTime = 0; 177 179 scrollIndex = -1; 178 180 } else { 179 if (hItem !is -1 &&scrollIndex is hItem && scrollBeginTime !is 0) {181 if (hItem !is cast(HTREEITEM)-1 && cast(HTREEITEM)scrollIndex is hItem && scrollBeginTime !is 0) { 180 182 if (System.currentTimeMillis() >= scrollBeginTime) { 181 int topItem =OS.SendMessage(handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);182 int nextItem =OS.SendMessage(handle, OS.TVM_GETNEXTITEM, hItem is topItem ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE, hItem);183 auto topItem = cast(HTREEITEM)OS.SendMessage(handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0); 184 auto nextItem = cast(HTREEITEM)OS.SendMessage(handle, OS.TVM_GETNEXTITEM, hItem is topItem ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE, hItem); 183 185 bool scroll = true; 184 186 if (hItem is topItem) { 185 scroll = nextItem !is 0;187 scroll = nextItem !is null; 186 188 } else { 187 189 RECT itemRect; 188 itemRect.left = nextItem; 189 if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, &itemRect) !is 0) { 190 if (OS.TreeView_GetItemRect (handle, nextItem, &itemRect, true)) { 190 191 RECT rect; 191 192 OS.GetClientRect (handle, &rect); … … 208 209 } else { 209 210 scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS; 210 scrollIndex = hItem;211 scrollIndex = cast(int)hItem; 211 212 } 212 213 } … … 215 216 expandIndex = -1; 216 217 } else { 217 if ( hItem !is -1 && expandIndex ishItem && expandBeginTime !is 0) {218 if (cast(int)hItem !is -1 && expandIndex is cast(int)hItem && expandBeginTime !is 0) { 218 219 if (System.currentTimeMillis() >= expandBeginTime) { 219 220 if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem) !is 0) { 220 TVITEM tvItem; 221 tvItem.hItem = cast(HANDLE) hItem; 222 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 223 OS.SendMessage (handle, OS.TVM_GETITEM, 0, &tvItem); 224 if ((tvItem.state & OS.TVIS_EXPANDED) is 0) { 225 OS.SendMessage (handle, OS.TVM_EXPAND, OS.TVE_EXPAND, hItem); 221 TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem); 222 if (item !is null && !item.getExpanded()) { 223 item.setExpanded(true); 226 224 tree.redraw(); 225 Event expandEvent = new Event (); 226 expandEvent.item = item; 227 tree.notifyListeners(DWT.Expand, expandEvent); 227 228 } 228 229 } … … 232 233 } else { 233 234 expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS; 234 expandIndex = hItem;235 } 236 } 237 if (dropIndex !is -1 && (dropIndex !is hItem || (effect & DND.FEEDBACK_SELECT) is 0)) {235 expandIndex = cast(int)hItem; 236 } 237 } 238 if (dropIndex !is -1 && (dropIndex !is cast(int)hItem || (effect & DND.FEEDBACK_SELECT) is 0)) { 238 239 TVITEM tvItem; 239 240 tvItem.hItem = cast(HANDLE) dropIndex; … … 244 245 dropIndex = -1; 245 246 } 246 if ( hItem !is -1 &&hItem !is dropIndex && (effect & DND.FEEDBACK_SELECT) !is 0) {247 if (cast(int)hItem !is -1 && cast(int)hItem !is dropIndex && (effect & DND.FEEDBACK_SELECT) !is 0) { 247 248 TVITEM tvItem; 248 249 tvItem.hItem = cast(HANDLE) hItem; … … 251 252 tvItem.state = OS.TVIS_DROPHILITED; 252 253 OS.SendMessage (handle, OS.TVM_SETITEM, 0, &tvItem); 253 dropIndex = hItem;254 dropIndex = cast(int)hItem; 254 255 } 255 256 if ((effect & DND.FEEDBACK_INSERT_BEFORE) !is 0 || (effect & DND.FEEDBACK_INSERT_AFTER) !is 0) { … … 264 265 * use the Tree API rather than calling the OS directly. 265 266 */ 266 TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, hItem);267 TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem); 267 268 if (item !is null) { 268 269 if (item !is insertItem || before !is insertBefore) {
