]>
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 //-------------------------------------------------------------------------
31 //-------------------------------------------------------------------------
36 class wxTextDropTarget
;
37 class wxFileDropTarget
;
38 class wxPrivateDropTarget
;
42 //-------------------------------------------------------------------------
44 //-------------------------------------------------------------------------
46 class wxDropTarget
: public wxObject
49 wxDropTarget( wxDataObject
*data
);
52 /* may be overridden to react to events */
53 virtual bool OnEnter( int x
, int y
);
55 virtual void OnLeave();
57 /* may be overridden to reject certain formats or drops
58 on certain areas. always returns TRUE by default
59 indicating that you'd accept the data from the drag. */
60 virtual bool OnMove( int x
, int y
);
62 /* has to be overridden to accept a drop event. call
63 IsSupported() to ask which formats are available
64 and then call RequestData() to indicate the format
66 virtual bool OnDrop( int x
, int y
);
68 /* this gets called once the data has actually arrived.
69 it will call GetData() to fill up its wxDataObject */
70 virtual bool OnData( int x
, int y
);
72 /* fill data with data from the dragging source */
77 GdkAtom
GetMatchingPair();
79 void RegisterWidget( GtkWidget
*widget
);
80 void UnregisterWidget( GtkWidget
*widget
);
83 GdkDragContext
*m_dragContext
;
84 GtkWidget
*m_dragWidget
;
85 GtkSelectionData
*m_dragData
;
87 bool m_firstMotion
; /* gdk has no "gdk_drag_enter" event */
89 void SetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
90 void SetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
91 void SetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
92 void SetDragTime( guint time
) { m_dragTime
= time
; }
95 //-------------------------------------------------------------------------
97 //-------------------------------------------------------------------------
101 wxDragError
, // error prevented the d&d operation from completing
102 wxDragNone
, // drag target didn't accept the data
103 wxDragCopy
, // the data was successfully copied
104 wxDragMove
, // the data was successfully moved (MSW only)
105 wxDragCancel
// the operation was cancelled by user (not an error)
108 class wxDropSource
: public wxObject
112 /* constructor. set data later with SetData() */
113 wxDropSource( wxWindow
*win
, const wxIcon
&go
= wxNullIcon
, const wxIcon
&stop
= wxNullIcon
);
115 wxDropSource( wxDataObject
& data
, wxWindow
*win
, const wxIcon
&go
= wxNullIcon
, const wxIcon
&stop
= wxNullIcon
);
118 void SetData( wxDataObject
& data
);
120 /* start drag action */
121 wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
123 /* override to give feedback */
124 virtual bool GiveFeedback( wxDragResult
WXUNUSED(effect
), bool WXUNUSED(bScrolling
) ) { return TRUE
; }
126 /* GTK implementation */
128 void RegisterWindow();
129 void UnregisterWindow();
133 wxDragResult m_retValue
;
134 wxDataObject
*m_data
;
136 wxCursor m_defaultCursor
;
137 wxCursor m_goaheadCursor
;
147 // wxUSE_DRAG_AND_DROP