wxDropSource

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

See Drag and drop overview and wxDataObject overview for more information.

Derived from

None

Include files

<wx/dnd.h>

Types

wxDragResult is defined as follows:

enum wxDragResult
{
    wxDragError,    // error prevented the d&d operation from completing
    wxDragNone,     // drag target didn't accept the data
    wxDragCopy,     // the data was successfully copied
    wxDragMove,     // the data was successfully moved (MSW only)
    wxDragLink,     // operation is a drag-link
    wxDragCancel    // the operation was cancelled by user (not an error)
};

See also

wxDropTarget, wxTextDropTarget, wxFileDropTarget



wxDropSource::wxDropSource



wxDropSource(wxWindow* win = NULL,const wxIconOrCursor& iconCopy = wxNullIconOrCursor, const wxIconOrCursor& iconMove = wxNullIconOrCursor, const wxIconOrCursor& iconNone = wxNullIconOrCursor)



wxDropSource(wxDataObject& data, wxWindow* win = NULL,const wxIconOrCursor& iconCopy = wxNullIconOrCursor, const wxIconOrCursor& iconMove = wxNullIconOrCursor, const wxIconOrCursor& iconNone = wxNullIconOrCursor)

The constructors for wxDataObject.

If you use the constructor without data parameter you must call SetData later.

Note that the exact type of iconCopy and subsequent parameters differs between wxMSW and wxGTK: 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.

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.

win is the window which initiates the drag and drop operation.



wxDropSource::~wxDropSource



virtual ~wxDropSource(void)



wxDropSource::SetData



void SetData(wxDataObject& data)

Sets the data wxDataObject associated with the drop source. This will not delete any previously associated data.



wxDropSource::DoDragDrop



virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly)

Do it (call this in response to a mouse button press, for example). This starts the drag-and-drop operation which will terminate when the user releases the mouse.

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
.

Return value

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



wxDropSource::GetDataObject



wxDataObject * GetDataObject(void)

Returns the wxDataObject object that has been assigned previously.



wxDropSource::GiveFeedback



virtual bool GiveFeedback(wxDragResult effect)

Overridable: you may give some custom UI feedback during the drag and drop operation in 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.

scrolling
true if the window is scrolling. MSW only.

Return value

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



wxDropSource::SetCursor



void 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.
ymasuda 平成17年11月19日