]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/dnd.h
A bit more or multi-format clipboard.
[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 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();
53
54 // implementation
55
56 GdkAtom GetMatchingPair();
57 void RegisterWidget( GtkWidget *widget );
58 void UnregisterWidget( GtkWidget *widget );
59
60 GdkDragContext *m_dragContext;
61 GtkWidget *m_dragWidget;
62 GtkSelectionData *m_dragData;
63 guint m_dragTime;
64 bool m_firstMotion; /* gdk has no "gdk_drag_enter" event */
65
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; }
70 };
71
72 // ----------------------------------------------------------------------------
73 // A simple wxDropTarget derived class for text data: you only need to
74 // override OnDropText() to get something working
75 // ----------------------------------------------------------------------------
76
77 class wxTextDropTarget : public wxDropTarget
78 {
79 public:
80 wxTextDropTarget();
81
82 virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
83
84 virtual bool OnData(wxCoord x, wxCoord y);
85 };
86
87 // ----------------------------------------------------------------------------
88 // A drop target which accepts files (dragged from File Manager or Explorer)
89 // ----------------------------------------------------------------------------
90
91 class wxFileDropTarget : public wxDropTarget
92 {
93 public:
94 wxFileDropTarget();
95
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;
99
100 virtual bool OnData(wxCoord x, wxCoord y);
101 };
102
103 //-------------------------------------------------------------------------
104 // wxDropSource
105 //-------------------------------------------------------------------------
106
107 class wxDropSource: public wxDropSourceBase
108 {
109 public:
110 /* constructor. set data later with SetData() */
111 wxDropSource( wxWindow *win,
112 const wxIcon &go = wxNullIcon,
113 const wxIcon &stop = wxNullIcon );
114
115 /* constructor for setting one data object */
116 wxDropSource( wxDataObject& data,
117 wxWindow *win,
118 const wxIcon &go = wxNullIcon,
119 const wxIcon &stop = wxNullIcon );
120
121 ~wxDropSource();
122
123 /* start drag action */
124 virtual wxDragResult DoDragDrop( bool bAllowMove = FALSE );
125
126 /* GTK implementation */
127 void RegisterWindow();
128 void UnregisterWindow();
129
130 GtkWidget *m_widget;
131 wxWindow *m_window;
132 wxDragResult m_retValue;
133
134 wxCursor m_defaultCursor;
135 wxCursor m_goaheadCursor;
136
137 wxIcon m_goIcon;
138 wxIcon m_stopIcon;
139
140 bool m_waiting;
141 };
142
143 #endif
144
145 // wxUSE_DRAG_AND_DROP
146
147 #endif
148 //__GTKDNDH__
149