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