]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/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 //-------------------------------------------------------------------------
28 // conditional compilation
29 //-------------------------------------------------------------------------
31 #if (GTK_MINOR_VERSION == 1)
32 #if (GTK_MICRO_VERSION >= 3)
33 #define NEW_GTK_DND_CODE
37 //-------------------------------------------------------------------------
39 //-------------------------------------------------------------------------
44 class wxTextDropTarget
;
45 class wxFileDropTarget
;
46 class wxPrivateDropTarget
;
50 //-------------------------------------------------------------------------
52 //-------------------------------------------------------------------------
54 class wxDropTarget
: public wxObject
61 virtual void OnEnter() { }
62 virtual void OnLeave() { }
63 virtual void OnMouseMove( long WXUNUSED(x
), long WXUNUSED(y
) ) { }
64 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
) = 0;
66 // Override these to indicate what kind of data you support:
68 virtual size_t GetFormatCount() const = 0;
69 virtual wxDataFormat
&GetFormat(size_t n
) const;
73 void RegisterWidget( GtkWidget
*widget
);
74 void UnregisterWidget( GtkWidget
*widget
);
76 wxDataFormat
*m_format
;
79 //-------------------------------------------------------------------------
81 //-------------------------------------------------------------------------
83 class wxTextDropTarget
: public wxDropTarget
88 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
89 virtual bool OnDropText( long x
, long y
, const char *psz
);
93 virtual size_t GetFormatCount() const;
96 //-------------------------------------------------------------------------
97 // wxPrivateDropTarget
98 //-------------------------------------------------------------------------
100 class wxPrivateDropTarget
: public wxDropTarget
104 wxPrivateDropTarget();
106 // you have to override OnDrop to get at the data
108 // the string ID identifies the format of clipboard or DnD data. a word
109 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
110 // to the clipboard - the latter with the Id "application/wxword" or
113 void SetId( const wxString
& id
);
120 virtual size_t GetFormatCount() const;
125 //----------------------------------------------------------------------------
126 // A drop target which accepts files (dragged from File Manager or Explorer)
127 //----------------------------------------------------------------------------
129 class wxFileDropTarget
: public wxDropTarget
135 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
136 virtual bool OnDropFiles( long x
, long y
,
137 size_t nFiles
, const char * const aszFiles
[] );
141 virtual size_t GetFormatCount() const;
144 //-------------------------------------------------------------------------
146 //-------------------------------------------------------------------------
150 wxDragError
, // error prevented the d&d operation from completing
151 wxDragNone
, // drag target didn't accept the data
152 wxDragCopy
, // the data was successfully copied
153 wxDragMove
, // the data was successfully moved (MSW only)
154 wxDragCancel
// the operation was cancelled by user (not an error)
157 class wxDropSource
: public wxObject
161 /* constructor. set data later with SetData() */
162 wxDropSource( wxWindow
*win
);
164 /* constructor for setting one data object */
165 wxDropSource( wxDataObject
*data
, wxWindow
*win
);
167 /* constructor for setting several data objects via wxDataBroker */
168 wxDropSource( wxDataBroker
*data
, wxWindow
*win
);
172 /* set one dataobject */
173 void SetData( wxDataBroker
*data
);
175 /* set severa dataobjects via wxDataBroker */
176 void SetData( wxDataObject
*data
);
178 /* start drag action */
179 wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
181 /* override to give feedback */
182 virtual bool GiveFeedback( wxDragResult
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; }
184 /* GTK implementation */
186 void RegisterWindow(void);
187 void UnregisterWindow(void);
191 wxDragResult m_retValue
;
192 wxDataBroker
*m_data
;
194 wxCursor m_defaultCursor
;
195 wxCursor m_goaheadCursor
;
200 // wxUSE_DRAG_AND_DROP