Changeset 136:04e357b8343d
- Timestamp:
- 02/13/08 08:24:54 (10 months ago)
- Files:
-
- dwt/dnd/DragSource.d (modified) (20 diffs)
- dwt/dnd/DropTarget.d (modified) (21 diffs)
- dwt/dnd/TableDragSourceEffect.d (modified) (4 diffs)
- dwt/dnd/Transfer.d (modified) (1 diff)
- dwt/dnd/TreeDragSourceEffect.d (modified) (4 diffs)
- dwt/internal/win32/OS.d (modified) (1 diff)
- dwt/internal/win32/WINAPI.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/dnd/DragSource.d
r135 r136 21 21 import dwt.internal.ImageList; 22 22 import dwt.internal.ole.win32.COM; 23 import dwt.internal.ole.win32.OLEIDL; 24 import dwt.internal.ole.win32.OBJIDL; 25 import dwt.internal.ole.win32.ifs; 26 import dwt.internal.ole.win32.extras; 23 27 import dwt.internal.win32.OS; 24 28 import dwt.widgets.Composite; … … 30 34 import dwt.widgets.Tree; 31 35 import dwt.widgets.Widget; 36 37 import dwt.dnd.DragSourceEffect; 38 import dwt.dnd.DragSourceListener; 39 import dwt.dnd.Transfer; 40 import dwt.dnd.TransferData; 41 import dwt.dnd.DND; 42 import dwt.dnd.DNDListener; 43 import dwt.dnd.DNDEvent; 44 import dwt.dnd.TreeDragSourceEffect; 45 import dwt.dnd.TableDragSourceEffect; 46 import dwt.dnd.OleEnumFORMATETC; 47 48 import dwt.dwthelper.utils; 32 49 33 50 /** … … 112 129 Control control; 113 130 Listener controlListener; 114 Transfer[] transferAgents = new Transfer[0];131 Transfer[] transferAgents; 115 132 DragSourceEffect dragEffect; 116 133 Composite topControl; 117 134 118 135 // ole interfaces 119 COMObjectiDropSource;120 COMObjectiDataObject;136 _IDropSourceImpl iDropSource; 137 _IDataObjectImpl iDataObject; 121 138 int refCount; 122 139 … … 124 141 int dataEffect = DND.DROP_NONE; 125 142 126 static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ 127 static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ 128 static final int CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$ 129 143 static const char[] DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ 144 static const char[] DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ 145 static const int CFSTR_PERFORMEDDROPEFFECT; 146 static this(){ 147 CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$ 148 } 130 149 /** 131 150 * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>. … … 167 186 this.AddRef(); 168 187 169 controlListener = new Listener(){188 controlListener = new class() Listener { 170 189 public void handleEvent(Event event) { 171 190 if (event.type is DWT.Dispose) { 172 if (! DragSource.this.isDisposed()) {173 DragSource.this.dispose();191 if (!this.outer.isDisposed()) { 192 this.outer.dispose(); 174 193 } 175 194 } 176 195 if (event.type is DWT.DragDetect) { 177 if (! DragSource.this.isDisposed()) {178 DragSource.this.drag(event);196 if (!this.outer.isDisposed()) { 197 this.outer.drag(event); 179 198 } 180 199 } … … 184 203 control.addListener(DWT.DragDetect, controlListener); 185 204 186 this.addListener(DWT.Dispose, new Listener(){205 this.addListener(DWT.Dispose, new class() Listener { 187 206 public void handleEvent(Event e) { 188 DragSource.this.onDispose();207 this.outer.onDispose(); 189 208 } 190 209 }); 191 210 192 211 Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT); 193 if ( effect instanceof DragSourceEffect) {194 dragEffect = (DragSourceEffect) effect;195 } else if ( control instanceof Tree) {196 dragEffect = new TreeDragSourceEffect( (Tree) control);197 } else if ( control instanceof Table) {198 dragEffect = new TableDragSourceEffect( (Table) control);212 if ( auto dse = cast(DragSourceEffect)effect ) { 213 dragEffect = dse; 214 } else if ( auto tree = cast(Tree)control ) { 215 dragEffect = new TreeDragSourceEffect(tree); 216 } else if ( auto table = cast(Table)control ) { 217 dragEffect = new TableDragSourceEffect(table); 199 218 } 200 219 } … … 250 269 private void createCOMInterfaces() { 251 270 // register each of the interfaces that this object implements 252 iDropSource = new COMObject(new int[]{2, 0, 0, 2, 1}){ 253 public int method0(int[] args) {return QueryInterface(args[0], args[1]);} 254 public int method1(int[] args) {return AddRef();} 255 public int method2(int[] args) {return Release();} 256 public int method3(int[] args) {return QueryContinueDrag(args[0], args[1]);} 257 public int method4(int[] args) {return GiveFeedback(args[0]);} 258 }; 259 260 iDataObject = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 2, 3, 2, 4, 1, 1}){ 261 public int method0(int[] args) {return QueryInterface(args[0], args[1]);} 262 public int method1(int[] args) {return AddRef();} 263 public int method2(int[] args) {return Release();} 264 public int method3(int[] args) {return GetData(args[0], args[1]);} 265 // method4 GetDataHere - not implemented 266 public int method5(int[] args) {return QueryGetData(args[0]);} 267 // method6 GetCanonicalFormatEtc - not implemented 268 public int method7(int[] args) {return SetData(args[0], args[1], args[2]);} 269 public int method8(int[] args) {return EnumFormatEtc(args[0], args[1]);} 270 // method9 DAdvise - not implemented 271 // method10 DUnadvise - not implemented 272 // method11 EnumDAdvise - not implemented 273 }; 271 iDropSource = new _IDropSourceImpl(this); 272 iDataObject = new _IDataObjectImpl(this); 274 273 } 275 274 276 275 protected void checkSubclass() { 277 String name = getClass().getName();278 String validName = DragSource.class.getName();279 if ( !validName.equals(name)) {276 char[] name = this.classinfo.name; 277 char[] validName = DragSource.classinfo.name; 278 if (validName!=/*eq*/name) { 280 279 DND.error(DWT.ERROR_INVALID_SUBCLASS); 281 280 } … … 283 282 284 283 private void disposeCOMInterfaces() { 285 if (iDropSource !is null)286 iDropSource.dispose();287 284 iDropSource = null; 288 289 if (iDataObject !is null)290 iDataObject.dispose();291 285 iDataObject = null; 292 286 } … … 302 296 if (!event.doit || transferAgents is null || transferAgents.length is 0 ) return; 303 297 304 int[] pdwEffect = new int[1];298 uint[1] pdwEffect; 305 299 int operations = opToOs(getStyle()); 306 300 Display display = control.getDisplay(); 307 Stringkey = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$301 char[] key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ 308 302 Object oldValue = display.getData(key); 309 display.setData(key, new bool(true));303 display.setData(key, new ValueWrapperBool(true)); 310 304 ImageList imagelist = null; 311 305 Image image = event.image; … … 328 322 } else { 329 323 int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; 330 OS.RedrawWindow (topControl.handle, null, 0, flags);324 OS.RedrawWindow (topControl.handle, null, null, flags); 331 325 } 332 326 OS.ImageList_DragEnter(topControl.handle, dragEvent.x - location.x, dragEvent.y - location.y); 333 327 } 334 int result = COM.DoDragDrop(iDataObject .getAddress(), iDropSource.getAddress(), operations, pdwEffect);328 int result = COM.DoDragDrop(iDataObject, iDropSource, operations, pdwEffect.ptr); 335 329 if (imagelist !is null) { 336 330 OS.ImageList_DragLeave(topControl.handle); … … 361 355 * must be incremented before returning. Caller is responsible for releasing ppenumFormatetc. 362 356 */ 363 private int EnumFormatEtc(int dwDirection, intppenumFormatetc) {357 private int EnumFormatEtc(int dwDirection, IEnumFORMATETC* ppenumFormatetc) { 364 358 // only allow getting of data - SetData is not currently supported 365 359 if (dwDirection is COM.DATADIR_SET) return COM.E_NOTIMPL; … … 381 375 enumFORMATETC.AddRef(); 382 376 383 FORMATETC [] formats = new FORMATETC[allowedDataTypes.length];377 FORMATETC*[] formats = new FORMATETC*[allowedDataTypes.length]; 384 378 for (int i = 0; i < formats.length; i++){ 385 379 formats[i] = allowedDataTypes[i].formatetc; … … 387 381 enumFORMATETC.setFormats(formats); 388 382 389 OS.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4);383 *ppenumFormatetc = enumFORMATETC.getAddress(); 390 384 return COM.S_OK; 391 385 } … … 400 394 } 401 395 402 private int GetData(int pFormatetc, intpmedium) {396 .LRESULT GetData(FORMATETC *pFormatetc, STGMEDIUM *pmedium) { 403 397 /* Called by a data consumer to obtain data from a source data object. 404 398 The GetData method renders the data described in the specified FORMATETC … … 406 400 The caller then assumes responsibility for releasing the STGMEDIUM structure. 407 401 */ 408 if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG;402 if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG; 409 403 410 404 if (QueryGetData(pFormatetc) !is COM.S_OK) return COM.DV_E_FORMATETC; … … 461 455 } 462 456 463 p rivate int GiveFeedback(intdwEffect) {457 package .LRESULT GiveFeedback(DWORD dwEffect) { 464 458 return COM.DRAGDROP_S_USEDEFAULTCURSORS; 465 459 } 466 460 467 p rivate int QueryContinueDrag(int fEscapePressed, intgrfKeyState) {461 package .LRESULT QueryContinueDrag(int fEscapePressed, DWORD grfKeyState) { 468 462 if (fEscapePressed !is 0){ 469 463 if (topControl !is null) OS.ImageList_DragLeave(topControl.handle); … … 533 527 } 534 528 535 private int QueryGetData(intpFormatetc) {529 private .LRESULT QueryGetData(FORMATETC* pFormatetc) { 536 530 if (transferAgents is null) return COM.E_FAIL; 537 531 TransferData transferData = new TransferData(); … … 554 548 * must be incremented before returning. Caller is responsible for releasing ppvObject. 555 549 */ 556 private int QueryInterface(int riid, intppvObject) {557 if (riid is 0 || ppvObject is 0)550 private HRESULT QueryInterface(REFIID riid, void** ppvObject) { 551 if (riid is null || ppvObject is null) 558 552 return COM.E_INVALIDARG; 559 GUID guid = new GUID(); 560 COM.MoveMemory(guid, riid, GUID.sizeof); 561 562 if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropSource)) { 563 OS.MoveMemory(ppvObject, new int[] {iDropSource.getAddress()}, 4); 553 554 if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropSource)) { 555 *ppvObject = cast(void*)cast(IUnknown) iDropSource; 564 556 AddRef(); 565 557 return COM.S_OK; 566 558 } 567 559 568 if (COM.IsEqualGUID( guid,COM.IIDIDataObject) ) {569 OS.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4);560 if (COM.IsEqualGUID(riid, &COM.IIDIDataObject) ) { 561 *ppvObject = cast(void*)cast(IDataObject) iDataObject; 570 562 AddRef(); 571 563 return COM.S_OK; 572 564 } 573 565 574 OS.MoveMemory(ppvObject, new int[] {0}, 4);566 *ppvObject = null; 575 567 return COM.E_NOINTERFACE; 576 568 } 577 569 578 private intRelease() {570 private ULONG Release() { 579 571 refCount--; 580 572 if (refCount is 0) { … … 609 601 } 610 602 611 private int SetData(int pFormatetc, intpmedium, int fRelease) {612 if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG;613 FORMATETC formatetc = new FORMATETC();603 .LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium, int fRelease) { 604 if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG; 605 FORMATETC* formatetc = new FORMATETC(); 614 606 COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof); 615 607 if (formatetc.cfFormat is CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed is COM.TYMED_HGLOBAL) { 616 STGMEDIUM stgmedium = new STGMEDIUM();608 STGMEDIUM* stgmedium = new STGMEDIUM(); 617 609 COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof); 618 int[ ] ptrEffect = new int[1];619 OS.MoveMemory(ptrEffect , stgmedium.unionField,4);620 int[ ] effect = new int[1];621 OS.MoveMemory(effect , ptrEffect[0],4);610 int[1] ptrEffect; 611 OS.MoveMemory(ptrEffect.ptr, stgmedium.unionField,4); 612 int[1] effect; 613 OS.MoveMemory(effect.ptr, ptrEffect[0],4); 622 614 dataEffect = osToOp(effect[0]); 623 615 } … … 653 645 654 646 } 647 648 649 private class _IDropSourceImpl : IDropSource { 650 651 DragSource parent; 652 this(DragSource p) { parent = p; } 653 extern (Windows): 654 // interface of IUnknown 655 HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } 656 ULONG AddRef() { return parent.AddRef(); } 657 ULONG Release() { return parent.Release(); } 658 659 // interface of IDropSource 660 HRESULT QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { return parent.QueryContinueDrag(fEscapePressed, grfKeyState); } 661 HRESULT GiveFeedback(DWORD dwEffect) { return parent.GiveFeedback(dwEffect);} 662 } 663 664 private class _IDataObjectImpl : IDataObject { 665 666 DragSource parent; 667 this(DragSource p) { parent = p; } 668 extern (Windows): 669 // interface of IUnknown 670 HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } 671 ULONG AddRef() { return parent.AddRef(); } 672 ULONG Release() { return parent.Release(); } 673 674 675 // interface IDataObject 676 LRESULT GetData( FORMATETC *pFormatetc, STGMEDIUM *pmedium) { return parent.GetData(pFormatetc, pmedium); } 677 LRESULT GetDataHere(FORMATETC * pFormatetc, STGMEDIUM * pmedium) { return COM.E_NOTIMPL; } 678 LRESULT QueryGetData(FORMATETC* pFormatetc) { return parent.QueryGetData(pFormatetc); } 679 LRESULT GetCanonicalFormatEtc(FORMATETC* pFormatetcIn, FORMATETC* pFormatetcOut) { return COM.E_NOTIMPL; } 680 LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM * pmedium, BOOL fRelease) { return parent.SetData(pFormatetc, pmedium, fRelease); } 681 LRESULT EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC * ppenumFormatetc) { return parent.EnumFormatEtc(dwDirection, ppenumFormatetc); } 682 LRESULT DAdvise(FORMATETC* pFormatetc, DWORD advf, IAdviseSink pAdvSink, DWORD* pdwConnection) { return COM.E_NOTIMPL; } 683 LRESULT DUnadvise(DWORD dwConnection) { return COM.E_NOTIMPL; } 684 LRESULT EnumDAdvise(IEnumSTATDATA * ppenumAdvise) { return COM.E_NOTIMPL; } 685 } dwt/dnd/DropTarget.d
r135 r136 17 17 import dwt.DWTException; 18 18 import dwt.internal.ole.win32.COM; 19 import dwt.internal.ole.win32.extras; 20 import dwt.internal.ole.win32.OBJIDL; 21 import dwt.internal.ole.win32.OLEIDL; 22 import dwt.internal.ole.win32.ifs; 19 23 import dwt.internal.win32.OS; 20 24 import dwt.widgets.Control; … … 24 28 import dwt.widgets.Tree; 25 29 import dwt.widgets.Widget; 30 31 import dwt.dnd.Transfer; 32 import dwt.dnd.DropTargetEffect; 33 import dwt.dnd.TransferData; 34 import dwt.dnd.DropTargetListener; 35 import dwt.dnd.DNDListener; 36 import dwt.dnd.DNDEvent; 37 import dwt.dnd.DND; 26 38 27 39 /** … … 80 92 Control control; 81 93 Listener controlListener; 82 Transfer[] transferAgents = new Transfer[0];94 Transfer[] transferAgents; 83 95 DropTargetEffect dropEffect; 84 96 … … 96 108 97 109 // interfaces 98 COMObjectiDropTarget;110 _IDropTargetImpl iDropTarget; 99 111 int refCount; 100 112 101 static final StringDEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$102 static final StringDROPTARGETID = "DropTarget"; //$NON-NLS-1$113 static final char[] DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$ 114 static final char[] DROPTARGETID = "DropTarget"; //$NON-NLS-1$ 103 115 104 116 /** … … 148 160 DND.error(DND.ERROR_CANNOT_INIT_DROP); 149 161 150 controlListener = new Listener (){162 controlListener = new class() Listener { 151 163 public void handleEvent (Event event) { 152 if (! DropTarget.this.isDisposed()){153 DropTarget.this.dispose();164 if (!this.outer.isDisposed()){ 165 this.outer.dispose(); 154 166 } 155 167 } … … 157 169 control.addListener (DWT.Dispose, controlListener); 158 170 159 this.addListener(DWT.Dispose, new Listener (){171 this.addListener(DWT.Dispose, new class() Listener { 160 172 public void handleEvent (Event event) { 161 173 onDispose(); … … 164 176 165 177 Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT); 166 if ( effect instanceof DropTargetEffect) {167 dropEffect = (DropTargetEffect) effect;168 } else if ( control instanceof Table) {169 dropEffect = new TableDropTargetEffect( (Table) control);170 } else if ( control instanceof Tree) {171 dropEffect = new TreeDropTargetEffect( (Tree) control);178 if ( auto dte = cast(DropTargetEffect) effect ) { 179 dropEffect = dte; 180 } else if ( auto table = cast(Table)control ) { 181 dropEffect = new TableDropTargetEffect(table); 182 } else if ( auto tree = cast(Tree)control ) { 183 dropEffect = new TreeDropTargetEffect(tree); 172 184 } 173 185 } … … 228 240 229 241 protected void checkSubclass () { 230 String name = getClass().getName ();231 String validName = DropTarget.class.getName();232 if ( !validName.equals(name)) {242 char[] name = this.classinfo.name; 243 char[] validName = DropTarget.classinfo.name; 244 if (validName!=/*eq*/name) { 233 245 DND.error (DWT.ERROR_INVALID_SUBCLASS); 234 246 } … … 237 249 void createCOMInterfaces() { 238 250 // register each of the interfaces that this object implements 239 iDropTarget = new COMObject(new int[]{2, 0, 0, 5, 4, 0, 5}){ 240 public int method0(int[] args) {return QueryInterface(args[0], args[1]);} 241 public int method1(int[] args) {return AddRef();} 242 public int method2(int[] args) {return Release();} 243 public int method3(int[] args) {return DragEnter(args[0], args[1], args[2], args[3], args[4]);} 244 public int method4(int[] args) {return DragOver(args[0], args[1], args[2], args[3]);} 245 public int method5(int[] args) {return DragLeave();} 246 public int method6(int[] args) {return Drop(args[0], args[1], args[2], args[3], args[4]);} 247 }; 248 251 iDropTarget = new _IDropTargetImpl(this); 249 252 } 250 253 251 254 void disposeCOMInterfaces() { 252 if (iDropTarget !is null)253 iDropTarget.dispose();254 255 iDropTarget = null; 255 256 } … … 263 264 DNDEvent event = new DNDEvent(); 264 265 if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) { 265 OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);266 *pdwEffect = COM.DROPEFFECT_NONE; 266 267 return COM.S_FALSE; 267 268 } … … 293 294 } 294 295 295 OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4);296 *pdwEffect = opToOs(selectedOperation); 296 297 return COM.S_OK; 297 298 } … … 321 322 if (!setEventData(event, iDataObject.getAddress(), grfKeyState, pt_x, pt_y, pdwEffect)) { 322 323 keyOperation = -1; 323 OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);324 *pdwEffect = COM.DROPEFFECT_NONE; 324 325 return COM.S_FALSE; 325 326 } … … 356 357 } 357 358 358 OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4);359 *pdwEffect = opToOs(selectedOperation); 359 360 return COM.S_OK; 360 361 } … … 374 375 if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) { 375 376 keyOperation = -1; 376 OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);377 *pdwEffect = COM.DROPEFFECT_NONE; 377 378 return COM.S_FALSE; 378 379 } … … 399 400 400 401 if (selectedOperation is DND.DROP_NONE){ 401 OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);402 *pdwEffect = COM.DROPEFFECT_NONE; 402 403 return COM.S_OK; 403 404 } … … 431 432 } 432 433 //notify source of action taken 433 OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4);434 *pdwEffect = opToOs(selectedOperation); 434 435 return COM.S_OK; 435 436 } … … 534 535 int QueryInterface(int riid, int ppvObject) { 535 536 536 if (riid is 0 || ppvObject is 0)537 if (riid is null || ppvObject is null) 537 538 return COM.E_INVALIDARG; 538 GUID guid = new GUID(); 539 COM.MoveMemory(guid, riid, GUID.sizeof); 540 if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropTarget)) { 541 OS.MoveMemory(ppvObject, new int[] {iDropTarget.getAddress()}, 4); 539 if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropTarget)) { 540 *ppvObject = cast(void*)cast(IUnknown) iDropTarget.getAddress(); 542 541 AddRef(); 543 542 return COM.S_OK; 544 543 } 545 544 546 OS.MoveMemory(ppvObject, new int[] {0}, 4);545 *ppvObject = null; 547 546 return COM.E_NOINTERFACE; 548 547 } … … 562 561 if (control is null || control.isDisposed()) return; 563 562 int handle = control.handle; 564 RECT lpRect = new RECT();565 if (OS.GetUpdateRect(handle, lpRect, false)) {563 RECT lpRect; 564 if (OS.GetUpdateRect(handle, &lpRect, false)) { 566 565 OS.ImageList_DragShowNolock(false); 567 OS.RedrawWindow(handle, lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE);566 OS.RedrawWindow(handle, *lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE); 568 567 OS.ImageList_DragShowNolock(true); 569 568 } … … 615 614 // get allowed operations 616 615 int style = getStyle(); 617 int[ ] operations = new int[1];618 OS.MoveMemory(operations , pdwEffect, 4);616 int[1] operations; 617 OS.MoveMemory(operations.ptr, pdwEffect, 4); 619 618 operations[0] = osToOp(operations[0]) & style; 620 619 if (operations[0] is DND.DROP_NONE) return false; … … 636 635 dataObject.AddRef(); 637 636 try { 638 int[ ] address = new int[1];639 if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address ) !is COM.S_OK) {637 int[1] address; 638 if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address.ptr) !is COM.S_OK) { 640 639 return false; 641 640 } … … 708 707 } 709 708 } 709 710 class _IDropTargetImpl : IDropTarget { 711 712 DropTarget parent; 713 this(DropTarget p) { parent = p; } 714 extern (Windows): 715 // interface of IUnknown 716 HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } 717 ULONG AddRef() { return parent.AddRef(); } 718 ULONG Release() { return parent.Release(); } 719 720 HRESULT DragEnter( IDataObject pDataObj, DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) { 721 return parent.DragEnter(pDataObj, grfKeyState, pt, pdwEffect); 722 } 723 HRESULT DragOver( DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) { 724 return parent.DragOver(grfKeyState, pt, pdwEffect); 725 } 726 HRESULT DragLeave(){ return parent.DragLeave(); } 727 HRESULT Drop(IDataObject pDataObj,DWORD grfKeyState,POINT pt,DWORD *pdwEffect){ 728 return parent.Drop(pDataObj, grfKeyState, pt, pdwEffect); 729 } 730 } 731 732 dwt/dnd/TableDragSourceEffect.d
r135 r136 20 20 import dwt.widgets.Table; 21 21 import dwt.widgets.TableItem; 22 23 import dwt.dnd.DragSourceEffect; 24 import dwt.dnd.DragSourceEvent; 22 25 23 26 /** … … 83 86 if (dragSourceImage !is null) dragSourceImage.dispose(); 84 87 dragSourceImage = null; 85 Table table = (Table) control;88 Table table = cast(Table) control; 86 89 TableItem[] selection = table.getSelection(); 87 90 if (selection.length is 0) return null; … … 91 94 Rectangle bounds = selection[0].getBounds(0); 92 95 for (int i = 1; i < count; i++) { 93 bounds = bounds.union (selection[i].getBounds(0));96 bounds = bounds.union_(selection[i].getBounds(0)); 94 97 } 95 int hDC = OS.GetDC(0);96 inthDC1 = OS.CreateCompatibleDC(hDC);97 intbitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height);98 inthOldBitmap = OS.SelectObject(hDC1, bitmap);98 auto hDC = OS.GetDC(null); 99 auto hDC1 = OS.CreateCompatibleDC(hDC); 100 auto bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); 101 auto hOldBitmap = OS.SelectObject(hDC1, bitmap); 99 102 RECT rect = new RECT(); 100 103 rect.right = bounds.width; … … 112 115 OS.SelectObject(hDC1, hOldBitmap); 113 116 OS.DeleteDC (hDC1); 114 OS.ReleaseDC ( 0, hDC);117 OS.ReleaseDC (null, hDC); 115 118 Display display = table.getDisplay(); 116 119 dragSourceImage = Image.win32_new(display, DWT.BITMAP, bitmap); dwt/dnd/Transfer.d
r135 r136 138 138 // If name is not in registry, add it and return assigned value. 139 139 // If name already exists in registry, return its assigned value 140 TCHAR chFormatName = new TCHAR(0, formatName, true);140 TCHAR* chFormatName = StrToTCHARz(0, formatName); 141 141 return OS.RegisterClipboardFormat(chFormatName); 142 142 } dwt/dnd/TreeDragSourceEffect.d
r135 r136 20 20 import dwt.widgets.Tree; 21 21 import dwt.widgets.TreeItem; 22 23 import dwt.dnd.DragSourceEffect; 24 import dwt.dnd.DragSourceEvent; 22 25 23 26 /** … … 82 85 if (dragSourceImage !is null) dragSourceImage.dispose(); 83 86 dragSourceImage = null; 84 Tree tree = (Tree) control;87 Tree tree = cast(Tree) control; 85 88 TreeItem[] selection = tree.getSelection(); 86 89 if (selection.length is 0) return null; … … 90 93 Rectangle bounds = selection[0].getBounds(0); 91 94 for (int i = 1; i < count; i++) { 92 bounds = bounds.union (selection[i].getBounds(0));95 bounds = bounds.union_(selection[i].getBounds(0)); 93 96 } 94 97 int hDC = OS.GetDC(0); … … 96 99 int bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); 97 100 int hOldBitmap = OS.SelectObject(hDC1, bitmap); 98 RECT rect = new RECT();101 RECT rect; 99 102 rect.right = bounds.width; 100 103 rect.bottom = bounds.height; 101 104 int hBrush = OS.GetStockObject(OS.WHITE_BRUSH); 102 OS.FillRect(hDC1, rect, hBrush);105 OS.FillRect(hDC1, &rect, hBrush); 103 106 for (int i = 0; i < count; i++) { 104 107 TreeItem selected = selection[i]; dwt/internal/win32/OS.d
r128 r136 4654 4654 alias WINAPI.ImageList_Add ImageList_Add; 4655 4655 alias WINAPI.ImageList_AddMasked ImageList_AddMasked; 4656 alias WINAPI.ImageList_BeginDrag ImageList_BeginDrag; 4656 4657 alias WINAPI.ImageList_Create ImageList_Create; 4657 4658 alias WINAPI.ImageList_Destroy ImageList_Destroy; 4659 alias WINAPI.ImageList_DragEnter ImageList_DragEnter; 4660 alias WINAPI.ImageList_DragLeave ImageList_DragLeave; 4661 alias WINAPI.ImageList_DragMove ImageList_DragMove; 4662 alias WINAPI.ImageList_EndDrag ImageList_EndDrag; 4658 4663 alias WINAPI.ImageList_GetIcon ImageList_GetIcon; 4659 4664 alias WINAPI.ImageList_GetIconSize ImageList_GetIconSize; dwt/internal/win32/WINAPI.d
r128 r136 1600 1600 // WINBOOL ImageList_Remove(HIMAGELIST, int); 1601 1601 // HICON ImageList_GetIcon(HIMAGELIST, int, UINT); 1602 //WINBOOL ImageList_BeginDrag(HIMAGELIST, int, int, int);1603 //void ImageList_EndDrag();1604 //WINBOOL ImageList_DragEnter(HWND, int, int);1605 //WINBOOL ImageList_DragLeave(HWND);1606 //WINBOOL ImageList_DragMove(int, int);1602 WINBOOL ImageList_BeginDrag(HIMAGELIST, int, int, int); 1603 void ImageList_EndDrag(); 1604 WINBOOL ImageList_DragEnter(HWND, int, int); 1605 WINBOOL ImageList_DragLeave(HWND); 1606 WINBOOL ImageList_DragMove(int, int); 1607 1607 // WINBOOL ImageList_SetDragCursorImage(HIMAGELIST, int, int, int); 1608 1608 // WINBOOL ImageList_DragShowNolock(WINBOOL);
