File: wx.GenericDragImage.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (518 lines) | stat: -rw-r--r-- 13,983 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.GenericDragImage:

==========================================================================================================================================
|phoenix_title|  **wx.GenericDragImage**
==========================================================================================================================================

This class is used when you wish to drag an object on the screen, and a simple cursor is not enough.          

On Windows, the Win32 API is used to achieve smooth dragging. On other platforms, GenericDragImage is used. Applications may also prefer to use GenericDragImage on Windows, too. 

To use this class, when you wish to start dragging an image, create a :ref:`wx.DragImage`  object and store it somewhere you can access it as the drag progresses. Call :meth:`~wx.GenericDragImage.BeginDrag`  to start, and :meth:`~wx.GenericDragImage.EndDrag`  to stop the drag. To move the image, initially call :meth:`~wx.GenericDragImage.Show`  and then :meth:`~wx.GenericDragImage.Move`. If you wish to update the screen contents during the drag (for example, highlight an item as in the dragimag sample), first call :meth:`~wx.GenericDragImage.Hide`, update the screen, call :meth:`~wx.GenericDragImage.Move`, and then call :meth:`~wx.GenericDragImage.Show`. 

You can drag within one window, or you can use full-screen dragging either across the whole screen, or just restricted to one area of the screen to save resources. If you want the user to drag between two windows, then you will need to use full-screen dragging. 

If you wish to draw the image yourself, use GenericDragImage and override :meth:`~wx.GenericDragImage.DoDrawImage`  and :meth:`~wx.GenericDragImage.GetImageRect`. 







         



