2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dnd.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxTextDropTarget
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxTextDropTarget
|
|
|
|
@wxheader{dnd.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A predefined drop target for dealing with text data.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{dnd}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see @ref overview_wxdndoverview, wxDropSource, wxDropTarget, wxFileDropTarget
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxTextDropTarget : public wxDropTarget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxTextDropTarget();
|
|
|
|
|
|
|
|
/**
|
|
|
|
See wxDropTarget::OnDrop. This function is implemented
|
|
|
|
appropriately for text, and calls OnDropText().
|
|
|
|
*/
|
|
|
|
virtual bool OnDrop(long x, long y, const void data, size_t size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Override this function to receive dropped text.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param x
|
2008-03-09 08:33:59 -04:00
|
|
|
The x coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param y
|
2008-03-09 08:33:59 -04:00
|
|
|
The y coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param data
|
2008-03-09 08:33:59 -04:00
|
|
|
The data being dropped: a wxString.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool OnDropText(wxCoord x, wxCoord y,
|
|
|
|
const wxString& data);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDropTarget
|
|
|
|
@wxheader{dnd.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a target for a drag and drop operation. A wxDataObject
|
|
|
|
can be associated with it and by default, this object will be filled with the
|
|
|
|
data from the
|
|
|
|
drag source, if the data formats supported by the data object match the drag
|
2008-03-08 09:43:31 -05:00
|
|
|
source data
|
2008-03-08 08:52:38 -05:00
|
|
|
format.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
There are various virtual handler functions defined in this class which may be
|
|
|
|
overridden
|
|
|
|
to give visual feedback or react in a more fine-tuned way, e.g. by not
|
|
|
|
accepting data on
|
|
|
|
the whole window area, but only a small portion of it. The normal sequence of
|
|
|
|
calls is
|
|
|
|
wxDropTarget::OnEnter, possibly many times wxDropTarget::OnDragOver,
|
|
|
|
wxDropTarget::OnDrop and finally wxDropTarget::OnData.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
See @ref overview_wxdndoverview and @ref overview_wxdataobjectoverview
|
2008-03-08 08:52:38 -05:00
|
|
|
for more information.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{dnd}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxDropSource, wxTextDropTarget, wxFileDropTarget, wxDataFormat,
|
|
|
|
wxDataObject
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxDropTarget
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Constructor. @a data is the data to be associated with the drop target.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDropTarget(wxDataObject* data = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor. Deletes the associated data object, if any.
|
|
|
|
*/
|
|
|
|
~wxDropTarget();
|
|
|
|
|
|
|
|
/**
|
|
|
|
This method may only be called from within OnData().
|
2008-03-08 09:43:31 -05:00
|
|
|
By default, this method copies the data from the drop source to the
|
2008-03-08 08:52:38 -05:00
|
|
|
wxDataObject associated with this drop target,
|
|
|
|
calling its wxDataObject::SetData method.
|
|
|
|
*/
|
|
|
|
virtual void GetData();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called after OnDrop() returns @true. By default this
|
|
|
|
will usually GetData() and will return the suggested
|
|
|
|
default value @e def.
|
|
|
|
*/
|
|
|
|
virtual wxDragResult OnData(wxCoord x, wxCoord y,
|
|
|
|
wxDragResult def);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Called when the mouse is being dragged over the drop target. By default,
|
2008-03-08 08:52:38 -05:00
|
|
|
this calls functions return the suggested return value @e def.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param x
|
2008-03-09 08:33:59 -04:00
|
|
|
The x coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param y
|
2008-03-09 08:33:59 -04:00
|
|
|
The y coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param def
|
2008-03-09 08:33:59 -04:00
|
|
|
Suggested value for return value. Determined by SHIFT or CONTROL key states.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@returns Returns the desired operation or wxDragNone. This is used for
|
2008-03-09 08:33:59 -04:00
|
|
|
optical feedback from the side of the drop source,
|
|
|
|
typically in form of changing the icon.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y,
|
|
|
|
wxDragResult def);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called when the user drops a data object on the target. Return @false to veto
|
|
|
|
the operation.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param x
|
2008-03-09 08:33:59 -04:00
|
|
|
The x coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param y
|
2008-03-09 08:33:59 -04:00
|
|
|
The y coordinate of the mouse.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@returns Return @true to accept the data, @false to veto the operation.
|
|
|
|
*/
|
|
|
|
virtual bool OnDrop(wxCoord x, wxCoord y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called when the mouse enters the drop target. By default, this calls
|
|
|
|
OnDragOver().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param x
|
2008-03-09 08:33:59 -04:00
|
|
|
The x coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param y
|
2008-03-09 08:33:59 -04:00
|
|
|
The y coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param def
|
2008-03-09 08:33:59 -04:00
|
|
|
Suggested default for return value. Determined by SHIFT or CONTROL key
|
|
|
|
states.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@returns Returns the desired operation or wxDragNone. This is used for
|
2008-03-09 08:33:59 -04:00
|
|
|
optical feedback from the side of the drop source,
|
|
|
|
typically in form of changing the icon.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual wxDragResult OnEnter(wxCoord x, wxCoord y,
|
|
|
|
wxDragResult def);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called when the mouse leaves the drop target.
|
|
|
|
*/
|
|
|
|
virtual void OnLeave();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Sets the data wxDataObject associated with the
|
2008-03-08 08:52:38 -05:00
|
|
|
drop target and deletes any previously associated data object.
|
|
|
|
*/
|
|
|
|
void SetDataObject(wxDataObject* data);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDropSource
|
|
|
|
@wxheader{dnd.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a source for a drag and drop operation.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
See @ref overview_wxdndoverview and @ref overview_wxdataobjectoverview
|
2008-03-08 08:52:38 -05:00
|
|
|
for more information.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{dnd}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxDropTarget, wxTextDropTarget, wxFileDropTarget
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxDropSource
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
The constructors for wxDataObject.
|
2008-03-09 08:33:59 -04:00
|
|
|
If you use the constructor without @a data parameter you must call
|
2008-03-08 08:52:38 -05:00
|
|
|
SetData() later.
|
2008-03-09 08:33:59 -04:00
|
|
|
Note that the exact type of @a iconCopy and subsequent parameters differs
|
2008-03-08 08:52:38 -05:00
|
|
|
between wxMSW and wxGTK: these are cursors under Windows but icons for GTK.
|
2008-03-10 11:24:38 -04:00
|
|
|
You should use the macro wxDROP_ICON() in portable
|
2008-03-08 08:52:38 -05:00
|
|
|
programs instead of directly using either of these types.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param win
|
2008-03-09 08:33:59 -04:00
|
|
|
The window which initiates the drag and drop operation.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param iconCopy
|
2008-03-09 08:33:59 -04:00
|
|
|
The icon or cursor used for feedback for copy operation.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param iconMove
|
2008-03-09 08:33:59 -04:00
|
|
|
The icon or cursor used for feedback for move operation.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param iconNone
|
2008-03-09 08:33:59 -04:00
|
|
|
The icon or cursor used for feedback when operation can't be done.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDropSource(wxWindow* win = NULL,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxIconOrCursor& iconCopy = wxNullIconOrCursor,
|
|
|
|
const wxIconOrCursor& iconMove = wxNullIconOrCursor,
|
|
|
|
const wxIconOrCursor& iconNone = wxNullIconOrCursor);
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDropSource(wxDataObject& data, wxWindow* win = NULL,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxIconOrCursor& iconCopy = wxNullIconOrCursor,
|
|
|
|
const wxIconOrCursor& iconMove = wxNullIconOrCursor,
|
|
|
|
const wxIconOrCursor& iconNone = wxNullIconOrCursor);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
~wxDropSource();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param flags
|
2008-03-09 08:33:59 -04:00
|
|
|
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
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@returns Returns the operation requested by the user, may be wxDragCopy,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDragMove, wxDragLink, wxDragCancel or wxDragNone if
|
|
|
|
an error occurred.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the wxDataObject object that has been assigned previously.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDataObject* GetDataObject();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param effect
|
2008-03-09 08:33:59 -04:00
|
|
|
The effect to implement. One of wxDragCopy, wxDragMove, wxDragLink and
|
2008-03-08 08:52:38 -05:00
|
|
|
wxDragNone.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param scrolling
|
2008-03-09 08:33:59 -04:00
|
|
|
@true if the window is scrolling. MSW only.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@returns Return @false if you want default feedback, or @true if you
|
2008-03-09 08:33:59 -04:00
|
|
|
implement your own feedback. The return values is
|
|
|
|
ignored under GTK.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool GiveFeedback(wxDragResult effect);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the icon to use for a certain drag result.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param res
|
2008-03-09 08:33:59 -04:00
|
|
|
The drag result to set the icon for.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param cursor
|
2008-03-09 08:33:59 -04:00
|
|
|
The ion to show when this drag result occurs.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetCursor(wxDragResult res, const wxCursor& cursor);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Sets the data wxDataObject associated with the
|
2008-03-08 08:52:38 -05:00
|
|
|
drop source. This will not delete any previously associated data.
|
|
|
|
*/
|
|
|
|
void SetData(wxDataObject& data);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileDropTarget
|
|
|
|
@wxheader{dnd.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a @ref overview_wxdroptarget "drop target" which accepts files (dragged
|
|
|
|
from File Manager or Explorer).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{dnd}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see @ref overview_wxdndoverview, wxDropSource, wxDropTarget, wxTextDropTarget
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileDropTarget : public wxDropTarget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxFileDropTarget();
|
|
|
|
|
|
|
|
/**
|
|
|
|
See wxDropTarget::OnDrop. This function is implemented
|
|
|
|
appropriately for files, and calls OnDropFiles().
|
|
|
|
*/
|
|
|
|
virtual bool OnDrop(long x, long y, const void data, size_t size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Override this function to receive dropped files.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param x
|
2008-03-09 08:33:59 -04:00
|
|
|
The x coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param y
|
2008-03-09 08:33:59 -04:00
|
|
|
The y coordinate of the mouse.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param filenames
|
2008-03-09 08:33:59 -04:00
|
|
|
An array of filenames.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool OnDropFiles(wxCoord x, wxCoord y,
|
|
|
|
const wxArrayString& filenames);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2008-03-20 02:00:05 -04:00
|
|
|
/** @ingroup group_funcmacro_gdi */
|
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-20 02:00:05 -04:00
|
|
|
This macro creates either a cursor (MSW) or an icon (elsewhere) with the
|
|
|
|
given @a name (of type <tt>const char*</tt>). Under MSW, the cursor is
|
|
|
|
loaded from the resource file and the icon is loaded from XPM file under
|
|
|
|
other platforms.
|
|
|
|
|
|
|
|
This macro should be used with wxDropSource::wxDropSource().
|
|
|
|
|
|
|
|
@returns wxCursor on MSW, otherwise returns a wxIcon
|
|
|
|
|
|
|
|
@header{wx/dnd.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-20 02:00:05 -04:00
|
|
|
#define wxDROP_ICON(name)
|
|
|
|
|
|
|
|
//@}
|
2008-03-08 08:52:38 -05:00
|
|
|
|