]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dnd.h
Allow to customize wxGrid column auto-sizing.
[wxWidgets.git] / include / wx / motif / dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/motif/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 #ifndef _WX_DND_H_
11 #define _WX_DND_H_
12
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
26 class WXDLLIMPEXP_FWD_CORE wxWindow;
27
28 class WXDLLIMPEXP_FWD_CORE wxDropTarget;
29 class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
30 class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
31 class WXDLLIMPEXP_FWD_CORE wxPrivateDropTarget;
32
33 class WXDLLIMPEXP_FWD_CORE wxDropSource;
34
35 //-------------------------------------------------------------------------
36 // wxDropTarget
37 //-------------------------------------------------------------------------
38
39 class WXDLLIMPEXP_CORE wxDropTarget: public wxObject
40 {
41 public:
42
43 wxDropTarget();
44 virtual ~wxDropTarget();
45
46 virtual void OnEnter() { }
47 virtual void OnLeave() { }
48 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
49
50 // Override these to indicate what kind of data you support:
51
52 virtual size_t GetFormatCount() const = 0;
53 virtual wxDataFormat GetFormat(size_t n) const = 0;
54
55 // implementation
56 };
57
58 //-------------------------------------------------------------------------
59 // wxTextDropTarget
60 //-------------------------------------------------------------------------
61
62 class WXDLLIMPEXP_CORE wxTextDropTarget: public wxDropTarget
63 {
64 public:
65
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 );
69
70 protected:
71
72 virtual size_t GetFormatCount() const;
73 virtual wxDataFormat GetFormat(size_t n) const;
74 };
75
76 //-------------------------------------------------------------------------
77 // wxPrivateDropTarget
78 //-------------------------------------------------------------------------
79
80 class WXDLLIMPEXP_CORE wxPrivateDropTarget: public wxDropTarget
81 {
82 public:
83
84 wxPrivateDropTarget();
85
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; }
97
98 private:
99
100 virtual size_t GetFormatCount() const;
101 virtual wxDataFormat GetFormat(size_t n) const;
102
103 wxString m_id;
104 };
105
106 // ----------------------------------------------------------------------------
107 // A drop target which accepts files (dragged from File Manager or Explorer)
108 // ----------------------------------------------------------------------------
109
110 class WXDLLIMPEXP_CORE wxFileDropTarget: public wxDropTarget
111 {
112 public:
113
114 wxFileDropTarget() {}
115
116 virtual bool OnDrop( long x, long y, const void *data, size_t size );
117 virtual bool OnDropFiles( long x, long y,
118 size_t nFiles, const char * const aszFiles[] );
119
120 protected:
121
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
139 class WXDLLIMPEXP_CORE wxDropSource: public wxObject
140 {
141 public:
142
143 wxDropSource( wxWindow *win );
144 wxDropSource( wxDataObject &data, wxWindow *win );
145
146 virtual ~wxDropSource(void);
147
148 void SetData( wxDataObject &data );
149 wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
150
151 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return true; }
152
153 // implementation
154 #if 0
155 void RegisterWindow(void);
156 void UnregisterWindow(void);
157
158 wxWindow *m_window;
159 wxDragResult m_retValue;
160 wxDataObject *m_data;
161
162 wxCursor m_defaultCursor;
163 wxCursor m_goaheadCursor;
164 #endif
165 };
166
167 #endif
168
169 // wxUSE_DRAG_AND_DROP
170
171 #endif
172 //_WX_DND_H_