.. seealso:: :ref:`Drag Image Sample <drag image sample>`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>GenericDragImage</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.DragImage_inheritance.png" alt="Inheritance diagram of GenericDragImage" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Object.html" title="wx.Object" alt="" coords="20,5,101,35"/> <area shape="rect" id="node2" href="wx.DragImage.html" title="wx.DragImage" alt="" coords="5,83,117,112"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.GenericDragImage.__init__`                                            Default constructor.
:meth:`~wx.GenericDragImage.BeginDrag`                                           Start dragging the image, in a window or full screen.
:meth:`~wx.GenericDragImage.DoDrawImage`                                         Draws the image on the device context with top-left corner at the given position.
:meth:`~wx.GenericDragImage.EndDrag`                                             Call this when the drag has finished.
:meth:`~wx.GenericDragImage.GetImageRect`                                        Returns the rectangle enclosing the image, assuming that the image is drawn with its top-left corner at the given point.
:meth:`~wx.GenericDragImage.Hide`                                                Hides the image.
:meth:`~wx.GenericDragImage.Move`                                                Call this to move the image to a new position.
:meth:`~wx.GenericDragImage.Show`                                                Shows the image.
:meth:`~wx.GenericDragImage.UpdateBackingFromWindow`                             Override this if you wish to draw the window contents to the backing bitmap yourself.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.GenericDragImage(Object)

   **Possible constructors**::

       GenericDragImage()
       
       GenericDragImage(image, cursor=NullCursor)
       
       GenericDragImage(image, cursor=NullCursor)
       
       GenericDragImage(text, cursor=NullCursor)
       
       GenericDragImage(treeCtrl, id)
       
       GenericDragImage(listCtrl, id)
       
   
   This class is used when you wish to drag an object on the screen, and
   a simple cursor is not enough.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      **~~~**

      
      **__init__** `(self, image, cursor=NullCursor)`
      
      Constructs a drag image from a bitmap and optional cursor.                  
      
      
      
      
      :param `image`: Bitmap to be used as the drag image. The bitmap can have a mask.   
      :type `image`: wx.Bitmap
      :param `cursor`: Optional cursor to combine with the image.   
      :type `cursor`: wx.Cursor
      
      
      
      
      
      
                        
      
      
      
      
      **~~~**

      
      **__init__** `(self, image, cursor=NullCursor)`
      
      Constructs a drag image from an icon and optional cursor.                  
      
      
      
      
      :param `image`: Icon to be used as the drag image.   
      :type `image`: wx.Icon
      :param `cursor`: Optional cursor to combine with the image.   
      :type `cursor`: wx.Cursor
      
      
      
      
      
      
                        
      
      
      
      
      **~~~**

      
      **__init__** `(self, text, cursor=NullCursor)`
      
      Constructs a drag image from a text string and optional cursor.                  
      
      
      
      
      :param `text`: Text used to construct a drag image.   
      :type `text`: string
      :param `cursor`: Optional cursor to combine with the image.   
      :type `cursor`: wx.Cursor
      
      
      
      
      
      
                        
      
      
      
      
      **~~~**

      
      **__init__** `(self, treeCtrl, id)`
      
      Constructs a drag image from the text in the given tree control item, and optional cursor.                  
      
      
      
      
      :param `treeCtrl`: Tree control for constructing a tree drag image.   
      :type `treeCtrl`: wx.TreeCtrl
      :param `id`: Tree control item id.   
      :type `id`: wx.TreeItemId
      
      
      
      
      
      
                        
      
      
      
      
      **~~~**

      
      **__init__** `(self, listCtrl, id)`
      
      Constructs a drag image from the text in the given list control item, and optional cursor.                  
      
      
      
      
      :param `listCtrl`: List control for constructing a list drag image.   
      :type `listCtrl`: wx.ListCtrl
      :param `id`: List control item id.   
      :type `id`: long
      
      
      
      
      
      
                        
      
      
      
      
      **~~~**






   .. method:: BeginDrag(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **BeginDrag** `(self, hotspot, window, fullScreen=False, rect=None)`
      
      Start dragging the image, in a window or full screen.                  
      
      You need to then call :meth:`Show`   and :meth:`Move`   to show the image on the screen. Call :meth:`EndDrag`   when the drag has finished. 
      
      Note that this call automatically calls CaptureMouse(). 
      
      
      
      
      :param `hotspot`: The location of the drag position relative to the upper-left corner of the image.   
      :type `hotspot`: wx.Point
      :param `window`: The window that captures the mouse, and within which the dragging is limited unless fullScreen is ``True``.   
      :type `window`: wx.Window
      :param `fullScreen`: If ``True``, specifies that the drag will be visible over the full screen, or over as much of the screen as is specified by rect. Note that the mouse will still be captured in window.   
      :type `fullScreen`: bool
      :param `rect`: If non-NULL, specifies the rectangle (in screen coordinates) that bounds the dragging operation. Specifying this can make the operation more efficient by cutting down on the area under consideration, and it can also make a visual difference since the drag is clipped to this area.   
      :type `rect`: wx.Rect
      
      
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      **~~~**

      
      **BeginDrag** `(self, hotspot, window, boundingWindow)`
      
      Start dragging the image, using the first window to capture the mouse and the second to specify the bounding area.                  
      
      This form is equivalent to using the first form, but more convenient than working out the bounding rectangle explicitly. 
      
      You need to then call :meth:`Show`   and :meth:`Move`   to show the image on the screen. Call :meth:`EndDrag`   when the drag has finished. 
      
      Note that this call automatically calls CaptureMouse(). 
      
      
      
      
      :param `hotspot`: The location of the drag position relative to the upper-left corner of the image.   
      :type `hotspot`: wx.Point
      :param `window`: The window that captures the mouse, and within which the dragging is limited.   
      :type `window`: wx.Window
      :param `boundingWindow`: Specifies the area within which the drag occurs.   
      :type `boundingWindow`: wx.Window
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      **~~~**






   .. method:: DoDrawImage(self, dc, pos)

      Draws the image on the device context with top-left corner at the given position.                  

      This function is only available with GenericDragImage, to allow applications to draw their own image instead of using an actual bitmap. If you override this function, you must also override :meth:`GetImageRect` .                  


      :param `dc`: 
      :type `dc`: wx.DC
      :param `pos`: 
      :type `pos`: wx.Point




      :rtype: `bool`








   .. method:: EndDrag(self)

      Call this when the drag has finished.                  

                

      :rtype: `bool`







      .. note:: 

         This function automatically releases mouse capture.   








   .. method:: GetImageRect(self, pos)

      Returns the rectangle enclosing the image, assuming that the image is drawn with its top-left corner at the given point.                  

      This function is available in GenericDragImage only, and may be overridden (together with :meth:`DoDrawImage` ) to provide a virtual drawing capability.                  


      :param `pos`: 
      :type `pos`: wx.Point




      :rtype: :ref:`wx.Rect`








   .. method:: Hide(self)

      Hides the image.                  

      You may wish to call this before updating the window contents (perhaps highlighting an item). Then call :meth:`Move`   and :meth:`Show` .                  

      :rtype: `bool`








   .. method:: Move(self, pt)

      Call this to move the image to a new position.                  

      The image will only be shown if :meth:`Show`   has been called previously (for example at the start of the drag). 




      :param `pt`: The position in client coordinates (relative to the window specified in :meth:`BeginDrag` ).  
      :type `pt`: wx.Point






      :rtype: `bool`



                  





   .. method:: Show(self)

      Shows the image.                  

      Call this at least once when dragging.                  

      :rtype: `bool`








   .. method:: UpdateBackingFromWindow(self, windowDC, destDC, sourceRect, destRect)

      Override this if you wish to draw the window contents to the backing bitmap yourself.                  

      This can be desirable if you wish to avoid flicker by not having to redraw the updated window itself just before dragging, which can cause a flicker just as the drag starts. Instead, paint the drag image's backing bitmap to show the appropriate graphic `minus`  the objects to be dragged, and leave the window itself to be updated by the drag image. This can provide eerily smooth, flicker-free drag behaviour. 

      The default implementation copies the window contents to the backing bitmap. A new implementation will normally copy information from another source, such as from its own backing bitmap if it has one, or directly from internal data structures. 

      This function is available in GenericDragImage only.                  


      :param `windowDC`: 
      :type `windowDC`: wx.DC
      :param `destDC`: 
      :type `destDC`: wx.MemoryDC
      :param `sourceRect`: 
      :type `sourceRect`: wx.Rect
      :param `destRect`: 
      :type `destRect`: wx.Rect




      :rtype: `bool`