Changeset 137:3665cb9211b2

Show
Ignore:
Timestamp:
02/13/08 08:52:31 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

DropTarget?

Files:

Legend:

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

    r136 r137  
    3636import dwt.dnd.DNDEvent; 
    3737import dwt.dnd.DND; 
     38import dwt.dnd.TableDropTargetEffect; 
     39import dwt.dnd.TreeDropTargetEffect; 
     40 
     41import dwt.dwthelper.utils; 
    3842 
    3943/** 
     
    155159    this.AddRef(); 
    156160 
    157     if (COM.CoLockObjectExternal(iDropTarget.getAddress(), true, true) !is COM.S_OK) 
     161    if (COM.CoLockObjectExternal(iDropTarget, true, true) !is COM.S_OK) 
    158162        DND.error(DND.ERROR_CANNOT_INIT_DROP); 
    159     if (COM.RegisterDragDrop( control.handle, iDropTarget.getAddress()) !is COM.S_OK) 
     163    if (COM.RegisterDragDrop( control.handle, iDropTarget) !is COM.S_OK) 
    160164        DND.error(DND.ERROR_CANNOT_INIT_DROP); 
    161165 
     
    234238} 
    235239 
    236 int AddRef() { 
     240ULONG AddRef() { 
    237241    refCount++; 
    238242    return refCount; 
     
    256260} 
    257261 
    258 int DragEnter(int pDataObject, int grfKeyState, int pt_x, int pt_y, int pdwEffect) { 
     262HRESULT DragEnter(IDataObject pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) { 
    259263    selectedDataType = null; 
    260264    selectedOperation = DND.DROP_NONE; 
     
    263267 
    264268    DNDEvent event = new DNDEvent(); 
    265     if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) { 
     269    if (!setEventData(event, pDataObject, grfKeyState, pt, pdwEffect)) { 
    266270        *pdwEffect = COM.DROPEFFECT_NONE; 
    267271        return COM.S_FALSE; 
     
    269273 
    270274    // Remember the iDataObject because it is not passed into the DragOver callback 
    271     iDataObject = new IDataObject(pDataObject)
     275    iDataObject = pDataObject
    272276    iDataObject.AddRef(); 
    273277 
     
    298302} 
    299303 
    300 int DragLeave() { 
     304HRESULT DragLeave() { 
    301305    keyOperation = -1; 
    302306 
     
    315319} 
    316320 
    317 int DragOver(int grfKeyState, int pt_x, int pt_y, int pdwEffect) { 
     321HRESULT DragOver(int grfKeyState, POINTL pt, DWORD* pdwEffect) { 
    318322    if (iDataObject is null) return COM.S_FALSE; 
    319323    int oldKeyOperation = keyOperation; 
    320324 
    321325    DNDEvent event = new DNDEvent(); 
    322     if (!setEventData(event, iDataObject.getAddress(), grfKeyState, pt_x, pt_y, pdwEffect)) { 
     326    if (!setEventData(event, iDataObject, grfKeyState, pt, pdwEffect)) { 
    323327        keyOperation = -1; 
    324328        *pdwEffect = COM.DROPEFFECT_NONE; 
     
    361365} 
    362366 
    363 int Drop(int pDataObject, int grfKeyState, int pt_x, int pt_y, int pdwEffect) { 
     367HRESULT Drop(IDataObject pDataObject, int grfKeyState, POINTL pt, DWORD* pdwEffect) { 
    364368    DNDEvent event = new DNDEvent(); 
    365369    event.widget = this; 
    366370    event.time = OS.GetMessageTime(); 
    367371    if (dropEffect !is null) { 
    368         event.item = dropEffect.getItem(pt_x, pt_y); 
     372        event.item = dropEffect.getItem(pt.x, pt.y); 
    369373    } 
    370374    event.detail = DND.DROP_NONE; 
     
    373377 
    374378    event = new DNDEvent(); 
    375     if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) { 
     379    if (!setEventData(event, pDataObject, grfKeyState, pt, pdwEffect)) { 
    376380        keyOperation = -1; 
    377381        *pdwEffect = COM.DROPEFFECT_NONE; 
     
    494498    control = null; 
    495499 
    496     COM.CoLockObjectExternal(iDropTarget.getAddress(), false, true); 
     500    COM.CoLockObjectExternal(iDropTarget, false, true); 
    497501 
    498502    this.Release(); 
     
    533537 * must be incremented before returning.  Caller is responsible for releasing ppvObject. 
    534538 */ 
    535 int QueryInterface(int riid, int ppvObject) { 
     539HRESULT QueryInterface(REFIID riid, void ** ppvObject) { 
    536540 
    537541    if (riid is null || ppvObject is null) 
    538542        return COM.E_INVALIDARG; 
    539543    if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropTarget)) { 
    540         *ppvObject = cast(void*)cast(IUnknown) iDropTarget.getAddress()
     544        *ppvObject = cast(void*)cast(IDropTarget) iDropTarget
    541545        AddRef(); 
    542546        return COM.S_OK; 
     
    547551} 
    548552 
    549 int Release() { 
     553ULONG Release() { 
    550554    refCount--; 
    551555 
     
    560564void refresh() { 
    561565    if (control is null || control.isDisposed()) return; 
    562     int handle = control.handle; 
     566    auto handle = control.handle; 
    563567    RECT lpRect; 
    564568    if (OS.GetUpdateRect(handle, &lpRect, false)) { 
    565569        OS.ImageList_DragShowNolock(false); 
    566         OS.RedrawWindow(handle, *lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE); 
     570        OS.RedrawWindow(handle, &lpRect, null, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE); 
    567571        OS.ImageList_DragShowNolock(true); 
    568572    } 
     
    609613} 
    610614 
    611 bool setEventData(DNDEvent event, int pDataObject, int grfKeyState, int pt_x, int pt_y, int pdwEffect) { 
    612     if (pDataObject is 0 || pdwEffect is 0) return false; 
     615bool setEventData(DNDEvent event, IDataObject pDataObject, int grfKeyState, POINTL pt, DWORD* pdwEffect) { 
     616    if (pDataObject is null || pdwEffect is null) return false; 
    613617 
    614618    // get allowed operations 
     
    632636    // Get allowed transfer types 
    633637    TransferData[] dataTypes = new TransferData[0]; 
    634     IDataObject dataObject = new IDataObject(pDataObject)
     638    IDataObject dataObject = pDataObject
    635639    dataObject.AddRef(); 
    636640    try { 
    637         int[1] address; 
     641        IEnumFORMATETC[1] address; 
    638642        if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address.ptr) !is COM.S_OK) { 
    639643            return false; 
    640644        } 
    641         IEnumFORMATETC enumFormatetc = new IEnumFORMATETC(address[0])
     645        IEnumFORMATETC enumFormatetc = address[0]
    642646        try { 
    643647            // Loop over enumerator and save any types that match what we are looking for 
    644             int rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, FORMATETC.sizeof); 
     648            auto rgelt = cast(FORMATETC*) OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, FORMATETC.sizeof); 
    645649            try { 
    646                 int[] pceltFetched = new int[1]
     650                uint[1] pceltFetched
    647651                enumFormatetc.Reset(); 
    648                 while (enumFormatetc.Next(1, rgelt, pceltFetched) is COM.S_OK && pceltFetched[0] is 1) { 
     652                while (enumFormatetc.Next(1, rgelt, pceltFetched.ptr) is COM.S_OK && pceltFetched[0] is 1) { 
    649653                    TransferData transferData = new TransferData(); 
    650654                    transferData.formatetc = new FORMATETC(); 
     
    675679 
    676680    event.widget = this; 
    677     event.x = pt_x; 
    678     event.y = pt_y; 
     681    event.x = pt.x; 
     682    event.y = pt.y; 
    679683    event.time = OS.GetMessageTime(); 
    680684    event.feedback = DND.FEEDBACK_SELECT; 
     
    682686    event.dataType = dataTypes[0]; 
    683687    if (dropEffect !is null) { 
    684         event.item = dropEffect.getItem(pt_x, pt_y); 
     688        event.item = dropEffect.getItem(pt.x, pt.y); 
    685689    } 
    686690    event.operations = operations[0]; 
     
    718722    ULONG Release() { return parent.Release(); } 
    719723 
    720     HRESULT DragEnter( IDataObject pDataObj, DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) { 
     724    HRESULT DragEnter( IDataObject pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect ) { 
    721725        return parent.DragEnter(pDataObj, grfKeyState, pt, pdwEffect); 
    722726    } 
    723     HRESULT DragOver( DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) { 
     727    HRESULT DragOver( DWORD grfKeyState, POINTL pt, DWORD *pdwEffect ) { 
    724728        return parent.DragOver(grfKeyState, pt, pdwEffect); 
    725729    } 
    726730    HRESULT DragLeave(){ return parent.DragLeave(); } 
    727     HRESULT Drop(IDataObject pDataObj,DWORD grfKeyState,POINT pt,DWORD *pdwEffect){ 
     731    HRESULT Drop(IDataObject pDataObj,DWORD grfKeyState,POINTL pt,DWORD *pdwEffect){ 
    728732        return parent.Drop(pDataObj, grfKeyState, pt, pdwEffect); 
    729733    } 
  • dwt/dnd/TableDropTargetEffect.d

    r135 r137  
    1717import dwt.widgets.Table; 
    1818import dwt.widgets.TableItem; 
     19 
     20import dwt.dnd.DropTargetEffect; 
     21import dwt.dnd.DropTargetEvent; 
    1922 
    2023/** 
     
    106109     */ 
    107110    public void dragLeave(DropTargetEvent event) { 
    108         Table table = (Table) control; 
     111        Table table = cast(Table) control; 
    109112        int handle = table.handle; 
    110113        if (dropHighlight !is null) { 
     
    136139     */ 
    137140    public void dragOver(DropTargetEvent event) { 
    138         Table table = (Table) getControl(); 
     141        Table table = cast(Table) getControl(); 
    139142        int effect = checkEffect(event.feedback); 
    140143        int handle = table.handle; 
  • dwt/dnd/TreeDropTargetEffect.d

    r135 r137  
    1717import dwt.widgets.Tree; 
    1818import dwt.widgets.TreeItem; 
     19 
     20import dwt.dnd.DropTargetEffect; 
     21import dwt.dnd.DropTargetEvent; 
    1922 
    2023/** 
     
    117120     */ 
    118121    public void dragLeave(DropTargetEvent event) { 
    119         Tree tree = (Tree) control; 
     122        Tree tree = cast(Tree) control; 
    120123        int handle = tree.handle; 
    121124        if (dropIndex !is -1) { 
     
    157160     */ 
    158161    public void dragOver(DropTargetEvent event) { 
    159         Tree tree = (Tree) getControl(); 
     162        Tree tree = cast(Tree) getControl(); 
    160163        int effect = checkEffect(event.feedback); 
    161164        int handle = tree.handle; 
     
    258261            * use the Tree API rather than calling the OS directly. 
    259262            */ 
    260             TreeItem item = (TreeItem)tree.getDisplay().findWidget(tree.handle, hItem); 
     263            TreeItem item = cast(TreeItem)tree.getDisplay().findWidget(tree.handle, hItem); 
    261264            if (item !is null) { 
    262265                if (item !is insertItem || before !is insertBefore) { 
  • dwt/internal/win32/OS.d

    r136 r137  
    46604660alias WINAPI.ImageList_DragLeave ImageList_DragLeave; 
    46614661alias WINAPI.ImageList_DragMove ImageList_DragMove; 
     4662alias WINAPI.ImageList_DragShowNolock ImageList_DragShowNolock; 
    46624663alias WINAPI.ImageList_EndDrag ImageList_EndDrag; 
    46634664alias WINAPI.ImageList_GetIcon ImageList_GetIcon; 
  • dwt/internal/win32/WINAPI.d

    r136 r137  
    16061606    WINBOOL ImageList_DragMove(int, int); 
    16071607//     WINBOOL ImageList_SetDragCursorImage(HIMAGELIST, int, int, int); 
    1608 //     WINBOOL ImageList_DragShowNolock(WINBOOL); 
     1608    WINBOOL ImageList_DragShowNolock(WINBOOL); 
    16091609//     HIMAGELIST ImageList_GetDragImage(POINT*, POINT*); 
    16101610//     WINBOOL ImageList_GetIconSize(HIMAGELIST, int*, int*);