.. wxPython Phoenix documentation

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

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

.. include:: headings.inc



.. _wx.DragImage:

==========================================================================================================================================
|phoenix_title|  **wx.DragImage**
==========================================================================================================================================

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.DragImage.BeginDrag`  to start, and :meth:`~wx.DragImage.EndDrag`  to stop the drag. To move the image, initially call :meth:`~wx.DragImage.Show`  and then :meth:`~wx.DragImage.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.DragImage.Hide`, update the screen, call :meth:`~wx.DragImage.Move`, and then call :meth:`~wx.DragImage.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.DragImage.DoDrawImage`  and :meth:`~wx.DragImage.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>DragImage</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 DragImage" 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.DragImage.__init__`                                                   Default constructor.
:meth:`~wx.DragImage.BeginDrag`                                                  Start dragging the image, in a window or full screen.
:meth:`~wx.DragImage.EndDrag`                                                    Call this when the drag has finished.
:meth:`~wx.DragImage.Hide`                                                       Hides the image.
:meth:`~wx.DragImage.Move`                                                       Call this to move the image to a new position.
:meth:`~wx.DragImage.Show`                                                       Shows the image.
================================================================================ ================================================================================


|


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


.. class:: wx.DragImage(Object)

   **Possible constructors**::

       DragImage()
       
       DragImage(image, cursor=NullCursor)
       
       DragImage(image, cursor=NullCursor)
       
       DragImage(text, cursor=NullCursor)
       
       DragImage(treeCtrl, id)
       
       DragImage(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:: EndDrag(self)

      Call this when the drag has finished.                  

                

      :rtype: `bool`







      .. note:: 

         This function automatically releases mouse capture.   








   .. 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`







