]>
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 ///////////////////////////////////////////////////////////////////////////////
18 #if wxUSE_DRAG_AND_DROP
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/dataobj.h"
23 #include "wx/cursor.h"
25 #include "wx/gdicmn.h"
27 //-------------------------------------------------------------------------
29 //-------------------------------------------------------------------------
34 class wxTextDropTarget
;
35 class wxFileDropTarget
;
39 //-------------------------------------------------------------------------
41 //-------------------------------------------------------------------------
43 class wxDropTarget
: public wxDropTargetBase
46 wxDropTarget(wxDataObject
*dataObject
= (wxDataObject
*) NULL
);
48 virtual bool OnEnter(wxCoord x
, wxCoord y
) ;
49 virtual bool OnMove(wxCoord x
, wxCoord y
);
50 virtual bool OnDrop(wxCoord x
, wxCoord y
);
51 virtual bool OnData(wxCoord x
, wxCoord y
);
52 virtual bool GetData();
56 GdkAtom
GetMatchingPair();
57 void RegisterWidget( GtkWidget
*widget
);
58 void UnregisterWidget( GtkWidget
*widget
);
60 GdkDragContext
*m_dragContext
;
61 GtkWidget
*m_dragWidget
;
62 GtkSelectionData
*m_dragData
;
64 bool m_firstMotion
; /* gdk has no "gdk_drag_enter" event */
66 void SetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
67 void SetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
68 void SetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
69 void SetDragTime( guint time
) { m_dragTime
= time
; }
72 // ----------------------------------------------------------------------------
73 // A simple wxDropTarget derived class for text data: you only need to
74 // override OnDropText() to get something working
75 // ----------------------------------------------------------------------------
77 class wxTextDropTarget
: public wxDropTarget
82 virtual bool OnDropText(wxCoord x
, wxCoord y
, const wxString
& text
) = 0;
84 virtual bool OnData(wxCoord x
, wxCoord y
);
87 // ----------------------------------------------------------------------------
88 // A drop target which accepts files (dragged from File Manager or Explorer)
89 // ----------------------------------------------------------------------------
91 class wxFileDropTarget
: public wxDropTarget
96 // parameters are the number of files and the array of file names
97 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
98 const wxArrayString
& filenames
) = 0;
100 virtual bool OnData(wxCoord x
, wxCoord y
);
103 //-------------------------------------------------------------------------
105 //-------------------------------------------------------------------------
107 class wxDropSource
: public wxDropSourceBase
110 /* constructor. set data later with SetData() */
111 wxDropSource( wxWindow
*win
,
112 const wxIcon
&go
= wxNullIcon
,
113 const wxIcon
&stop
= wxNullIcon
);
115 /* constructor for setting one data object */
116 wxDropSource( wxDataObject
& data
,
118 const wxIcon
&go
= wxNullIcon
,
119 const wxIcon
&stop
= wxNullIcon
);
123 /* start drag action */
124 virtual wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
126 /* GTK implementation */
127 void RegisterWindow();
128 void UnregisterWindow();
132 wxDragResult m_retValue
;
134 wxCursor m_defaultCursor
;
135 wxCursor m_goaheadCursor
;
145 // wxUSE_DRAG_AND_DROP