X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e32a6e58ad15a0ab2a28c1bd297c4fc2fa60fb1a..633e19307ce18ce24837db616feb9dda848056dd:/interface/wx/dnd.h diff --git a/interface/wx/dnd.h b/interface/wx/dnd.h index fef09feb98..182fe158e9 100644 --- a/interface/wx/dnd.h +++ b/interface/wx/dnd.h @@ -7,46 +7,15 @@ ///////////////////////////////////////////////////////////////////////////// /** - @class wxTextDropTarget - - A predefined drop target for dealing with text data. - - @library{wxcore} - @category{dnd} - - @see @ref overview_dnd, wxDropSource, wxDropTarget, wxFileDropTarget -*/ -class wxTextDropTarget : public wxDropTarget + Possible flags for drag and drop operations. + */ +enum { -public: - /** - Constructor. - */ - wxTextDropTarget(); - - /** - See wxDropTarget::OnDrop(). This function is implemented appropriately - for text, and calls OnDropText(). - */ - virtual bool OnDrop(wxCoord x, wxCoord y); - - /** - Override this function to receive dropped text. - - @param x - The x coordinate of the mouse. - @param y - The y coordinate of the mouse. - @param data - The data being dropped: a wxString. - - Return @true to accept the data, or @false to veto the operation. - */ - virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& data) = 0; + wxDrag_CopyOnly = 0, ///< Allow only copying. + wxDrag_AllowMove = 1, ///< Allow moving too (copying is always allowed). + wxDrag_DefaultMove = 3 ///< Allow moving and make it default operation. }; - - /** Result returned from a wxDropSource::DoDragDrop() call. */ @@ -60,6 +29,8 @@ enum wxDragResult wxDragCancel ///< The operation was cancelled by user (not an error). }; + + /** @class wxDropTarget @@ -99,23 +70,23 @@ public: associated with this drop target, calling its wxDataObject::SetData() method. */ - virtual bool GetData() = 0; + virtual bool GetData(); /** Called after OnDrop() returns @true. By default this will usually - GetData() and will return the suggested default value @a def. + GetData() and will return the suggested default value @a defResult. */ - virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0; + virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult defResult) = 0; /** Called when the mouse is being dragged over the drop target. By - default, this calls functions return the suggested return value @a def. + default, this calls functions return the suggested return value @a defResult. @param x The x coordinate of the mouse. @param y The y coordinate of the mouse. - @param def + @param defResult Suggested value for return value. Determined by SHIFT or CONTROL key states. @@ -123,7 +94,7 @@ public: feedback from the side of the drop source, typically in form of changing the icon. */ - virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); + virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult defResult); /** Called when the user drops a data object on the target. Return @false @@ -136,7 +107,7 @@ public: @return @true to accept the data, or @false to veto the operation. */ - virtual bool OnDrop(wxCoord x, wxCoord y) = 0; + virtual bool OnDrop(wxCoord x, wxCoord y); /** Called when the mouse enters the drop target. By default, this calls @@ -146,7 +117,7 @@ public: The x coordinate of the mouse. @param y The y coordinate of the mouse. - @param def + @param defResult Suggested default for return value. Determined by SHIFT or CONTROL key states. @@ -154,18 +125,39 @@ public: feedback from the side of the drop source, typically in form of changing the icon. */ - virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def); + virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult defResult); /** Called when the mouse leaves the drop target. */ virtual void OnLeave(); + /** + Returns the data wxDataObject associated with the drop target + */ + wxDataObject *GetDataObject() const; + /** Sets the data wxDataObject associated with the drop target and deletes any previously associated data object. */ void SetDataObject(wxDataObject* data); + + + /** + Sets the default action for drag and drop. Use wxDragMove or + wxDragCopy to set deafult action to move or copy and use wxDragNone + (default) to set default action specified by initialization of draging + (see wxDropSource::DoDragDrop()) + */ + void SetDefaultAction(wxDragResult action); + + /** + Returns default action for drag and drop or wxDragNone if this not + specified. + */ + wxDragResult GetDefaultAction(); + }; @@ -204,9 +196,9 @@ public: The icon or cursor used for feedback when operation can't be done. */ wxDropSource(wxWindow* win = NULL, - const wxCursor& iconCopy = wxNullIcon, - const wxCursor& iconMove = wxNullIcon, - const wxCursor& iconNone = wxNullIcon); + const wxCursor& iconCopy = wxNullCursor, + const wxCursor& iconMove = wxNullCursor, + const wxCursor& iconNone = wxNullCursor); /** The constructor taking a wxDataObject. @@ -230,9 +222,9 @@ public: The icon or cursor used for feedback when operation can't be done. */ wxDropSource(wxDataObject& data, wxWindow* win = NULL, - const wxCursor& iconCopy = wxNullIcon, - const wxCursor& iconMove = wxNullIcon, - const wxCursor& iconNone = wxNullIcon); + const wxCursor& iconCopy = wxNullCursor, + const wxCursor& iconMove = wxNullCursor, + const wxCursor& iconNone = wxNullCursor); /** This constructor requires that you must call SetData() later. @@ -252,9 +244,9 @@ public: The icon or cursor used for feedback when operation can't be done. */ wxDropSource(wxWindow* win = NULL, - const wxIcon& iconCopy = wxNullCursor, - const wxIcon& iconMove = wxNullCursor, - const wxIcon& iconNone = wxNullCursor); + const wxIcon& iconCopy = wxNullIcon, + const wxIcon& iconMove = wxNullIcon, + const wxIcon& iconNone = wxNullIcon); /** The constructor taking a wxDataObject. @@ -276,9 +268,9 @@ public: The icon or cursor used for feedback when operation can't be done. */ wxDropSource(wxDataObject& data, wxWindow* win = NULL, - const wxIcon& iconCopy = wxNullCursor, - const wxIcon& iconMove = wxNullCursor, - const wxIcon& iconNone = wxNullCursor); + const wxIcon& iconCopy = wxNullIcon, + const wxIcon& iconMove = wxNullIcon, + const wxIcon& iconNone = wxNullIcon); /** Starts the drag-and-drop operation which will terminate when the user @@ -286,10 +278,11 @@ public: example. @param 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. + 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. @return The operation requested by the user, may be ::wxDragCopy, ::wxDragMove, ::wxDragLink, ::wxDragCancel or ::wxDragNone if @@ -322,10 +315,24 @@ public: @param res The drag result to set the icon for. @param cursor - The ion to show when this drag result occurs. + The icon to show when this drag result occurs. + + @onlyfor{wxmsw,wxosx} */ void SetCursor(wxDragResult res, const wxCursor& cursor); + /** + Set the icon to use for a certain drag result. + + @param res + The drag result to set the icon for. + @param icon + The icon to show when this drag result occurs. + + @onlyfor{wxgtk} + */ + void SetIcon(wxDragResult res, const wxIcon& icon); + /** Sets the data wxDataObject associated with the drop source. This will not delete any previously associated data. @@ -335,6 +342,46 @@ public: +/** + @class wxTextDropTarget + + A predefined drop target for dealing with text data. + + @library{wxcore} + @category{dnd} + + @see @ref overview_dnd, wxDropSource, wxDropTarget, wxFileDropTarget +*/ +class wxTextDropTarget : public wxDropTarget +{ +public: + /** + Constructor. + */ + wxTextDropTarget(); + + /** + See wxDropTarget::OnDrop(). This function is implemented appropriately + for text, and calls OnDropText(). + */ + virtual bool OnDrop(wxCoord x, wxCoord y); + + /** + Override this function to receive dropped text. + + @param x + The x coordinate of the mouse. + @param y + The y coordinate of the mouse. + @param data + The data being dropped: a wxString. + + Return @true to accept the data, or @false to veto the operation. + */ + virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& data) = 0; +}; + + /** @class wxFileDropTarget @@ -399,5 +446,11 @@ public: */ #define wxDROP_ICON(name) +/** + Returns true if res indicates that something was done during a DnD operation, + i.e. is neither error nor none nor cancel. +*/ +bool wxIsDragResultOk(wxDragResult res); + //@}