]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: dnd.h | |
2d120f83 | 3 | // Purpose: declaration of wxDropTarget, wxDropSource classes |
9b6dbb09 JS |
4 | // Author: Julian Smart |
5 | // RCS-ID: $Id$ | |
2d120f83 | 6 | // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart |
65571936 | 7 | // Licence: wxWindows licence |
9b6dbb09 JS |
8 | /////////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | #ifndef _WX_DND_H_ | |
11 | #define _WX_DND_H_ | |
12 | ||
9b6dbb09 | 13 | #include "wx/defs.h" |
2d120f83 JS |
14 | |
15 | #if wxUSE_DRAG_AND_DROP | |
16 | ||
9b6dbb09 JS |
17 | #include "wx/object.h" |
18 | #include "wx/string.h" | |
2d120f83 | 19 | #include "wx/dataobj.h" |
9b6dbb09 JS |
20 | #include "wx/cursor.h" |
21 | ||
22 | //------------------------------------------------------------------------- | |
23 | // classes | |
24 | //------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLEXPORT wxWindow; | |
27 | ||
9b6dbb09 JS |
28 | class WXDLLEXPORT wxDropTarget; |
29 | class WXDLLEXPORT wxTextDropTarget; | |
30 | class WXDLLEXPORT wxFileDropTarget; | |
2d120f83 | 31 | class WXDLLEXPORT wxPrivateDropTarget; |
9b6dbb09 JS |
32 | |
33 | class WXDLLEXPORT wxDropSource; | |
34 | ||
9b6dbb09 JS |
35 | //------------------------------------------------------------------------- |
36 | // wxDropTarget | |
37 | //------------------------------------------------------------------------- | |
38 | ||
39 | class WXDLLEXPORT wxDropTarget: public wxObject | |
40 | { | |
83df96d6 JS |
41 | public: |
42 | ||
9b6dbb09 JS |
43 | wxDropTarget(); |
44 | ~wxDropTarget(); | |
45 | ||
46 | virtual void OnEnter() { } | |
47 | virtual void OnLeave() { } | |
2d120f83 | 48 | virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0; |
83df96d6 | 49 | |
9b6dbb09 | 50 | // Override these to indicate what kind of data you support: |
83df96d6 | 51 | |
9b6dbb09 JS |
52 | virtual size_t GetFormatCount() const = 0; |
53 | virtual wxDataFormat GetFormat(size_t n) const = 0; | |
83df96d6 JS |
54 | |
55 | // implementation | |
9b6dbb09 JS |
56 | }; |
57 | ||
58 | //------------------------------------------------------------------------- | |
59 | // wxTextDropTarget | |
60 | //------------------------------------------------------------------------- | |
61 | ||
62 | class WXDLLEXPORT wxTextDropTarget: public wxDropTarget | |
63 | { | |
83df96d6 JS |
64 | public: |
65 | ||
9b6dbb09 | 66 | wxTextDropTarget() {}; |
2d120f83 | 67 | virtual bool OnDrop( long x, long y, const void *data, size_t size ); |
9b6dbb09 JS |
68 | virtual bool OnDropText( long x, long y, const char *psz ); |
69 | ||
83df96d6 JS |
70 | protected: |
71 | ||
9b6dbb09 JS |
72 | virtual size_t GetFormatCount() const; |
73 | virtual wxDataFormat GetFormat(size_t n) const; | |
74 | }; | |
75 | ||
2d120f83 JS |
76 | //------------------------------------------------------------------------- |
77 | // wxPrivateDropTarget | |
78 | //------------------------------------------------------------------------- | |
79 | ||
80 | class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget | |
81 | { | |
82 | public: | |
2d120f83 | 83 | |
83df96d6 | 84 | wxPrivateDropTarget(); |
2d120f83 | 85 | |
83df96d6 JS |
86 | // you have to override OnDrop to get at the data |
87 | ||
88 | // the string ID identifies the format of clipboard or DnD data. a word | |
89 | // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject | |
90 | // to the clipboard - the latter with the Id "WXWORD_FORMAT". | |
91 | ||
92 | void SetId( const wxString& id ) | |
93 | { m_id = id; } | |
94 | ||
95 | wxString GetId() | |
96 | { return m_id; } | |
2d120f83 | 97 | |
2d120f83 | 98 | private: |
2d120f83 | 99 | |
83df96d6 JS |
100 | virtual size_t GetFormatCount() const; |
101 | virtual wxDataFormat GetFormat(size_t n) const; | |
102 | ||
103 | wxString m_id; | |
2d120f83 JS |
104 | }; |
105 | ||
9b6dbb09 JS |
106 | // ---------------------------------------------------------------------------- |
107 | // A drop target which accepts files (dragged from File Manager or Explorer) | |
108 | // ---------------------------------------------------------------------------- | |
109 | ||
110 | class WXDLLEXPORT wxFileDropTarget: public wxDropTarget | |
111 | { | |
83df96d6 | 112 | public: |
9b6dbb09 JS |
113 | |
114 | wxFileDropTarget() {}; | |
115 | ||
2d120f83 | 116 | virtual bool OnDrop( long x, long y, const void *data, size_t size ); |
9b6dbb09 | 117 | virtual bool OnDropFiles( long x, long y, |
83df96d6 JS |
118 | size_t nFiles, const char * const aszFiles[] ); |
119 | ||
120 | protected: | |
121 | ||
9b6dbb09 JS |
122 | virtual size_t GetFormatCount() const; |
123 | virtual wxDataFormat GetFormat(size_t n) const; | |
124 | }; | |
125 | ||
126 | //------------------------------------------------------------------------- | |
127 | // wxDropSource | |
128 | //------------------------------------------------------------------------- | |
129 | ||
2d120f83 JS |
130 | enum wxDragResult |
131 | { | |
83df96d6 JS |
132 | wxDragError, // error prevented the d&d operation from completing |
133 | wxDragNone, // drag target didn't accept the data | |
134 | wxDragCopy, // the data was successfully copied | |
135 | wxDragMove, // the data was successfully moved | |
136 | wxDragCancel // the operation was cancelled by user (not an error) | |
2d120f83 | 137 | }; |
9b6dbb09 JS |
138 | |
139 | class WXDLLEXPORT wxDropSource: public wxObject | |
140 | { | |
83df96d6 JS |
141 | public: |
142 | ||
9b6dbb09 JS |
143 | wxDropSource( wxWindow *win ); |
144 | wxDropSource( wxDataObject &data, wxWindow *win ); | |
145 | ||
146 | ~wxDropSource(void); | |
147 | ||
148 | void SetData( wxDataObject &data ); | |
2245b2b2 | 149 | wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); |
9b6dbb09 | 150 | |
96be256b | 151 | virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return true; }; |
83df96d6 JS |
152 | |
153 | // implementation | |
2d120f83 JS |
154 | #if 0 |
155 | void RegisterWindow(void); | |
156 | void UnregisterWindow(void); | |
83df96d6 | 157 | |
2d120f83 JS |
158 | wxWindow *m_window; |
159 | wxDragResult m_retValue; | |
9b6dbb09 | 160 | wxDataObject *m_data; |
2d120f83 JS |
161 | |
162 | wxCursor m_defaultCursor; | |
163 | wxCursor m_goaheadCursor; | |
164 | #endif | |
9b6dbb09 JS |
165 | }; |
166 | ||
2d120f83 JS |
167 | #endif |
168 | ||
83df96d6 | 169 | // wxUSE_DRAG_AND_DROP |
2d120f83 | 170 | |
9b6dbb09 | 171 | #endif |
83df96d6 | 172 | //_WX_DND_H_ |
9b6dbb09 | 173 |