Show
Ignore:
Timestamp:
05/17/08 11:34:28 (8 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Update to SWT 3.4M7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dnd/TreeDropTargetEffect.d

    r144 r213  
    1313module dwt.dnd.TreeDropTargetEffect; 
    1414 
     15import dwt.DWT; 
    1516import dwt.graphics.Point; 
    1617import dwt.internal.win32.OS; 
     18import dwt.widgets.Event; 
    1719import dwt.widgets.Tree; 
    1820import dwt.widgets.TreeItem; 
     
    6062    static final int EXPAND_HYSTERESIS = 1000; // milli seconds 
    6163 
    62     int dropIndex; 
     64    int /*long*/ dropIndex; 
    6365    int scrollIndex; 
    6466    long scrollBeginTime; 
    65     int expandIndex; 
     67    int /*long*/ expandIndex; 
    6668    long expandBeginTime; 
    6769    TreeItem insertItem; 
     
    172174        lpht.pt.y = coordinates.y; 
    173175        OS.SendMessage (handle, OS.TVM_HITTEST, 0, &lpht); 
    174         int hItem = cast(int) lpht.hItem; 
     176        auto hItem = lpht.hItem; 
    175177        if ((effect & DND.FEEDBACK_SCROLL) is 0) { 
    176178            scrollBeginTime = 0; 
    177179            scrollIndex = -1; 
    178180        } 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) { 
    180182                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); 
    183185                    bool scroll = true; 
    184186                    if (hItem is topItem) { 
    185                         scroll = nextItem !is 0
     187                        scroll = nextItem !is null
    186188                    } else { 
    187189                        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)) { 
    190191                            RECT rect; 
    191192                            OS.GetClientRect (handle, &rect); 
     
    208209            } else { 
    209210                scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS; 
    210                 scrollIndex = hItem; 
     211                scrollIndex = cast(int)hItem; 
    211212            } 
    212213        } 
     
    215216            expandIndex = -1; 
    216217        } else { 
    217             if (hItem !is -1 && expandIndex is hItem && expandBeginTime !is 0) { 
     218            if (cast(int)hItem !is -1 && expandIndex is cast(int)hItem && expandBeginTime !is 0) { 
    218219                if (System.currentTimeMillis() >= expandBeginTime) { 
    219220                    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); 
    226224                            tree.redraw(); 
     225                            Event expandEvent = new Event (); 
     226                            expandEvent.item = item; 
     227                            tree.notifyListeners(DWT.Expand, expandEvent); 
    227228                        } 
    228229                    } 
     
    232233            } else { 
    233234                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)) { 
    238239            TVITEM tvItem; 
    239240            tvItem.hItem = cast(HANDLE) dropIndex; 
     
    244245            dropIndex = -1; 
    245246        } 
    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) { 
    247248            TVITEM tvItem; 
    248249            tvItem.hItem = cast(HANDLE) hItem; 
     
    251252            tvItem.state = OS.TVIS_DROPHILITED; 
    252253            OS.SendMessage (handle, OS.TVM_SETITEM, 0, &tvItem); 
    253             dropIndex = hItem; 
     254            dropIndex = cast(int)hItem; 
    254255        } 
    255256        if ((effect & DND.FEEDBACK_INSERT_BEFORE) !is 0 || (effect & DND.FEEDBACK_INSERT_AFTER) !is 0) { 
     
    264265            * use the Tree API rather than calling the OS directly. 
    265266            */ 
    266             TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, hItem); 
     267            TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, cast(int)hItem); 
    267268            if (item !is null) { 
    268269                if (item !is insertItem || before !is insertBefore) {