Class: Wx::DragImage

Inherits:
Object show all
Defined in:
lib/wx/doc/gen/drag_image.rb

Overview

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 DragImage object and store it somewhere you can access it as the drag progresses. Call #begin_drag to start, and #end_drag to stop the drag. To move the image, initially call #show and then #move. If you wish to update the screen contents during the drag (for example, highlight an item as in the dragimag sample), first call #hide, update the screen, call #move, and then call #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 do_draw_image and get_image_rect.

Category: Clipboard and Drag & Drop

See Also:

  • Image Sample

Requires:

  • USE_DRAGIMAGE

Instance Method Summary collapse

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initializeWx::DragImage #initialize(image, cursor = Wx::NULL_CURSOR) ⇒ Wx::DragImage #initialize(image, cursor = Wx::NULL_CURSOR) ⇒ Wx::DragImage #initialize(text, cursor = Wx::NULL_CURSOR) ⇒ Wx::DragImage #initialize(treeCtrl, id) ⇒ Wx::DragImage #initialize(listCtrl, id) ⇒ Wx::DragImage

Returns a new instance of DragImage.

Overloads:

  • #initializeWx::DragImage

    Default constructor.

  • #initialize(image, cursor = Wx::NULL_CURSOR) ⇒ Wx::DragImage

    Constructs a drag image from a bitmap and optional cursor.

    Parameters:

    • image (Wx::Bitmap)

      Bitmap to be used as the drag image. The bitmap can have a mask.

    • cursor (Wx::Cursor) (defaults to: Wx::NULL_CURSOR)

      Optional cursor to combine with the image.

  • #initialize(image, cursor = Wx::NULL_CURSOR) ⇒ Wx::DragImage

    Constructs a drag image from an icon and optional cursor.

    Parameters:

    • image (Wx::Icon)

      Icon to be used as the drag image.

    • cursor (Wx::Cursor) (defaults to: Wx::NULL_CURSOR)

      Optional cursor to combine with the image.

  • #initialize(text, cursor = Wx::NULL_CURSOR) ⇒ Wx::DragImage

    Constructs a drag image from a text string and optional cursor.

    Parameters:

    • text (String)

      Text used to construct a drag image.

    • cursor (Wx::Cursor) (defaults to: Wx::NULL_CURSOR)

      Optional cursor to combine with the image.

  • #initialize(treeCtrl, id) ⇒ Wx::DragImage

    Constructs a drag image from the text in the given tree control item, and optional cursor.

    Parameters:

  • #initialize(listCtrl, id) ⇒ Wx::DragImage

    Constructs a drag image from the text in the given list control item, and optional cursor.

    Parameters:

    • listCtrl (Wx::ListCtrl)

      List control for constructing a list drag image.

    • id (Integer)

      List control item id.



51
# File 'lib/wx/doc/gen/drag_image.rb', line 51

def initialize(*args) end

Instance Method Details

#begin_drag(hotspot, window, fullScreen = false, rect = nil) ⇒ Boolean #begin_drag(hotspot, window, boundingWindow) ⇒ Boolean

Overloads:

  • #begin_drag(hotspot, window, fullScreen = false, rect = nil) ⇒ Boolean

    Start dragging the image, in a window or full screen.

    You need to then call #show and #move to show the image on the screen. Call #end_drag when the drag has finished. Note that this call automatically calls CaptureMouse().

    Parameters:

    • hotspot (Array(Integer, Integer), Wx::Point)

      The location of the drag position relative to the upper-left corner of the image.

    • window (Wx::Window)

      The window that captures the mouse, and within which the dragging is limited unless fullScreen is true.

    • fullScreen (Boolean) (defaults to: false)

      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.

    • rect (Wx::Rect) (defaults to: nil)

      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.

    Returns:

    • (Boolean)
  • #begin_drag(hotspot, window, boundingWindow) ⇒ Boolean

    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 #show and #move to show the image on the screen. Call #end_drag when the drag has finished. Note that this call automatically calls CaptureMouse().

    Parameters:

    • hotspot (Array(Integer, Integer), Wx::Point)

      The location of the drag position relative to the upper-left corner of the image.

    • window (Wx::Window)

      The window that captures the mouse, and within which the dragging is limited.

    • boundingWindow (Wx::Window)

      Specifies the area within which the drag occurs.

    Returns:

    • (Boolean)


73
# File 'lib/wx/doc/gen/drag_image.rb', line 73

def begin_drag(*args) end

#end_dragBoolean

Call this when the drag has finished.

Note:

This function automatically releases mouse capture.

Returns:

  • (Boolean)


83
# File 'lib/wx/doc/gen/drag_image.rb', line 83

def end_drag; end

#hideBoolean

Hides the image.

You may wish to call this before updating the window contents (perhaps highlighting an item). Then call #move and #show.

Returns:

  • (Boolean)


89
# File 'lib/wx/doc/gen/drag_image.rb', line 89

def hide; end

#move(pt) ⇒ Boolean

Call this to move the image to a new position.

The image will only be shown if #show has been called previously (for example at the start of the drag).

You can move the image either when the image is hidden or shown, but in general dragging will be smoother if you move the image when it is shown.

Parameters:

  • pt (Array(Integer, Integer), Wx::Point)

    The position in client coordinates (relative to the window specified in #begin_drag).

Returns:

  • (Boolean)


98
# File 'lib/wx/doc/gen/drag_image.rb', line 98

def move(pt) end

#showBoolean

Shows the image.

Call this at least once when dragging.

Returns:

  • (Boolean)


104
# File 'lib/wx/doc/gen/drag_image.rb', line 104

def show; end