]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
379c0e94ef74b0dd78256e9d1aba01c4b762017f
[wxWidgets.git] / include / wx / gtk / dnd.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: dnd.h
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7 // Licence: wxWindows license
8 ///////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef __GTKDNDH__
12 #define __GTKDNDH__
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #if wxUSE_DRAG_AND_DROP
19
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/dataobj.h"
23 #include "wx/cursor.h"
24 #include "wx/icon.h"
25 #include "wx/gdicmn.h"
26
27 //-------------------------------------------------------------------------
28 // classes
29 //-------------------------------------------------------------------------
30
31 class wxWindow;
32
33 class wxDropTarget;
34 class wxTextDropTarget;
35 class wxFileDropTarget;
36
37 class wxDropSource;
38
39 //-------------------------------------------------------------------------
40 // wxDropTarget
41 //-------------------------------------------------------------------------
42
43 class wxDropTarget: public wxDropTargetBase
44 {
45 public:
46 wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
47
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();
52
53 // implementation
54
55 GdkAtom GetMatchingPair();
56 void RegisterWidget( GtkWidget *widget );
57 void UnregisterWidget( GtkWidget *widget );
58
59 GdkDragContext *m_dragContext;
60 GtkWidget *m_dragWidget;
61 GtkSelectionData *m_dragData;
62 guint m_dragTime;
63 bool m_firstMotion; /* gdk has no "gdk_drag_enter" event */
64
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; }
69 };
70
71 // ----------------------------------------------------------------------------
72 // A simple wxDropTarget derived class for text data: you only need to
73 // override OnDropText() to get something working
74 // ----------------------------------------------------------------------------
75
76 class wxTextDropTarget : public wxDropTarget
77 {
78 public:
79 wxTextDropTarget();
80
81 virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
82
83 virtual bool OnData(wxCoord x, wxCoord y);
84 };
85
86 // ----------------------------------------------------------------------------
87 // A drop target which accepts files (dragged from File Manager or Explorer)
88 // ----------------------------------------------------------------------------
89
90 class wxFileDropTarget : public wxDropTarget
91 {
92 public:
93 wxFileDropTarget();
94
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;
98
99 virtual bool OnData(wxCoord x, wxCoord y);
100 };
101
102 //-------------------------------------------------------------------------
103 // wxDropSource
104 //-------------------------------------------------------------------------
105
106 class wxDropSource: public wxDropSourceBase
107 {
108 public:
109 /* constructor. set data later with SetData() */
110 wxDropSource( wxWindow *win,
111 const wxIcon &go = wxNullIcon,
112 const wxIcon &stop = wxNullIcon );
113
114 /* constructor for setting one data object */
115 wxDropSource( wxDataObject& data,
116 wxWindow *win,
117 const wxIcon &go = wxNullIcon,
118 const wxIcon &stop = wxNullIcon );
119
120 ~wxDropSource();
121
122 /* start drag action */
123 virtual wxDragResult DoDragDrop( bool bAllowMove = FALSE );
124
125 /* GTK implementation */
126 void RegisterWindow();
127 void UnregisterWindow();
128
129 GtkWidget *m_widget;
130 wxWindow *m_window;
131 wxDragResult m_retValue;
132
133 wxCursor m_defaultCursor;
134 wxCursor m_goaheadCursor;
135
136 wxIcon m_goIcon;
137 wxIcon m_stopIcon;
138
139 bool m_waiting;
140 };
141
142 #endif
143
144 // wxUSE_DRAG_AND_DROP
145
146 #endif
147 //__GTKDNDH__
148