]>
git.saurik.com Git - wxWidgets.git/blob - interface/dnd.h
d1e5f7d8867d7ffe67a0b83b8aca666a453b30f9
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxTextDropTarget class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxTextDropTarget
13 A predefined drop target for dealing with text data.
19 @ref overview_wxdndoverview "Drag and drop overview", wxDropSource,
20 wxDropTarget, wxFileDropTarget
22 class wxTextDropTarget
: public wxDropTarget
31 See wxDropTarget::OnDrop. This function is implemented
32 appropriately for text, and calls OnDropText().
34 virtual bool OnDrop(long x
, long y
, const void data
, size_t size
);
37 Override this function to receive dropped text.
40 The x coordinate of the mouse.
43 The y coordinate of the mouse.
46 The data being dropped: a wxString.
48 virtual bool OnDropText(wxCoord x
, wxCoord y
,
49 const wxString
& data
);
57 This class represents a target for a drag and drop operation. A wxDataObject
58 can be associated with it and by default, this object will be filled with the
60 drag source, if the data formats supported by the data object match the drag
64 There are various virtual handler functions defined in this class which may be
66 to give visual feedback or react in a more fine-tuned way, e.g. by not
68 the whole window area, but only a small portion of it. The normal sequence of
70 wxDropTarget::OnEnter, possibly many times wxDropTarget::OnDragOver,
71 wxDropTarget::OnDrop and finally wxDropTarget::OnData.
73 See @ref overview_wxdndoverview "Drag and drop overview" and @ref
74 overview_wxdataobjectoverview "wxDataObject overview"
81 wxDropSource, wxTextDropTarget, wxFileDropTarget, wxDataFormat, wxDataObject
87 Constructor. @e data is the data to be associated with the drop target.
89 wxDropTarget(wxDataObject
* data
= @NULL
);
92 Destructor. Deletes the associated data object, if any.
97 This method may only be called from within OnData().
98 By default, this method copies the data from the drop source to the
99 wxDataObject associated with this drop target,
100 calling its wxDataObject::SetData method.
102 virtual void GetData();
105 Called after OnDrop() returns @true. By default this
106 will usually GetData() and will return the suggested
107 default value @e def.
109 virtual wxDragResult
OnData(wxCoord x
, wxCoord y
,
113 Called when the mouse is being dragged over the drop target. By default,
114 this calls functions return the suggested return value @e def.
117 The x coordinate of the mouse.
120 The y coordinate of the mouse.
123 Suggested value for return value. Determined by SHIFT or CONTROL key states.
125 @returns Returns the desired operation or wxDragNone. This is used for
126 optical feedback from the side of the drop source,
127 typically in form of changing the icon.
129 virtual wxDragResult
OnDragOver(wxCoord x
, wxCoord y
,
133 Called when the user drops a data object on the target. Return @false to veto
137 The x coordinate of the mouse.
140 The y coordinate of the mouse.
142 @returns Return @true to accept the data, @false to veto the operation.
144 virtual bool OnDrop(wxCoord x
, wxCoord y
);
147 Called when the mouse enters the drop target. By default, this calls
151 The x coordinate of the mouse.
154 The y coordinate of the mouse.
157 Suggested default for return value. Determined by SHIFT or CONTROL key states.
159 @returns Returns the desired operation or wxDragNone. This is used for
160 optical feedback from the side of the drop source,
161 typically in form of changing the icon.
163 virtual wxDragResult
OnEnter(wxCoord x
, wxCoord y
,
167 Called when the mouse leaves the drop target.
169 virtual void OnLeave();
172 Sets the data wxDataObject associated with the
173 drop target and deletes any previously associated data object.
175 void SetDataObject(wxDataObject
* data
);
183 This class represents a source for a drag and drop operation.
185 See @ref overview_wxdndoverview "Drag and drop overview" and @ref
186 overview_wxdataobjectoverview "wxDataObject overview"
187 for more information.
193 wxDropTarget, wxTextDropTarget, wxFileDropTarget
200 The constructors for wxDataObject.
202 If you use the constructor without @e data parameter you must call
205 Note that the exact type of @e iconCopy and subsequent parameters differs
206 between wxMSW and wxGTK: these are cursors under Windows but icons for GTK.
207 You should use the macro wxDROP_ICON in portable
208 programs instead of directly using either of these types.
211 The window which initiates the drag and drop operation.
214 The icon or cursor used for feedback for copy operation.
217 The icon or cursor used for feedback for move operation.
220 The icon or cursor used for feedback when operation can't be done.
222 wxDropSource(wxWindow
* win
= @NULL
,
223 const wxIconOrCursor
& iconCopy
= wxNullIconOrCursor
,
224 const wxIconOrCursor
& iconMove
= wxNullIconOrCursor
,
225 const wxIconOrCursor
& iconNone
= wxNullIconOrCursor
);
226 wxDropSource(wxDataObject
& data
, wxWindow
* win
= @NULL
,
227 const wxIconOrCursor
& iconCopy
= wxNullIconOrCursor
,
228 const wxIconOrCursor
& iconMove
= wxNullIconOrCursor
,
229 const wxIconOrCursor
& iconNone
= wxNullIconOrCursor
);
238 Do it (call this in response to a mouse button press, for example). This starts
239 the drag-and-drop operation which will terminate when the user releases the
243 If wxDrag_AllowMove is included in the flags, data may
244 be moved and not only copied (default). If wxDrag_DefaultMove is
245 specified (which includes the previous flag), this is even the default
248 @returns Returns the operation requested by the user, may be wxDragCopy,
249 wxDragMove, wxDragLink, wxDragCancel or wxDragNone if
252 virtual wxDragResult
DoDragDrop(int flags
= wxDrag_CopyOnly
);
255 Returns the wxDataObject object that has been assigned previously.
257 wxDataObject
* GetDataObject();
260 Overridable: you may give some custom UI feedback during the drag and drop
262 in this function. It is called on each mouse move, so your implementation must
267 The effect to implement. One of wxDragCopy, wxDragMove, wxDragLink and
271 @true if the window is scrolling. MSW only.
273 @returns Return @false if you want default feedback, or @true if you
274 implement your own feedback. The return values is
277 virtual bool GiveFeedback(wxDragResult effect
);
280 Set the icon to use for a certain drag result.
283 The drag result to set the icon for.
286 The ion to show when this drag result occurs.
288 void SetCursor(wxDragResult res
, const wxCursor
& cursor
);
291 Sets the data wxDataObject associated with the
292 drop source. This will not delete any previously associated data.
294 void SetData(wxDataObject
& data
);
299 @class wxFileDropTarget
302 This is a @ref overview_wxdroptarget "drop target" which accepts files (dragged
303 from File Manager or Explorer).
309 @ref overview_wxdndoverview "Drag and drop overview", wxDropSource,
310 wxDropTarget, wxTextDropTarget
312 class wxFileDropTarget
: public wxDropTarget
321 See wxDropTarget::OnDrop. This function is implemented
322 appropriately for files, and calls OnDropFiles().
324 virtual bool OnDrop(long x
, long y
, const void data
, size_t size
);
327 Override this function to receive dropped files.
330 The x coordinate of the mouse.
333 The y coordinate of the mouse.
336 An array of filenames.
338 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
339 const wxArrayString
& filenames
);
343 // ============================================================================
344 // Global functions/macros
345 // ============================================================================
348 This macro creates either a cursor (MSW) or an icon (elsewhere) with the given
349 name. Under MSW, the cursor is loaded from the resource file and the icon is
350 loaded from XPM file under other platforms.
352 This macro should be used with
353 @ref wxDropSource::wxdropsource "wxDropSource constructor".
355 #define wxIconOrCursor wxDROP_ICON(const char * name) /* implementation is private */