]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/dnd.h
AddFile(wxImage&) -> AddFile(const wxImage&)
[wxWidgets.git] / include / wx / motif / dnd.h
CommitLineData
9b6dbb09
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: dnd.h
2d120f83 3// Purpose: declaration of wxDropTarget, wxDropSource classes
9b6dbb09
JS
4// Author: Julian Smart
5// RCS-ID: $Id$
2d120f83 6// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
65571936 7// Licence: wxWindows licence
9b6dbb09
JS
8///////////////////////////////////////////////////////////////////////////////
9
2d120f83 10
9b6dbb09
JS
11#ifndef _WX_DND_H_
12#define _WX_DND_H_
13
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
2d120f83 15#pragma interface
9b6dbb09
JS
16#endif
17
18#include "wx/defs.h"
2d120f83
JS
19
20#if wxUSE_DRAG_AND_DROP
21
9b6dbb09
JS
22#include "wx/object.h"
23#include "wx/string.h"
2d120f83 24#include "wx/dataobj.h"
9b6dbb09
JS
25#include "wx/cursor.h"
26
27//-------------------------------------------------------------------------
28// classes
29//-------------------------------------------------------------------------
30
31class WXDLLEXPORT wxWindow;
32
9b6dbb09
JS
33class WXDLLEXPORT wxDropTarget;
34class WXDLLEXPORT wxTextDropTarget;
35class WXDLLEXPORT wxFileDropTarget;
2d120f83 36class WXDLLEXPORT wxPrivateDropTarget;
9b6dbb09
JS
37
38class WXDLLEXPORT wxDropSource;
39
9b6dbb09
JS
40//-------------------------------------------------------------------------
41// wxDropTarget
42//-------------------------------------------------------------------------
43
44class WXDLLEXPORT wxDropTarget: public wxObject
45{
83df96d6
JS
46public:
47
9b6dbb09
JS
48 wxDropTarget();
49 ~wxDropTarget();
50
51 virtual void OnEnter() { }
52 virtual void OnLeave() { }
2d120f83 53 virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
83df96d6 54
9b6dbb09 55 // Override these to indicate what kind of data you support:
83df96d6 56
9b6dbb09
JS
57 virtual size_t GetFormatCount() const = 0;
58 virtual wxDataFormat GetFormat(size_t n) const = 0;
83df96d6
JS
59
60 // implementation
9b6dbb09
JS
61};
62
63//-------------------------------------------------------------------------
64// wxTextDropTarget
65//-------------------------------------------------------------------------
66
67class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
68{
83df96d6
JS
69public:
70
9b6dbb09 71 wxTextDropTarget() {};
2d120f83 72 virtual bool OnDrop( long x, long y, const void *data, size_t size );
9b6dbb09
JS
73 virtual bool OnDropText( long x, long y, const char *psz );
74
83df96d6
JS
75protected:
76
9b6dbb09
JS
77 virtual size_t GetFormatCount() const;
78 virtual wxDataFormat GetFormat(size_t n) const;
79};
80
2d120f83
JS
81//-------------------------------------------------------------------------
82// wxPrivateDropTarget
83//-------------------------------------------------------------------------
84
85class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget
86{
87public:
2d120f83 88
83df96d6 89 wxPrivateDropTarget();
2d120f83 90
83df96d6
JS
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; }
2d120f83 102
2d120f83 103private:
2d120f83 104
83df96d6
JS
105 virtual size_t GetFormatCount() const;
106 virtual wxDataFormat GetFormat(size_t n) const;
107
108 wxString m_id;
2d120f83
JS
109};
110
9b6dbb09
JS
111// ----------------------------------------------------------------------------
112// A drop target which accepts files (dragged from File Manager or Explorer)
113// ----------------------------------------------------------------------------
114
115class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
116{
83df96d6 117public:
9b6dbb09
JS
118
119 wxFileDropTarget() {};
120
2d120f83 121 virtual bool OnDrop( long x, long y, const void *data, size_t size );
9b6dbb09 122 virtual bool OnDropFiles( long x, long y,
83df96d6
JS
123 size_t nFiles, const char * const aszFiles[] );
124
125protected:
126
9b6dbb09
JS
127 virtual size_t GetFormatCount() const;
128 virtual wxDataFormat GetFormat(size_t n) const;
129};
130
131//-------------------------------------------------------------------------
132// wxDropSource
133//-------------------------------------------------------------------------
134
2d120f83
JS
135enum wxDragResult
136{
83df96d6
JS
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)
2d120f83 142};
9b6dbb09
JS
143
144class WXDLLEXPORT wxDropSource: public wxObject
145{
83df96d6
JS
146public:
147
9b6dbb09
JS
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);
9b6dbb09
JS
155
156 virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
83df96d6
JS
157
158 // implementation
2d120f83
JS
159#if 0
160 void RegisterWindow(void);
161 void UnregisterWindow(void);
83df96d6 162
2d120f83
JS
163 wxWindow *m_window;
164 wxDragResult m_retValue;
9b6dbb09 165 wxDataObject *m_data;
2d120f83
JS
166
167 wxCursor m_defaultCursor;
168 wxCursor m_goaheadCursor;
169#endif
9b6dbb09
JS
170};
171
2d120f83
JS
172#endif
173
83df96d6 174// wxUSE_DRAG_AND_DROP
2d120f83 175
9b6dbb09 176#endif
83df96d6 177//_WX_DND_H_
9b6dbb09 178