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