]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dnd.h
Better disabling of toolbars and menubars
[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
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
KB
25#include "wx/cursor.h"
26
fed46e72
RR
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
c801d85f
KB
37//-------------------------------------------------------------------------
38// classes
39//-------------------------------------------------------------------------
40
41class wxWindow;
42
43class wxDropTarget;
44class wxTextDropTarget;
e3e65dac
RR
45class wxFileDropTarget;
46
47class wxDropSource;
48
c801d85f
KB
49//-------------------------------------------------------------------------
50// wxDropTarget
51//-------------------------------------------------------------------------
52
46dc76ba 53class wxDropTarget: public wxObject
c801d85f
KB
54{
55 public:
56
57 wxDropTarget();
58 ~wxDropTarget();
e3e65dac 59
c801d85f
KB
60 virtual void OnEnter() { }
61 virtual void OnLeave() { }
dc86cb34 62 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
c801d85f 63
e3e65dac
RR
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
dc86cb34
RR
69 // implementation
70
e3e65dac 71 void RegisterWidget( GtkWidget *widget );
c801d85f
KB
72 void UnregisterWidget( GtkWidget *widget );
73};
74
75//-------------------------------------------------------------------------
76// wxTextDropTarget
77//-------------------------------------------------------------------------
78
79class wxTextDropTarget: public wxDropTarget
80{
81 public:
82
83 wxTextDropTarget() {};
dc86cb34 84 virtual bool OnDrop( long x, long y, const void *data, size_t size );
c801d85f 85 virtual bool OnDropText( long x, long y, const char *psz );
e3e65dac
RR
86
87 protected:
88
89 virtual size_t GetFormatCount() const;
90 virtual wxDataFormat GetFormat(size_t n) const;
c801d85f
KB
91};
92
e3e65dac
RR
93// ----------------------------------------------------------------------------
94// A drop target which accepts files (dragged from File Manager or Explorer)
95// ----------------------------------------------------------------------------
c801d85f 96
e3e65dac 97class wxFileDropTarget: public wxDropTarget
c801d85f
KB
98{
99 public:
e3e65dac
RR
100
101 wxFileDropTarget() {};
102
dc86cb34 103 virtual bool OnDrop( long x, long y, const void *data, size_t size );
e3e65dac 104 virtual bool OnDropFiles( long x, long y,
dc86cb34 105 size_t nFiles, const char * const aszFiles[] );
c801d85f 106
e3e65dac 107 protected:
c801d85f 108
e3e65dac
RR
109 virtual size_t GetFormatCount() const;
110 virtual wxDataFormat GetFormat(size_t n) const;
c801d85f
KB
111};
112
113//-------------------------------------------------------------------------
e3e65dac 114// wxDropSource
c801d85f
KB
115//-------------------------------------------------------------------------
116
dc86cb34
RR
117enum 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};
46ccb510 125
e3e65dac 126class wxDropSource: public wxObject
c801d85f
KB
127{
128 public:
129
e3e65dac
RR
130 wxDropSource( wxWindow *win );
131 wxDropSource( wxDataObject &data, wxWindow *win );
132
133 ~wxDropSource(void);
c801d85f 134
e3e65dac 135 void SetData( wxDataObject &data );
46ccb510 136 wxDragResult DoDragDrop( bool bAllowMove = FALSE );
e3e65dac 137
46ccb510 138 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
b6af8d80 139
dc86cb34
RR
140 // implementation
141
e3e65dac
RR
142 void RegisterWindow(void);
143 void UnregisterWindow(void);
144
145 GtkWidget *m_widget;
146 wxWindow *m_window;
46ccb510 147 wxDragResult m_retValue;
e3e65dac
RR
148 wxDataObject *m_data;
149
150 wxCursor m_defaultCursor;
151 wxCursor m_goaheadCursor;
c801d85f
KB
152};
153
ac57418f
RR
154#endif
155
156 // wxUSE_DRAG_AND_DROP
157
c801d85f
KB
158#endif
159 //__GTKDNDH__
160