]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dnd.h
applied wxNativeFontInfo patch from Derry Bryson (with minor changes)
[wxWidgets.git] / include / wx / motif / dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: dnd.h
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
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef _WX_DND_H_
12 #define _WX_DND_H_
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "wx/defs.h"
19
20 #if wxUSE_DRAG_AND_DROP
21
22 #include "wx/object.h"
23 #include "wx/string.h"
24 #include "wx/dataobj.h"
25 #include "wx/cursor.h"
26
27 //-------------------------------------------------------------------------
28 // classes
29 //-------------------------------------------------------------------------
30
31 class WXDLLEXPORT wxWindow;
32
33 class WXDLLEXPORT wxDropTarget;
34 class WXDLLEXPORT wxTextDropTarget;
35 class WXDLLEXPORT wxFileDropTarget;
36 class WXDLLEXPORT wxPrivateDropTarget;
37
38 class WXDLLEXPORT wxDropSource;
39
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() { }
53 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
54
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;
59
60 // implementation
61 };
62
63 //-------------------------------------------------------------------------
64 // wxTextDropTarget
65 //-------------------------------------------------------------------------
66
67 class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
68 {
69 public:
70
71 wxTextDropTarget() {};
72 virtual bool OnDrop( long x, long y, const void *data, size_t size );
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
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
95 // to the clipboard - the latter with the Id "WXWORD_FORMAT".
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
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
121 virtual bool OnDrop( long x, long y, const void *data, size_t size );
122 virtual bool OnDropFiles( long x, long y,
123 size_t nFiles, const char * const aszFiles[] );
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
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 };
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; };
157
158 // implementation
159 #if 0
160 void RegisterWindow(void);
161 void UnregisterWindow(void);
162
163 wxWindow *m_window;
164 wxDragResult m_retValue;
165 wxDataObject *m_data;
166
167 wxCursor m_defaultCursor;
168 wxCursor m_goaheadCursor;
169 #endif
170 };
171
172 #endif
173
174 // wxUSE_DRAG_AND_DROP
175
176 #endif
177 //_WX_DND_H_
178