]>
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 //-------------------------------------------------------------------------
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 = 0;
72 void RegisterWidget( GtkWidget
*widget
);
73 void UnregisterWidget( GtkWidget
*widget
);
76 //-------------------------------------------------------------------------
78 //-------------------------------------------------------------------------
80 class wxTextDropTarget
: public wxDropTarget
84 wxTextDropTarget() {};
85 virtual bool OnDrop( long x
, long y
, const void *data
, size_t size
);
86 virtual bool OnDropText( long x
, long y
, const char *psz
);
90 virtual size_t GetFormatCount() const;
91 virtual wxDataFormat
GetFormat(size_t n
) const;
94 //-------------------------------------------------------------------------
95 // wxPrivateDropTarget
96 //-------------------------------------------------------------------------
98 class wxPrivateDropTarget
: public wxDropTarget
102 wxPrivateDropTarget();
104 // you have to override OnDrop to get at the data
106 // the string ID identifies the format of clipboard or DnD data. a word
107 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
108 // to the clipboard - the latter with the Id "WXWORD_FORMAT".
110 void SetId( const wxString
& id
)
118 virtual size_t GetFormatCount() const;
119 virtual wxDataFormat
GetFormat(size_t n
) const;
124 // ----------------------------------------------------------------------------
125 // A drop target which accepts files (dragged from File Manager or Explorer)
126 // ----------------------------------------------------------------------------
128 class wxFileDropTarget
: public wxDropTarget
132 wxFileDropTarget() {};
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;
141 virtual wxDataFormat
GetFormat(size_t n
) 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
154 wxDragCancel
// the operation was cancelled by user (not an error)
157 class wxDropSource
: public wxObject
161 wxDropSource( wxWindow
*win
);
162 wxDropSource( wxDataObject
&data
, wxWindow
*win
);
166 void SetData( wxDataObject
&data
);
167 wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
169 virtual bool GiveFeedback( wxDragResult
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; };
173 void RegisterWindow(void);
174 void UnregisterWindow(void);
178 wxDragResult m_retValue
;
179 wxDataObject
*m_data
;
181 wxCursor m_defaultCursor
;
182 wxCursor m_goaheadCursor
;
187 // wxUSE_DRAG_AND_DROP