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