Mercurial > projects > dwt-win
comparison dwt/dnd/DragSource.d @ 136:04e357b8343d
DragSource
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 13 Feb 2008 14:24:54 +0100 |
parents | 242e33c0e383 |
children | 3afcd4ddcf90 |
comparison
equal
deleted
inserted
replaced
135:242e33c0e383 | 136:04e357b8343d |
---|---|
18 import dwt.DWTException; | 18 import dwt.DWTException; |
19 import dwt.graphics.Image; | 19 import dwt.graphics.Image; |
20 import dwt.graphics.Point; | 20 import dwt.graphics.Point; |
21 import dwt.internal.ImageList; | 21 import dwt.internal.ImageList; |
22 import dwt.internal.ole.win32.COM; | 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 import dwt.internal.win32.OS; | 27 import dwt.internal.win32.OS; |
24 import dwt.widgets.Composite; | 28 import dwt.widgets.Composite; |
25 import dwt.widgets.Control; | 29 import dwt.widgets.Control; |
26 import dwt.widgets.Display; | 30 import dwt.widgets.Display; |
27 import dwt.widgets.Event; | 31 import dwt.widgets.Event; |
28 import dwt.widgets.Listener; | 32 import dwt.widgets.Listener; |
29 import dwt.widgets.Table; | 33 import dwt.widgets.Table; |
30 import dwt.widgets.Tree; | 34 import dwt.widgets.Tree; |
31 import dwt.widgets.Widget; | 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 /** |
34 * | 51 * |
35 * <code>DragSource</code> defines the source object for a drag and drop transfer. | 52 * <code>DragSource</code> defines the source object for a drag and drop transfer. |
36 * | 53 * |
109 public class DragSource : Widget { | 126 public class DragSource : Widget { |
110 | 127 |
111 // info for registering as a drag source | 128 // info for registering as a drag source |
112 Control control; | 129 Control control; |
113 Listener controlListener; | 130 Listener controlListener; |
114 Transfer[] transferAgents = new Transfer[0]; | 131 Transfer[] transferAgents; |
115 DragSourceEffect dragEffect; | 132 DragSourceEffect dragEffect; |
116 Composite topControl; | 133 Composite topControl; |
117 | 134 |
118 // ole interfaces | 135 // ole interfaces |
119 COMObject iDropSource; | 136 _IDropSourceImpl iDropSource; |
120 COMObject iDataObject; | 137 _IDataObjectImpl iDataObject; |
121 int refCount; | 138 int refCount; |
122 | 139 |
123 //workaround - track the operation performed by the drop target for DragEnd event | 140 //workaround - track the operation performed by the drop target for DragEnd event |
124 int dataEffect = DND.DROP_NONE; | 141 int dataEffect = DND.DROP_NONE; |
125 | 142 |
126 static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ | 143 static const char[] DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ |
127 static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ | 144 static const char[] DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ |
128 static final int CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$ | 145 static const int CFSTR_PERFORMEDDROPEFFECT; |
129 | 146 static this(){ |
147 CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$ | |
148 } | |
130 /** | 149 /** |
131 * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>. | 150 * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>. |
132 * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform. | 151 * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform. |
133 * It is therefore mandatory that the DragSource instance be disposed when no longer required. | 152 * It is therefore mandatory that the DragSource instance be disposed when no longer required. |
134 * | 153 * |
164 } | 183 } |
165 control.setData(DRAGSOURCEID, this); | 184 control.setData(DRAGSOURCEID, this); |
166 createCOMInterfaces(); | 185 createCOMInterfaces(); |
167 this.AddRef(); | 186 this.AddRef(); |
168 | 187 |
169 controlListener = new Listener() { | 188 controlListener = new class() Listener { |
170 public void handleEvent(Event event) { | 189 public void handleEvent(Event event) { |
171 if (event.type is DWT.Dispose) { | 190 if (event.type is DWT.Dispose) { |
172 if (!DragSource.this.isDisposed()) { | 191 if (!this.outer.isDisposed()) { |
173 DragSource.this.dispose(); | 192 this.outer.dispose(); |
174 } | 193 } |
175 } | 194 } |
176 if (event.type is DWT.DragDetect) { | 195 if (event.type is DWT.DragDetect) { |
177 if (!DragSource.this.isDisposed()) { | 196 if (!this.outer.isDisposed()) { |
178 DragSource.this.drag(event); | 197 this.outer.drag(event); |
179 } | 198 } |
180 } | 199 } |
181 } | 200 } |
182 }; | 201 }; |
183 control.addListener(DWT.Dispose, controlListener); | 202 control.addListener(DWT.Dispose, controlListener); |
184 control.addListener(DWT.DragDetect, controlListener); | 203 control.addListener(DWT.DragDetect, controlListener); |
185 | 204 |
186 this.addListener(DWT.Dispose, new Listener() { | 205 this.addListener(DWT.Dispose, new class() Listener { |
187 public void handleEvent(Event e) { | 206 public void handleEvent(Event e) { |
188 DragSource.this.onDispose(); | 207 this.outer.onDispose(); |
189 } | 208 } |
190 }); | 209 }); |
191 | 210 |
192 Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT); | 211 Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT); |
193 if (effect instanceof DragSourceEffect) { | 212 if ( auto dse = cast(DragSourceEffect)effect ) { |
194 dragEffect = (DragSourceEffect) effect; | 213 dragEffect = dse; |
195 } else if (control instanceof Tree) { | 214 } else if ( auto tree = cast(Tree)control ) { |
196 dragEffect = new TreeDragSourceEffect((Tree) control); | 215 dragEffect = new TreeDragSourceEffect(tree); |
197 } else if (control instanceof Table) { | 216 } else if ( auto table = cast(Table)control ) { |
198 dragEffect = new TableDragSourceEffect((Table) control); | 217 dragEffect = new TableDragSourceEffect(table); |
199 } | 218 } |
200 } | 219 } |
201 | 220 |
202 static int checkStyle(int style) { | 221 static int checkStyle(int style) { |
203 if (style is DWT.NONE) return DND.DROP_MOVE; | 222 if (style is DWT.NONE) return DND.DROP_MOVE; |
247 return refCount; | 266 return refCount; |
248 } | 267 } |
249 | 268 |
250 private void createCOMInterfaces() { | 269 private void createCOMInterfaces() { |
251 // register each of the interfaces that this object implements | 270 // register each of the interfaces that this object implements |
252 iDropSource = new COMObject(new int[]{2, 0, 0, 2, 1}){ | 271 iDropSource = new _IDropSourceImpl(this); |
253 public int method0(int[] args) {return QueryInterface(args[0], args[1]);} | 272 iDataObject = new _IDataObjectImpl(this); |
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 }; | |
274 } | 273 } |
275 | 274 |
276 protected void checkSubclass() { | 275 protected void checkSubclass() { |
277 String name = getClass().getName(); | 276 char[] name = this.classinfo.name; |
278 String validName = DragSource.class.getName(); | 277 char[] validName = DragSource.classinfo.name; |
279 if (!validName.equals(name)) { | 278 if (validName!=/*eq*/name) { |
280 DND.error(DWT.ERROR_INVALID_SUBCLASS); | 279 DND.error(DWT.ERROR_INVALID_SUBCLASS); |
281 } | 280 } |
282 } | 281 } |
283 | 282 |
284 private void disposeCOMInterfaces() { | 283 private void disposeCOMInterfaces() { |
285 if (iDropSource !is null) | |
286 iDropSource.dispose(); | |
287 iDropSource = null; | 284 iDropSource = null; |
288 | |
289 if (iDataObject !is null) | |
290 iDataObject.dispose(); | |
291 iDataObject = null; | 285 iDataObject = null; |
292 } | 286 } |
293 | 287 |
294 private void drag(Event dragEvent) { | 288 private void drag(Event dragEvent) { |
295 DNDEvent event = new DNDEvent(); | 289 DNDEvent event = new DNDEvent(); |
299 event.time = OS.GetMessageTime(); | 293 event.time = OS.GetMessageTime(); |
300 event.doit = true; | 294 event.doit = true; |
301 notifyListeners(DND.DragStart,event); | 295 notifyListeners(DND.DragStart,event); |
302 if (!event.doit || transferAgents is null || transferAgents.length is 0 ) return; | 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 int operations = opToOs(getStyle()); | 299 int operations = opToOs(getStyle()); |
306 Display display = control.getDisplay(); | 300 Display display = control.getDisplay(); |
307 String key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ | 301 char[] key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ |
308 Object oldValue = display.getData(key); | 302 Object oldValue = display.getData(key); |
309 display.setData(key, new bool(true)); | 303 display.setData(key, new ValueWrapperBool(true)); |
310 ImageList imagelist = null; | 304 ImageList imagelist = null; |
311 Image image = event.image; | 305 Image image = event.image; |
312 if (image !is null) { | 306 if (image !is null) { |
313 imagelist = new ImageList(DWT.NONE); | 307 imagelist = new ImageList(DWT.NONE); |
314 imagelist.add(image); | 308 imagelist.add(image); |
325 */ | 319 */ |
326 if (OS.IsWinCE) { | 320 if (OS.IsWinCE) { |
327 OS.UpdateWindow (topControl.handle); | 321 OS.UpdateWindow (topControl.handle); |
328 } else { | 322 } else { |
329 int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; | 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 OS.ImageList_DragEnter(topControl.handle, dragEvent.x - location.x, dragEvent.y - location.y); | 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 if (imagelist !is null) { | 329 if (imagelist !is null) { |
336 OS.ImageList_DragLeave(topControl.handle); | 330 OS.ImageList_DragLeave(topControl.handle); |
337 OS.ImageList_EndDrag(); | 331 OS.ImageList_EndDrag(); |
338 imagelist.dispose(); | 332 imagelist.dispose(); |
339 topControl = null; | 333 topControl = null; |
358 /* | 352 /* |
359 * EnumFormatEtc([in] dwDirection, [out] ppenumFormatetc) | 353 * EnumFormatEtc([in] dwDirection, [out] ppenumFormatetc) |
360 * Ownership of ppenumFormatetc transfers from callee to caller so reference count on ppenumFormatetc | 354 * Ownership of ppenumFormatetc transfers from callee to caller so reference count on ppenumFormatetc |
361 * must be incremented before returning. Caller is responsible for releasing ppenumFormatetc. | 355 * must be incremented before returning. Caller is responsible for releasing ppenumFormatetc. |
362 */ | 356 */ |
363 private int EnumFormatEtc(int dwDirection, int ppenumFormatetc) { | 357 private int EnumFormatEtc(int dwDirection, IEnumFORMATETC* ppenumFormatetc) { |
364 // only allow getting of data - SetData is not currently supported | 358 // only allow getting of data - SetData is not currently supported |
365 if (dwDirection is COM.DATADIR_SET) return COM.E_NOTIMPL; | 359 if (dwDirection is COM.DATADIR_SET) return COM.E_NOTIMPL; |
366 | 360 |
367 // what types have been registered? | 361 // what types have been registered? |
368 TransferData[] allowedDataTypes = new TransferData[0]; | 362 TransferData[] allowedDataTypes = new TransferData[0]; |
378 } | 372 } |
379 | 373 |
380 OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC(); | 374 OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC(); |
381 enumFORMATETC.AddRef(); | 375 enumFORMATETC.AddRef(); |
382 | 376 |
383 FORMATETC[] formats = new FORMATETC[allowedDataTypes.length]; | 377 FORMATETC*[] formats = new FORMATETC*[allowedDataTypes.length]; |
384 for (int i = 0; i < formats.length; i++){ | 378 for (int i = 0; i < formats.length; i++){ |
385 formats[i] = allowedDataTypes[i].formatetc; | 379 formats[i] = allowedDataTypes[i].formatetc; |
386 } | 380 } |
387 enumFORMATETC.setFormats(formats); | 381 enumFORMATETC.setFormats(formats); |
388 | 382 |
389 OS.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4); | 383 *ppenumFormatetc = enumFORMATETC.getAddress(); |
390 return COM.S_OK; | 384 return COM.S_OK; |
391 } | 385 } |
392 /** | 386 /** |
393 * Returns the Control which is registered for this DragSource. This is the control that the | 387 * Returns the Control which is registered for this DragSource. This is the control that the |
394 * user clicks in to initiate dragging. | 388 * user clicks in to initiate dragging. |
397 */ | 391 */ |
398 public Control getControl() { | 392 public Control getControl() { |
399 return control; | 393 return control; |
400 } | 394 } |
401 | 395 |
402 private int GetData(int pFormatetc, int pmedium) { | 396 .LRESULT GetData(FORMATETC *pFormatetc, STGMEDIUM *pmedium) { |
403 /* Called by a data consumer to obtain data from a source data object. | 397 /* Called by a data consumer to obtain data from a source data object. |
404 The GetData method renders the data described in the specified FORMATETC | 398 The GetData method renders the data described in the specified FORMATETC |
405 structure and transfers it through the specified STGMEDIUM structure. | 399 structure and transfers it through the specified STGMEDIUM structure. |
406 The caller then assumes responsibility for releasing the STGMEDIUM structure. | 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 if (QueryGetData(pFormatetc) !is COM.S_OK) return COM.DV_E_FORMATETC; | 404 if (QueryGetData(pFormatetc) !is COM.S_OK) return COM.DV_E_FORMATETC; |
411 | 405 |
412 TransferData transferData = new TransferData(); | 406 TransferData transferData = new TransferData(); |
413 transferData.formatetc = new FORMATETC(); | 407 transferData.formatetc = new FORMATETC(); |
458 */ | 452 */ |
459 public Transfer[] getTransfer(){ | 453 public Transfer[] getTransfer(){ |
460 return transferAgents; | 454 return transferAgents; |
461 } | 455 } |
462 | 456 |
463 private int GiveFeedback(int dwEffect) { | 457 package .LRESULT GiveFeedback(DWORD dwEffect) { |
464 return COM.DRAGDROP_S_USEDEFAULTCURSORS; | 458 return COM.DRAGDROP_S_USEDEFAULTCURSORS; |
465 } | 459 } |
466 | 460 |
467 private int QueryContinueDrag(int fEscapePressed, int grfKeyState) { | 461 package .LRESULT QueryContinueDrag(int fEscapePressed, DWORD grfKeyState) { |
468 if (fEscapePressed !is 0){ | 462 if (fEscapePressed !is 0){ |
469 if (topControl !is null) OS.ImageList_DragLeave(topControl.handle); | 463 if (topControl !is null) OS.ImageList_DragLeave(topControl.handle); |
470 return COM.DRAGDROP_S_CANCEL; | 464 return COM.DRAGDROP_S_CANCEL; |
471 } | 465 } |
472 /* | 466 /* |
530 operation |= DND.DROP_MOVE; | 524 operation |= DND.DROP_MOVE; |
531 } | 525 } |
532 return operation; | 526 return operation; |
533 } | 527 } |
534 | 528 |
535 private int QueryGetData(int pFormatetc) { | 529 private .LRESULT QueryGetData(FORMATETC* pFormatetc) { |
536 if (transferAgents is null) return COM.E_FAIL; | 530 if (transferAgents is null) return COM.E_FAIL; |
537 TransferData transferData = new TransferData(); | 531 TransferData transferData = new TransferData(); |
538 transferData.formatetc = new FORMATETC(); | 532 transferData.formatetc = new FORMATETC(); |
539 COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof); | 533 COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof); |
540 transferData.type = transferData.formatetc.cfFormat; | 534 transferData.type = transferData.formatetc.cfFormat; |
551 | 545 |
552 /* QueryInterface([in] riid, [out] ppvObject) | 546 /* QueryInterface([in] riid, [out] ppvObject) |
553 * Ownership of ppvObject transfers from callee to caller so reference count on ppvObject | 547 * Ownership of ppvObject transfers from callee to caller so reference count on ppvObject |
554 * must be incremented before returning. Caller is responsible for releasing ppvObject. | 548 * must be incremented before returning. Caller is responsible for releasing ppvObject. |
555 */ | 549 */ |
556 private int QueryInterface(int riid, int ppvObject) { | 550 private HRESULT QueryInterface(REFIID riid, void** ppvObject) { |
557 if (riid is 0 || ppvObject is 0) | 551 if (riid is null || ppvObject is null) |
558 return COM.E_INVALIDARG; | 552 return COM.E_INVALIDARG; |
559 GUID guid = new GUID(); | 553 |
560 COM.MoveMemory(guid, riid, GUID.sizeof); | 554 if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropSource)) { |
561 | 555 *ppvObject = cast(void*)cast(IUnknown) iDropSource; |
562 if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropSource)) { | |
563 OS.MoveMemory(ppvObject, new int[] {iDropSource.getAddress()}, 4); | |
564 AddRef(); | 556 AddRef(); |
565 return COM.S_OK; | 557 return COM.S_OK; |
566 } | 558 } |
567 | 559 |
568 if (COM.IsEqualGUID(guid, COM.IIDIDataObject) ) { | 560 if (COM.IsEqualGUID(riid, &COM.IIDIDataObject) ) { |
569 OS.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4); | 561 *ppvObject = cast(void*)cast(IDataObject) iDataObject; |
570 AddRef(); | 562 AddRef(); |
571 return COM.S_OK; | 563 return COM.S_OK; |
572 } | 564 } |
573 | 565 |
574 OS.MoveMemory(ppvObject, new int[] {0}, 4); | 566 *ppvObject = null; |
575 return COM.E_NOINTERFACE; | 567 return COM.E_NOINTERFACE; |
576 } | 568 } |
577 | 569 |
578 private int Release() { | 570 private ULONG Release() { |
579 refCount--; | 571 refCount--; |
580 if (refCount is 0) { | 572 if (refCount is 0) { |
581 disposeCOMInterfaces(); | 573 disposeCOMInterfaces(); |
582 COM.CoFreeUnusedLibraries(); | 574 COM.CoFreeUnusedLibraries(); |
583 } | 575 } |
606 removeListener(DND.DragStart, listener); | 598 removeListener(DND.DragStart, listener); |
607 removeListener(DND.DragSetData, listener); | 599 removeListener(DND.DragSetData, listener); |
608 removeListener(DND.DragEnd, listener); | 600 removeListener(DND.DragEnd, listener); |
609 } | 601 } |
610 | 602 |
611 private int SetData(int pFormatetc, int pmedium, int fRelease) { | 603 .LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium, int fRelease) { |
612 if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG; | 604 if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG; |
613 FORMATETC formatetc = new FORMATETC(); | 605 FORMATETC* formatetc = new FORMATETC(); |
614 COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof); | 606 COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof); |
615 if (formatetc.cfFormat is CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed is COM.TYMED_HGLOBAL) { | 607 if (formatetc.cfFormat is CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed is COM.TYMED_HGLOBAL) { |
616 STGMEDIUM stgmedium = new STGMEDIUM(); | 608 STGMEDIUM* stgmedium = new STGMEDIUM(); |
617 COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof); | 609 COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof); |
618 int[] ptrEffect = new int[1]; | 610 int[1] ptrEffect; |
619 OS.MoveMemory(ptrEffect, stgmedium.unionField,4); | 611 OS.MoveMemory(ptrEffect.ptr, stgmedium.unionField,4); |
620 int[] effect = new int[1]; | 612 int[1] effect; |
621 OS.MoveMemory(effect, ptrEffect[0],4); | 613 OS.MoveMemory(effect.ptr, ptrEffect[0],4); |
622 dataEffect = osToOp(effect[0]); | 614 dataEffect = osToOp(effect[0]); |
623 } | 615 } |
624 if (fRelease is 1) { | 616 if (fRelease is 1) { |
625 COM.ReleaseStgMedium(pmedium); | 617 COM.ReleaseStgMedium(pmedium); |
626 } | 618 } |
650 public void setTransfer(Transfer[] transferAgents){ | 642 public void setTransfer(Transfer[] transferAgents){ |
651 this.transferAgents = transferAgents; | 643 this.transferAgents = transferAgents; |
652 } | 644 } |
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 } |