| Version: 3.0.5

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
wxDropSource Class Reference
Class List by Category » Clipboard and Drag & Drop

`#include <wx/dnd.h>`

## Detailed Description

This class represents a source for a drag and drop operation.

##

Library: wxCore
Category: Clipboard and Drag & Drop

See also
  Drag and Drop Overview, wxDataObject Overview, wxDropTarget, wxTextDropTarget, wxFileDropTarget

## Public Member Functions

| wxDropSource (wxWindow *win=NULL, const wxCursor &iconCopy=wxNullCursor, const wxCursor &iconMove=wxNullCursor, const wxCursor &iconNone=wxNullCursor)
| This constructor requires that you must call SetData() later. More...
| wxDropSource (wxDataObject &data, wxWindow *win=NULL, const wxCursor &iconCopy=wxNullCursor, const wxCursor &iconMove=wxNullCursor, const wxCursor &iconNone=wxNullCursor)
| The constructor taking a wxDataObject. More...
| wxDropSource (wxWindow *win=NULL, const wxIcon &iconCopy=wxNullIcon, const wxIcon &iconMove=wxNullIcon, const wxIcon &iconNone=wxNullIcon)
| This constructor requires that you must call SetData() later. More...
| wxDropSource (wxDataObject &data, wxWindow *win=NULL, const wxIcon &iconCopy=wxNullIcon, const wxIcon &iconMove=wxNullIcon, const wxIcon &iconNone=wxNullIcon)
| The constructor taking a wxDataObject. More...
virtual wxDragResult | DoDragDrop (int flags=wxDrag_CopyOnly)
| Starts the drag-and-drop operation which will terminate when the user releases the mouse. More...
wxDataObject * | GetDataObject ()
| Returns the wxDataObject object that has been assigned previously. More...
virtual bool | GiveFeedback (wxDragResult effect)
| You may give some custom UI feedback during the drag and drop operation by overriding this function. More...
void | SetCursor (wxDragResult res, const wxCursor &cursor)
| Set the icon to use for a certain drag result. More...
void | SetIcon (wxDragResult res, const wxIcon &icon)
| Set the icon to use for a certain drag result. More...
void | SetData (wxDataObject &data)
| Sets the data wxDataObject associated with the drop source. More...

## Constructor & Destructor Documentation

wxDropSource::wxDropSource | ( | wxWindow * | win = `NULL`,
|  | const wxCursor & | iconCopy = `wxNullCursor`,
|  | const wxCursor & | iconMove = `wxNullCursor`,
|  | const wxCursor & | iconNone = `wxNullCursor`
| ) |  |

This constructor requires that you must call SetData() later.

Note that the type of iconCopy and subsequent parameters differs between different ports: these are cursors under Windows and OS X but icons for GTK. You should use the macro wxDROP_ICON() in portable programs instead of directly using either of these types.

Availability: only available for the wxMSW, wxOSX ports.

Parameters

  win | The window which initiates the drag and drop operation.
  iconCopy | The icon or cursor used for feedback for copy operation.
  iconMove | The icon or cursor used for feedback for move operation.
  iconNone | The icon or cursor used for feedback when operation can't be done.

wxDropSource::wxDropSource | ( | wxDataObject & | data,
|  | wxWindow * | win = `NULL`,
|  | const wxCursor & | iconCopy = `wxNullCursor`,
|  | const wxCursor & | iconMove = `wxNullCursor`,
|  | const wxCursor & | iconNone = `wxNullCursor`
| ) |  |

The constructor taking a wxDataObject.

Note that the type of iconCopy and subsequent parameters differs between different ports: these are cursors under Windows and OS X but icons for GTK. You should use the macro wxDROP_ICON() in portable programs instead of directly using either of these types.

Availability: only available for the wxMSW, wxOSX ports.

Parameters

  data | The data associated with the drop source.
  win | The window which initiates the drag and drop operation.
  iconCopy | The icon or cursor used for feedback for copy operation.
  iconMove | The icon or cursor used for feedback for move operation.
  iconNone | The icon or cursor used for feedback when operation can't be done.

wxDropSource::wxDropSource | ( | wxWindow * | win = `NULL`,
|  | const wxIcon & | iconCopy = `wxNullIcon`,
|  | const wxIcon & | iconMove = `wxNullIcon`,
|  | const wxIcon & | iconNone = `wxNullIcon`
| ) |  |

This constructor requires that you must call SetData() later.

This is the wxGTK-specific version of the constructor taking wxIcon instead of wxCursor as the other ports.

Availability: only available for the wxGTK port.

Parameters

  win | The window which initiates the drag and drop operation.
  iconCopy | The icon or cursor used for feedback for copy operation.
  iconMove | The icon or cursor used for feedback for move operation.
  iconNone | The icon or cursor used for feedback when operation can't be done.

wxDropSource::wxDropSource | ( | wxDataObject & | data,
|  | wxWindow * | win = `NULL`,
|  | const wxIcon & | iconCopy = `wxNullIcon`,
|  | const wxIcon & | iconMove = `wxNullIcon`,
|  | const wxIcon & | iconNone = `wxNullIcon`
| ) |  |

The constructor taking a wxDataObject.

This is the wxGTK-specific version of the constructor taking wxIcon instead of wxCursor as the other ports.

Availability: only available for the wxGTK port.

Parameters

  data | The data associated with the drop source.
  win | The window which initiates the drag and drop operation.
  iconCopy | The icon or cursor used for feedback for copy operation.
  iconMove | The icon or cursor used for feedback for move operation.
  iconNone | The icon or cursor used for feedback when operation can't be done.

## Member Function Documentation

virtual wxDragResult wxDropSource::DoDragDrop | ( | int | flags = `wxDrag_CopyOnly` | ) |

virtual

Starts the drag-and-drop operation which will terminate when the user releases the mouse.

Call this in response to a mouse button press, for example.

Parameters

  flags | If wxDrag_AllowMove is included in the flags, data may be moved and not only copied as is the case for the default wxDrag_CopyOnly. If wxDrag_DefaultMove is specified (which includes the previous flag), moving is not only possible but becomes the default operation.

Returns
  The operation requested by the user, may be wxDragCopy, wxDragMove, wxDragLink, wxDragCancel or wxDragNone if an error occurred.

wxDataObject* wxDropSource::GetDataObject | ( |  | ) |

Returns the wxDataObject object that has been assigned previously.

virtual bool wxDropSource::GiveFeedback | ( | wxDragResult | effect | ) |

virtual

You may give some custom UI feedback during the drag and drop operation by overriding this function.

It is called on each mouse move, so your implementation must not be too slow.

Parameters

  effect | The effect to implement. One of wxDragCopy, wxDragMove, wxDragLink and wxDragNone.

Returns
  false if you want default feedback, or true if you implement your own feedback. The return value is ignored under GTK.

void wxDropSource::SetCursor | ( | wxDragResult | res,
|  | const wxCursor & | cursor
| ) |  |

Set the icon to use for a certain drag result.

Parameters

  res | The drag result to set the icon for.
  cursor | The icon to show when this drag result occurs.

Availability: only available for the wxMSW, wxOSX ports.

void wxDropSource::SetData | ( | wxDataObject & | data | ) |

Sets the data wxDataObject associated with the drop source.

This will not delete any previously associated data.

void wxDropSource::SetIcon | ( | wxDragResult | res,
|  | const wxIcon & | icon
| ) |  |

Set the icon to use for a certain drag result.

Parameters

  res | The drag result to set the icon for.
  icon | The icon to show when this drag result occurs.

Availability: only available for the wxGTK port.