1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of wxDropTarget, wxDropSource classes
4 // Author: Julian Smart
5 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
14 #if wxUSE_DRAG_AND_DROP
16 #include "wx/object.h"
17 #include "wx/string.h"
18 #include "wx/dataobj.h"
19 #include "wx/cursor.h"
21 //-------------------------------------------------------------------------
23 //-------------------------------------------------------------------------
25 class WXDLLIMPEXP_FWD_CORE wxWindow
;
27 class WXDLLIMPEXP_FWD_CORE wxDropTarget
;
28 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget
;
29 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget
;
30 class WXDLLIMPEXP_FWD_CORE wxPrivateDropTarget
;
32 class WXDLLIMPEXP_FWD_CORE wxDropSource
;
34 //-------------------------------------------------------------------------
36 //-------------------------------------------------------------------------
38 class WXDLLIMPEXP_CORE wxDropTarget
: public wxObject
43 virtual ~wxDropTarget();
45 virtual void OnEnter() { }
46 virtual void OnLeave() { }
47 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
) = 0;
49 // Override these to indicate what kind of data you support:
51 virtual size_t GetFormatCount() const = 0;
52 virtual wxDataFormat
GetFormat(size_t n
) const = 0;
57 //-------------------------------------------------------------------------
59 //-------------------------------------------------------------------------
61 class WXDLLIMPEXP_CORE wxTextDropTarget
: public wxDropTarget
66 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
67 virtual bool OnDropText( long x
, long y
, const char *psz
);
71 virtual size_t GetFormatCount() const;
72 virtual wxDataFormat
GetFormat(size_t n
) const;
75 //-------------------------------------------------------------------------
76 // wxPrivateDropTarget
77 //-------------------------------------------------------------------------
79 class WXDLLIMPEXP_CORE wxPrivateDropTarget
: public wxDropTarget
83 wxPrivateDropTarget();
85 // you have to override OnDrop to get at the data
87 // the string ID identifies the format of clipboard or DnD data. a word
88 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
89 // to the clipboard - the latter with the Id "WXWORD_FORMAT".
91 void SetId( const wxString
& id
)
99 virtual size_t GetFormatCount() const;
100 virtual wxDataFormat
GetFormat(size_t n
) const;
105 // ----------------------------------------------------------------------------
106 // A drop target which accepts files (dragged from File Manager or Explorer)
107 // ----------------------------------------------------------------------------
109 class WXDLLIMPEXP_CORE wxFileDropTarget
: public wxDropTarget
113 wxFileDropTarget() {}
115 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
116 virtual bool OnDropFiles( long x
, long y
,
117 size_t nFiles
, const char * const aszFiles
[] );
121 virtual size_t GetFormatCount() const;
122 virtual wxDataFormat
GetFormat(size_t n
) const;
125 //-------------------------------------------------------------------------
127 //-------------------------------------------------------------------------
131 wxDragError
, // error prevented the d&d operation from completing
132 wxDragNone
, // drag target didn't accept the data
133 wxDragCopy
, // the data was successfully copied
134 wxDragMove
, // the data was successfully moved
135 wxDragCancel
// the operation was cancelled by user (not an error)
138 class WXDLLIMPEXP_CORE wxDropSource
: public wxObject
142 wxDropSource( wxWindow
*win
);
143 wxDropSource( wxDataObject
&data
, wxWindow
*win
);
145 virtual ~wxDropSource(void);
147 void SetData( wxDataObject
&data
);
148 wxDragResult
DoDragDrop(int flags
= wxDrag_CopyOnly
);
150 virtual bool GiveFeedback( wxDragResult
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; }
154 void RegisterWindow(void);
155 void UnregisterWindow(void);
158 wxDragResult m_retValue
;
159 wxDataObject
*m_data
;
161 wxCursor m_defaultCursor
;
162 wxCursor m_goaheadCursor
;
168 // wxUSE_DRAG_AND_DROP