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

List of all members.

## Constructor & Destructor Documentation

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.

Note that the type of iconCopy and subsequent parameters differs between different ports: these are cursors under Windows 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 wxIcon & | iconCopy = `wxNullIcon`,
|  | const wxIcon & | iconMove = `wxNullIcon`,
|  | const wxIcon & | iconNone = `wxNullIcon` |
| ) |  |  |

The constructor for wxDataObject.

Note that the type of iconCopy and subsequent parameters differs between different ports: these are cursors under Windows 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 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 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 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 wxCursor & | iconCopy = `wxNullCursor`,
|  | const wxCursor & | iconMove = `wxNullCursor`,
|  | const wxCursor & | iconNone = `wxNullCursor` |
| ) |  |  |

The constructor for wxDataObject.

Note that the type of iconCopy and subsequent parameters differs between different ports: these are cursors under Windows 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 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.

virtual wxDropSource::~wxDropSource | ( |  | ) | `[virtual]`

Default constructor.

## 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 (default). If wxDrag_DefaultMove is specified (which includes the previous flag), this is even 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 ion to show when this drag result occurs.

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

Sets the data wxDataObject associated with the drop source.

This will not delete any previously associated data.

|  | [ top ]