]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: dnd.h | |
3 | // Purpose: declaration of the wxDropTarget class | |
4 | // Author: Robert Roebling | |
58614078 | 5 | // RCS-ID: $Id$ |
c801d85f KB |
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 | ||
06cfab17 | 18 | #if wxUSE_DRAG_AND_DROP |
ac57418f | 19 | |
c801d85f KB |
20 | #include "wx/object.h" |
21 | #include "wx/string.h" | |
8b53e5a2 | 22 | #include "wx/dataobj.h" |
c801d85f | 23 | #include "wx/cursor.h" |
e4677d31 RR |
24 | #include "wx/icon.h" |
25 | #include "wx/gdicmn.h" | |
c801d85f KB |
26 | |
27 | //------------------------------------------------------------------------- | |
28 | // classes | |
29 | //------------------------------------------------------------------------- | |
30 | ||
31 | class wxWindow; | |
32 | ||
33 | class wxDropTarget; | |
34 | class wxTextDropTarget; | |
e3e65dac RR |
35 | class wxFileDropTarget; |
36 | ||
37 | class wxDropSource; | |
38 | ||
d6086ea6 RR |
39 | //------------------------------------------------------------------------- |
40 | // wxDropTarget | |
41 | //------------------------------------------------------------------------- | |
42 | ||
b068c4e8 | 43 | class wxDropTarget: public wxDropTargetBase |
d6086ea6 RR |
44 | { |
45 | public: | |
b068c4e8 RR |
46 | wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL ); |
47 | ||
c9057ae1 | 48 | virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); |
b068c4e8 RR |
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; } | |
9e2896e5 | 69 | }; |
8e193f38 | 70 | |
97c79de2 RR |
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 | ||
9e2896e5 VZ |
102 | //------------------------------------------------------------------------- |
103 | // wxDropSource | |
104 | //------------------------------------------------------------------------- | |
105 | ||
b068c4e8 | 106 | class wxDropSource: public wxDropSourceBase |
9e2896e5 VZ |
107 | { |
108 | public: | |
109 | /* constructor. set data later with SetData() */ | |
110 | wxDropSource( wxWindow *win, | |
111 | const wxIcon &go = wxNullIcon, | |
112 | const wxIcon &stop = wxNullIcon ); | |
8e193f38 | 113 | |
9e2896e5 VZ |
114 | /* constructor for setting one data object */ |
115 | wxDropSource( wxDataObject& data, | |
116 | wxWindow *win, | |
117 | const wxIcon &go = wxNullIcon, | |
118 | const wxIcon &stop = wxNullIcon ); | |
8e193f38 | 119 | |
9e2896e5 | 120 | ~wxDropSource(); |
8e193f38 | 121 | |
9e2896e5 VZ |
122 | /* start drag action */ |
123 | virtual wxDragResult DoDragDrop( bool bAllowMove = FALSE ); | |
8e193f38 | 124 | |
9e2896e5 VZ |
125 | /* GTK implementation */ |
126 | void RegisterWindow(); | |
127 | void UnregisterWindow(); | |
8e193f38 | 128 | |
8a126fcc RR |
129 | GtkWidget *m_widget; |
130 | wxWindow *m_window; | |
131 | wxDragResult m_retValue; | |
8e193f38 | 132 | |
8a126fcc RR |
133 | wxCursor m_defaultCursor; |
134 | wxCursor m_goaheadCursor; | |
8e193f38 | 135 | |
8a126fcc RR |
136 | wxIcon m_goIcon; |
137 | wxIcon m_stopIcon; | |
8e193f38 | 138 | |
8a126fcc | 139 | bool m_waiting; |
c801d85f KB |
140 | }; |
141 | ||
ac57418f RR |
142 | #endif |
143 | ||
144 | // wxUSE_DRAG_AND_DROP | |
145 | ||
8e193f38 | 146 | #endif |
c801d85f KB |
147 | //__GTKDNDH__ |
148 |