]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/dnd.h
char handling fixed again
[wxWidgets.git] / include / wx / gtk / dnd.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: dnd.h
3// Purpose: declaration of the wxDropTarget class
4// Author: Robert Roebling
5// RCS-ID: $Id$
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"
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#include "wx/icon.h"
27#include "wx/gdicmn.h"
28
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
39//-------------------------------------------------------------------------
40// classes
41//-------------------------------------------------------------------------
42
43class wxWindow;
44
45class wxDropTarget;
46class wxTextDropTarget;
47class wxFileDropTarget;
48class wxPrivateDropTarget;
49
50class wxDropSource;
51
52//-------------------------------------------------------------------------
53// wxDropTarget
54//-------------------------------------------------------------------------
55
56class wxDropTarget: public wxObject
57{
58 public:
59
60 wxDropTarget();
61 ~wxDropTarget();
62
63 virtual void OnEnter() { }
64 virtual void OnLeave() { }
65 virtual void OnMouseMove( long WXUNUSED(x), long WXUNUSED(y) ) { }
66 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
67
68 // Override these to indicate what kind of data you support:
69
70 virtual size_t GetFormatCount() const = 0;
71 virtual wxDataFormat &GetFormat(size_t n) const;
72
73 // implementation
74
75 void RegisterWidget( GtkWidget *widget );
76 void UnregisterWidget( GtkWidget *widget );
77
78 wxDataFormat *m_format;
79};
80
81//-------------------------------------------------------------------------
82// wxTextDropTarget
83//-------------------------------------------------------------------------
84
85class wxTextDropTarget: public wxDropTarget
86{
87 public:
88
89 wxTextDropTarget();
90 virtual bool OnDrop( long x, long y, const void *data, size_t size );
91 virtual bool OnDropText( long x, long y, const char *psz );
92
93 protected:
94
95 virtual size_t GetFormatCount() const;
96};
97
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
112 // to the clipboard - the latter with the Id "application/wxword" or
113 // "image/png".
114
115 void SetId( const wxString& id );
116
117 wxString GetId()
118 { return m_id; }
119
120private:
121
122 virtual size_t GetFormatCount() const;
123
124 wxString m_id;
125};
126
127//----------------------------------------------------------------------------
128// A drop target which accepts files (dragged from File Manager or Explorer)
129//----------------------------------------------------------------------------
130
131class wxFileDropTarget: public wxDropTarget
132{
133 public:
134
135 wxFileDropTarget();
136
137 virtual bool OnDrop( long x, long y, const void *data, size_t size );
138 virtual bool OnDropFiles( long x, long y,
139 size_t nFiles, const char * const aszFiles[] );
140
141 protected:
142
143 virtual size_t GetFormatCount() const;
144};
145
146//-------------------------------------------------------------------------
147// wxDropSource
148//-------------------------------------------------------------------------
149
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
155 wxDragMove, // the data was successfully moved (MSW only)
156 wxDragCancel // the operation was cancelled by user (not an error)
157};
158
159class wxDropSource: public wxObject
160{
161 public:
162
163 /* constructor. set data later with SetData() */
164 wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
165
166 /* constructor for setting one data object */
167 wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
168
169 /* constructor for setting several data objects via wxDataBroker */
170 wxDropSource( wxDataBroker *data, wxWindow *win );
171
172 ~wxDropSource(void);
173
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 */
181 wxDragResult DoDragDrop( bool bAllowMove = FALSE );
182
183 /* override to give feedback */
184 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
185
186 /* GTK implementation */
187
188 void RegisterWindow(void);
189 void UnregisterWindow(void);
190
191 GtkWidget *m_widget;
192 wxWindow *m_window;
193 wxDragResult m_retValue;
194 wxDataBroker *m_data;
195
196 wxCursor m_defaultCursor;
197 wxCursor m_goaheadCursor;
198
199 wxIcon m_goIcon;
200 wxIcon m_stopIcon;
201};
202
203#endif
204
205 // wxUSE_DRAG_AND_DROP
206
207#endif
208 //__GTKDNDH__
209