]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dnd.h
Win16 corrections
[wxWidgets.git] / include / wx / gtk / dnd.h
CommitLineData
c801d85f
KB
1///////////////////////////////////////////////////////////////////////////////
2// Name: dnd.h
3// Purpose: declaration of the wxDropTarget class
4// Author: Robert Roebling
58614078 5// RCS-ID: $Id$
c801d85f
KB
6// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7// Licence: wxWindows license
8///////////////////////////////////////////////////////////////////////////////
9
10
11#ifndef __GTKDNDH__
12#define __GTKDNDH__
13
14#ifdef __GNUG__
15#pragma interface
16#endif
17
18#include "wx/defs.h"
ac57418f 19
d345e841
RR
20//-------------------------------------------------------------------------
21// conditional compilation
22//-------------------------------------------------------------------------
23
24#if (GTK_MINOR_VERSION > 0)
25#define NEW_GTK_DND_CODE
26#endif
27
06cfab17 28#if wxUSE_DRAG_AND_DROP
ac57418f 29
c801d85f
KB
30#include "wx/object.h"
31#include "wx/string.h"
8b53e5a2 32#include "wx/dataobj.h"
c801d85f 33#include "wx/cursor.h"
e4677d31
RR
34#include "wx/icon.h"
35#include "wx/gdicmn.h"
c801d85f
KB
36
37//-------------------------------------------------------------------------
38// classes
39//-------------------------------------------------------------------------
40
41class wxWindow;
42
43class wxDropTarget;
44class wxTextDropTarget;
e3e65dac 45class wxFileDropTarget;
ab8884ac 46class wxPrivateDropTarget;
e3e65dac
RR
47
48class wxDropSource;
49
c801d85f
KB
50//-------------------------------------------------------------------------
51// wxDropTarget
52//-------------------------------------------------------------------------
53
46dc76ba 54class wxDropTarget: public wxObject
c801d85f
KB
55{
56 public:
57
58 wxDropTarget();
59 ~wxDropTarget();
e3e65dac 60
c801d85f
KB
61 virtual void OnEnter() { }
62 virtual void OnLeave() { }
5b077d48 63 virtual void OnMouseMove( long WXUNUSED(x), long WXUNUSED(y) ) { }
dc86cb34 64 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
c801d85f 65
e3e65dac
RR
66 // Override these to indicate what kind of data you support:
67
68 virtual size_t GetFormatCount() const = 0;
0d2a2b60 69 virtual wxDataFormat &GetFormat(size_t n) const;
e3e65dac 70
dc86cb34
RR
71 // implementation
72
e3e65dac 73 void RegisterWidget( GtkWidget *widget );
c801d85f 74 void UnregisterWidget( GtkWidget *widget );
0d2a2b60
RR
75
76 wxDataFormat *m_format;
c801d85f
KB
77};
78
79//-------------------------------------------------------------------------
80// wxTextDropTarget
81//-------------------------------------------------------------------------
82
83class wxTextDropTarget: public wxDropTarget
84{
85 public:
86
0d2a2b60 87 wxTextDropTarget();
dc86cb34 88 virtual bool OnDrop( long x, long y, const void *data, size_t size );
c801d85f 89 virtual bool OnDropText( long x, long y, const char *psz );
e3e65dac
RR
90
91 protected:
92
93 virtual size_t GetFormatCount() const;
c801d85f
KB
94};
95
ab8884ac
RR
96//-------------------------------------------------------------------------
97// wxPrivateDropTarget
98//-------------------------------------------------------------------------
99
100class wxPrivateDropTarget: public wxDropTarget
101{
102public:
103
104 wxPrivateDropTarget();
105
106 // you have to override OnDrop to get at the data
107
108 // the string ID identifies the format of clipboard or DnD data. a word
109 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
0d2a2b60
RR
110 // to the clipboard - the latter with the Id "application/wxword" or
111 // "image/png".
ab8884ac 112
0d2a2b60 113 void SetId( const wxString& id );
ab8884ac
RR
114
115 wxString GetId()
116 { return m_id; }
117
118private:
119
120 virtual size_t GetFormatCount() const;
ab8884ac
RR
121
122 wxString m_id;
123};
124
0d2a2b60 125//----------------------------------------------------------------------------
e3e65dac 126// A drop target which accepts files (dragged from File Manager or Explorer)
0d2a2b60 127//----------------------------------------------------------------------------
c801d85f 128
e3e65dac 129class wxFileDropTarget: public wxDropTarget
c801d85f
KB
130{
131 public:
e3e65dac 132
0d2a2b60 133 wxFileDropTarget();
e3e65dac 134
dc86cb34 135 virtual bool OnDrop( long x, long y, const void *data, size_t size );
e3e65dac 136 virtual bool OnDropFiles( long x, long y,
dc86cb34 137 size_t nFiles, const char * const aszFiles[] );
c801d85f 138
e3e65dac 139 protected:
c801d85f 140
e3e65dac 141 virtual size_t GetFormatCount() const;
c801d85f
KB
142};
143
144//-------------------------------------------------------------------------
e3e65dac 145// wxDropSource
c801d85f
KB
146//-------------------------------------------------------------------------
147
dc86cb34
RR
148enum wxDragResult
149{
150 wxDragError, // error prevented the d&d operation from completing
151 wxDragNone, // drag target didn't accept the data
152 wxDragCopy, // the data was successfully copied
0d2a2b60 153 wxDragMove, // the data was successfully moved (MSW only)
dc86cb34
RR
154 wxDragCancel // the operation was cancelled by user (not an error)
155};
46ccb510 156
e3e65dac 157class wxDropSource: public wxObject
c801d85f
KB
158{
159 public:
160
0d2a2b60 161 /* constructor. set data later with SetData() */
e4677d31 162 wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
0d2a2b60
RR
163
164 /* constructor for setting one data object */
e4677d31 165 wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
0d2a2b60
RR
166
167 /* constructor for setting several data objects via wxDataBroker */
168 wxDropSource( wxDataBroker *data, wxWindow *win );
e3e65dac
RR
169
170 ~wxDropSource(void);
c801d85f 171
0d2a2b60
RR
172 /* set one dataobject */
173 void SetData( wxDataBroker *data );
174
175 /* set severa dataobjects via wxDataBroker */
176 void SetData( wxDataObject *data );
177
178 /* start drag action */
46ccb510 179 wxDragResult DoDragDrop( bool bAllowMove = FALSE );
e3e65dac 180
0d2a2b60
RR
181 /* override to give feedback */
182 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
b6af8d80 183
0d2a2b60 184 /* GTK implementation */
dc86cb34 185
e3e65dac
RR
186 void RegisterWindow(void);
187 void UnregisterWindow(void);
188
189 GtkWidget *m_widget;
190 wxWindow *m_window;
46ccb510 191 wxDragResult m_retValue;
0d2a2b60 192 wxDataBroker *m_data;
e3e65dac
RR
193
194 wxCursor m_defaultCursor;
195 wxCursor m_goaheadCursor;
e4677d31
RR
196
197 wxIcon m_goIcon;
198 wxIcon m_stopIcon;
c801d85f
KB
199};
200
ac57418f
RR
201#endif
202
203 // wxUSE_DRAG_AND_DROP
204
c801d85f
KB
205#endif
206 //__GTKDNDH__
207