]>
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 bool OnDrop( long x
, long y
, const void *data
, size_t size
) = 0;
65 // Override these to indicate what kind of data you support:
67 virtual size_t GetFormatCount() const = 0;
68 virtual wxDataFormat
&GetFormat(size_t n
) const;
72 void RegisterWidget( GtkWidget
*widget
);
73 void UnregisterWidget( GtkWidget
*widget
);
75 wxDataFormat
*m_format
;
78 //-------------------------------------------------------------------------
80 //-------------------------------------------------------------------------
82 class wxTextDropTarget
: public wxDropTarget
87 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
88 virtual bool OnDropText( long x
, long y
, const char *psz
);
92 virtual size_t GetFormatCount() const;
95 //-------------------------------------------------------------------------
96 // wxPrivateDropTarget
97 //-------------------------------------------------------------------------
99 class wxPrivateDropTarget
: public wxDropTarget
103 wxPrivateDropTarget();
105 // you have to override OnDrop to get at the data
107 // the string ID identifies the format of clipboard or DnD data. a word
108 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
109 // to the clipboard - the latter with the Id "application/wxword" or
112 void SetId( const wxString
& id
);
119 virtual size_t GetFormatCount() const;
124 //----------------------------------------------------------------------------
125 // A drop target which accepts files (dragged from File Manager or Explorer)
126 //----------------------------------------------------------------------------
128 class wxFileDropTarget
: public wxDropTarget
134 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
135 virtual bool OnDropFiles( long x
, long y
,
136 size_t nFiles
, const char * const aszFiles
[] );
140 virtual size_t GetFormatCount() const;
143 //-------------------------------------------------------------------------
145 //-------------------------------------------------------------------------
149 wxDragError
, // error prevented the d&d operation from completing
150 wxDragNone
, // drag target didn't accept the data
151 wxDragCopy
, // the data was successfully copied
152 wxDragMove
, // the data was successfully moved (MSW only)
153 wxDragCancel
// the operation was cancelled by user (not an error)
156 class wxDropSource
: public wxObject
160 /* constructor. set data later with SetData() */
161 wxDropSource( wxWindow
*win
);
163 /* constructor for setting one data object */
164 wxDropSource( wxDataObject
*data
, wxWindow
*win
);
166 /* constructor for setting several data objects via wxDataBroker */
167 wxDropSource( wxDataBroker
*data
, wxWindow
*win
);
171 /* set one dataobject */
172 void SetData( wxDataBroker
*data
);
174 /* set severa dataobjects via wxDataBroker */
175 void SetData( wxDataObject
*data
);
177 /* start drag action */
178 wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
180 /* override to give feedback */
181 virtual bool GiveFeedback( wxDragResult
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; }
183 /* GTK implementation */
185 void RegisterWindow(void);
186 void UnregisterWindow(void);
190 wxDragResult m_retValue
;
191 wxDataBroker
*m_data
;
193 wxCursor m_defaultCursor
;
194 wxCursor m_goaheadCursor
;
199 // wxUSE_DRAG_AND_DROP