]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
Compile improvemnts for strict compilers and the like
[wxWidgets.git] / include / wx / gtk / dnd.h
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
27 //-------------------------------------------------------------------------
28 // conditional compilation
29 //-------------------------------------------------------------------------
30
31 #if (GTK_MINOR_VERSION == 1)
32 #if (GTK_MICRO_VERSION >= 3)
33 #define NEW_GTK_DND_CODE
34 #endif
35 #endif
36
37 //-------------------------------------------------------------------------
38 // classes
39 //-------------------------------------------------------------------------
40
41 class wxWindow;
42
43 class wxDropTarget;
44 class wxTextDropTarget;
45 class wxFileDropTarget;
46
47 class wxDropSource;
48
49 //-------------------------------------------------------------------------
50 // wxDropTarget
51 //-------------------------------------------------------------------------
52
53 class wxDropTarget: public wxObject
54 {
55 public:
56
57 wxDropTarget();
58 ~wxDropTarget();
59
60 virtual void OnEnter() { }
61 virtual void OnLeave() { }
62 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
63
64 // Override these to indicate what kind of data you support:
65
66 virtual size_t GetFormatCount() const = 0;
67 virtual wxDataFormat GetFormat(size_t n) const = 0;
68
69 // implementation
70
71 void RegisterWidget( GtkWidget *widget );
72 void UnregisterWidget( GtkWidget *widget );
73 };
74
75 //-------------------------------------------------------------------------
76 // wxTextDropTarget
77 //-------------------------------------------------------------------------
78
79 class wxTextDropTarget: public wxDropTarget
80 {
81 public:
82
83 wxTextDropTarget() {};
84 virtual bool OnDrop( long x, long y, const void *data, size_t size );
85 virtual bool OnDropText( long x, long y, const char *psz );
86
87 protected:
88
89 virtual size_t GetFormatCount() const;
90 virtual wxDataFormat GetFormat(size_t n) const;
91 };
92
93 // ----------------------------------------------------------------------------
94 // A drop target which accepts files (dragged from File Manager or Explorer)
95 // ----------------------------------------------------------------------------
96
97 class wxFileDropTarget: public wxDropTarget
98 {
99 public:
100
101 wxFileDropTarget() {};
102
103 virtual bool OnDrop( long x, long y, const void *data, size_t size );
104 virtual bool OnDropFiles( long x, long y,
105 size_t nFiles, const char * const aszFiles[] );
106
107 protected:
108
109 virtual size_t GetFormatCount() const;
110 virtual wxDataFormat GetFormat(size_t n) const;
111 };
112
113 //-------------------------------------------------------------------------
114 // wxDropSource
115 //-------------------------------------------------------------------------
116
117 enum wxDragResult
118 {
119 wxDragError, // error prevented the d&d operation from completing
120 wxDragNone, // drag target didn't accept the data
121 wxDragCopy, // the data was successfully copied
122 wxDragMove, // the data was successfully moved
123 wxDragCancel // the operation was cancelled by user (not an error)
124 };
125
126 class wxDropSource: public wxObject
127 {
128 public:
129
130 wxDropSource( wxWindow *win );
131 wxDropSource( wxDataObject &data, wxWindow *win );
132
133 ~wxDropSource(void);
134
135 void SetData( wxDataObject &data );
136 wxDragResult DoDragDrop( bool bAllowMove = FALSE );
137
138 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
139
140 // implementation
141
142 void RegisterWindow(void);
143 void UnregisterWindow(void);
144
145 GtkWidget *m_widget;
146 wxWindow *m_window;
147 wxDragResult m_retValue;
148 wxDataObject *m_data;
149
150 wxCursor m_defaultCursor;
151 wxCursor m_goaheadCursor;
152 };
153
154 #endif
155
156 // wxUSE_DRAG_AND_DROP
157
158 #endif
159 //__GTKDNDH__
160