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