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