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