]>
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 ///////////////////////////////////////////////////////////////////////////////
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 wxDragResult
OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
);
49 virtual bool OnDrop(wxCoord x
, wxCoord y
);
50 virtual bool OnData(wxCoord x
, wxCoord y
);
51 virtual bool GetData();
55 GdkAtom
GetMatchingPair();
56 void RegisterWidget( GtkWidget
*widget
);
57 void UnregisterWidget( GtkWidget
*widget
);
59 GdkDragContext
*m_dragContext
;
60 GtkWidget
*m_dragWidget
;
61 GtkSelectionData
*m_dragData
;
63 bool m_firstMotion
; /* gdk has no "gdk_drag_enter" event */
65 void SetDragContext( GdkDragContext
*dc
) { m_dragContext
= dc
; }
66 void SetDragWidget( GtkWidget
*w
) { m_dragWidget
= w
; }
67 void SetDragData( GtkSelectionData
*sd
) { m_dragData
= sd
; }
68 void SetDragTime( guint time
) { m_dragTime
= time
; }
71 // ----------------------------------------------------------------------------
72 // A simple wxDropTarget derived class for text data: you only need to
73 // override OnDropText() to get something working
74 // ----------------------------------------------------------------------------
76 class wxTextDropTarget
: public wxDropTarget
81 virtual bool OnDropText(wxCoord x
, wxCoord y
, const wxString
& text
) = 0;
83 virtual bool OnData(wxCoord x
, wxCoord y
);
86 // ----------------------------------------------------------------------------
87 // A drop target which accepts files (dragged from File Manager or Explorer)
88 // ----------------------------------------------------------------------------
90 class wxFileDropTarget
: public wxDropTarget
95 // parameters are the number of files and the array of file names
96 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
97 const wxArrayString
& filenames
) = 0;
99 virtual bool OnData(wxCoord x
, wxCoord y
);
102 //-------------------------------------------------------------------------
104 //-------------------------------------------------------------------------
106 class wxDropSource
: public wxDropSourceBase
109 /* constructor. set data later with SetData() */
110 wxDropSource( wxWindow
*win
,
111 const wxIcon
&go
= wxNullIcon
,
112 const wxIcon
&stop
= wxNullIcon
);
114 /* constructor for setting one data object */
115 wxDropSource( wxDataObject
& data
,
117 const wxIcon
&go
= wxNullIcon
,
118 const wxIcon
&stop
= wxNullIcon
);
122 /* start drag action */
123 virtual wxDragResult
DoDragDrop( bool bAllowMove
= FALSE
);
125 /* GTK implementation */
126 void RegisterWindow();
127 void UnregisterWindow();
131 wxDragResult m_retValue
;
133 wxCursor m_defaultCursor
;
134 wxCursor m_goaheadCursor
;
144 // wxUSE_DRAG_AND_DROP