]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7 // Licence: wxWindows license
8 ///////////////////////////////////////////////////////////////////////////////
20 #if wxUSE_DRAG_AND_DROP
22 #include "wx/object.h"
23 #include "wx/string.h"
24 #include "wx/dataobj.h"
25 #include "wx/cursor.h"
27 #include "wx/gdicmn.h"
29 //-------------------------------------------------------------------------
30 // conditional compilation
31 //-------------------------------------------------------------------------
33 #if (GTK_MINOR_VERSION == 1)
34 #if (GTK_MICRO_VERSION >= 3)
35 #define NEW_GTK_DND_CODE
39 //-------------------------------------------------------------------------
41 //-------------------------------------------------------------------------
46 class wxTextDropTarget
;
47 class wxFileDropTarget
;
48 class wxPrivateDropTarget
;
52 //-------------------------------------------------------------------------
54 //-------------------------------------------------------------------------
56 class wxDropTarget
: public wxObject
63 virtual void OnEnter() { }
64 virtual void OnLeave() { }
65 virtual void OnMouseMove( long WXUNUSED(x
), long WXUNUSED(y
) ) { }
66 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
) = 0;
68 // Override these to indicate what kind of data you support:
70 virtual size_t GetFormatCount() const = 0;
71 virtual wxDataFormat
&GetFormat(size_t n
) const;
75 void RegisterWidget( GtkWidget
*widget
);
76 void UnregisterWidget( GtkWidget
*widget
);
78 wxDataFormat
*m_format
;
81 //-------------------------------------------------------------------------
83 //-------------------------------------------------------------------------
85 class wxTextDropTarget
: public wxDropTarget
90 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
91 virtual bool OnDropText( long x
, long y
, const char *psz
);
95 virtual size_t GetFormatCount() const;
98 //-------------------------------------------------------------------------
99 // wxPrivateDropTarget
100 //-------------------------------------------------------------------------
102 class wxPrivateDropTarget
: public wxDropTarget
106 wxPrivateDropTarget();
108 // you have to override OnDrop to get at the data
110 // the string ID identifies the format of clipboard or DnD data. a word
111 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
112 // to the clipboard - the latter with the Id "application/wxword" or
115 void SetId( const wxString
& id
);
122 virtual size_t GetFormatCount() const;
127 //----------------------------------------------------------------------------
128 // A drop target which accepts files (dragged from File Manager or Explorer)
129 //----------------------------------------------------------------------------
131 class wxFileDropTarget
: public wxDropTarget
137 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
138 virtual bool OnDropFiles( long x
, long y
,
139 size_t nFiles
, const char * const aszFiles
[] );
143 virtual size_t GetFormatCount() const;
146 //-------------------------------------------------------------------------
148 //-------------------------------------------------------------------------
152 wxDragError
, // error prevented the d&d operation from completing
153 wxDragNone
, // drag target didn't accept the data
154 wxDragCopy
, // the data was successfully copied
155 wxDragMove
, // the data was successfully moved (MSW only)
156 wxDragCancel
// the operation was cancelled by user (not an error)
159 class wxDropSource
: public wxObject
163 /* constructor. set data later with SetData() */
164 wxDropSource( wxWindow
*win
, const wxIcon
&go
= wxNullIcon
, const wxIcon
&stop
= wxNullIcon
);
166 /* constructor for setting one data object */
167 wxDropSource( wxDataObject
*data
, wxWindow
*win
, const wxIcon
&go
= wxNullIcon
, const wxIcon
&stop
= wxNullIcon
);
169 /* constructor for setting several data objects via wxDataBroker */
170 wxDropSource( wxDataBroker
*data
, wxWindow
*win
);
174 /* set one dataobject */
175 void SetData( wxDataBroker
*data
);
177 /* set severa dataobjects via wxDataBroker */
178 void SetData( wxDataObject
*data
);
180 /* start drag action */
181 wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
183 /* override to give feedback */
184 virtual bool GiveFeedback( wxDragResult
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; }
186 /* GTK implementation */
188 void RegisterWindow(void);
189 void UnregisterWindow(void);
193 wxDragResult m_retValue
;
194 wxDataBroker
*m_data
;
196 wxCursor m_defaultCursor
;
197 wxCursor m_goaheadCursor
;
205 // wxUSE_DRAG_AND_DROP