]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/dnd.h
disable use of #pragma interface under Mac OS X
[wxWidgets.git] / include / wx / x11 / dnd.h
CommitLineData
83df96d6
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: dnd.h
3// Purpose: declaration of wxDropTarget, wxDropSource classes
4// Author: Julian Smart
5// RCS-ID: $Id$
6// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10
11#ifndef _WX_DND_H_
12#define _WX_DND_H_
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// classes
29//-------------------------------------------------------------------------
30
31class WXDLLEXPORT wxWindow;
32
33class WXDLLEXPORT wxDropTarget;
34class WXDLLEXPORT wxTextDropTarget;
35class WXDLLEXPORT wxFileDropTarget;
36class WXDLLEXPORT wxPrivateDropTarget;
37
38class WXDLLEXPORT wxDropSource;
39
40//-------------------------------------------------------------------------
41// wxDropTarget
42//-------------------------------------------------------------------------
43
44class WXDLLEXPORT wxDropTarget: public wxObject
45{
46public:
47
48 wxDropTarget();
49 ~wxDropTarget();
50
51 virtual void OnEnter() { }
52 virtual void OnLeave() { }
53 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
54
55 // Override these to indicate what kind of data you support:
56
57 virtual size_t GetFormatCount() const = 0;
58 virtual wxDataFormat GetFormat(size_t n) const = 0;
59
60 // implementation
61};
62
63//-------------------------------------------------------------------------
64// wxTextDropTarget
65//-------------------------------------------------------------------------
66
67class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
68{
69public:
70
71 wxTextDropTarget() {};
72 virtual bool OnDrop( long x, long y, const void *data, size_t size );
73 virtual bool OnDropText( long x, long y, const char *psz );
74
75protected:
76
77 virtual size_t GetFormatCount() const;
78 virtual wxDataFormat GetFormat(size_t n) const;
79};
80
81//-------------------------------------------------------------------------
82// wxPrivateDropTarget
83//-------------------------------------------------------------------------
84
85class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget
86{
87public:
88
89 wxPrivateDropTarget();
90
91 // you have to override OnDrop to get at the data
92
93 // the string ID identifies the format of clipboard or DnD data. a word
94 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
95 // to the clipboard - the latter with the Id "WXWORD_FORMAT".
96
97 void SetId( const wxString& id )
98 { m_id = id; }
99
100 wxString GetId()
101 { return m_id; }
102
103private:
104
105 virtual size_t GetFormatCount() const;
106 virtual wxDataFormat GetFormat(size_t n) const;
107
108 wxString m_id;
109};
110
111// ----------------------------------------------------------------------------
112// A drop target which accepts files (dragged from File Manager or Explorer)
113// ----------------------------------------------------------------------------
114
115class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
116{
117public:
118
119 wxFileDropTarget() {};
120
121 virtual bool OnDrop( long x, long y, const void *data, size_t size );
122 virtual bool OnDropFiles( long x, long y,
123 size_t nFiles, const char * const aszFiles[] );
124
125protected:
126
127 virtual size_t GetFormatCount() const;
128 virtual wxDataFormat GetFormat(size_t n) const;
129};
130
131//-------------------------------------------------------------------------
132// wxDropSource
133//-------------------------------------------------------------------------
134
135enum wxDragResult
136{
137 wxDragError, // error prevented the d&d operation from completing
138 wxDragNone, // drag target didn't accept the data
139 wxDragCopy, // the data was successfully copied
140 wxDragMove, // the data was successfully moved
141 wxDragCancel // the operation was cancelled by user (not an error)
142};
143
144class WXDLLEXPORT wxDropSource: public wxObject
145{
146public:
147
148 wxDropSource( wxWindow *win );
149 wxDropSource( wxDataObject &data, wxWindow *win );
150
151 ~wxDropSource(void);
152
153 void SetData( wxDataObject &data );
2245b2b2 154 wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
83df96d6
JS
155
156 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
157
158 // implementation
159#if 0
160 void RegisterWindow(void);
161 void UnregisterWindow(void);
162
163 wxWindow *m_window;
164 wxDragResult m_retValue;
165 wxDataObject *m_data;
166
167 wxCursor m_defaultCursor;
168 wxCursor m_goaheadCursor;
169#endif
170};
171
172#endif
173
174// wxUSE_DRAG_AND_DROP
175
176#endif
177//_WX_DND_H_
178