]> git.saurik.com Git - wxWidgets.git/blob - src/motif/dnd.cpp
Add missing WXK constants for the control keys
[wxWidgets.git] / src / motif / dnd.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dnd.cpp
3 // Purpose: wxDropTarget, wxDropSource classes
4 // Author: Julian Smart
5 // Id: $Id$
6 // Copyright: (c) 1998 Julian Smart
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #if wxUSE_DRAG_AND_DROP
14
15 #include "wx/dnd.h"
16
17 #ifndef WX_PRECOMP
18 #include "wx/intl.h"
19 #include "wx/log.h"
20 #include "wx/app.h"
21 #include "wx/utils.h"
22 #include "wx/window.h"
23 #include "wx/gdicmn.h"
24 #endif
25
26 #include <X11/Xlib.h>
27
28 // ----------------------------------------------------------------------------
29 // global
30 // ----------------------------------------------------------------------------
31
32 // ----------------------------------------------------------------------------
33 // wxDropTarget
34 // ----------------------------------------------------------------------------
35
36 wxDropTarget::wxDropTarget()
37 {
38 }
39
40 wxDropTarget::~wxDropTarget()
41 {
42 }
43
44 // ----------------------------------------------------------------------------
45 // wxTextDropTarget
46 // ----------------------------------------------------------------------------
47
48 bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
49 {
50 OnDropText( x, y, (const char*)data );
51 return true;
52 }
53
54 bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
55 {
56 wxLogDebug( "Got dropped text: %s.", psz );
57 wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
58 return true;
59 }
60
61 size_t wxTextDropTarget::GetFormatCount() const
62 {
63 return 1;
64 }
65
66 wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
67 {
68 return wxDF_TEXT;
69 }
70
71 // ----------------------------------------------------------------------------
72 // wxFileDropTarget
73 // ----------------------------------------------------------------------------
74
75 bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
76 {
77 wxLogDebug( "Got %d dropped files.", (int)nFiles );
78 wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
79 size_t i;
80 for (i = 0; i < nFiles; i++)
81 {
82 wxLogDebug( aszFiles[i] );
83 }
84 return true;
85 }
86
87 bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
88 {
89 size_t number = 0;
90 char *text = (char*) data;
91 size_t i;
92 for (i = 0; i < size; i++)
93 if (text[i] == 0) number++;
94
95 if (number == 0) return true;
96
97 char **files = new char*[number];
98
99 text = (char*) data;
100 for ( i = 0; i < number; i++)
101 {
102 files[i] = text;
103 int len = strlen( text );
104 text += len+1;
105 }
106
107 bool ret = OnDropFiles( x, y, 1, files );
108
109 free( files );
110
111 return ret;
112 }
113
114 size_t wxFileDropTarget::GetFormatCount() const
115 {
116 return 1;
117 }
118
119 wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
120 {
121 return wxDF_FILENAME;
122 }
123
124 //-------------------------------------------------------------------------
125 // wxDropSource
126 //-------------------------------------------------------------------------
127
128 wxDropSource::wxDropSource( wxWindow *win )
129 {
130 #if 0
131 m_window = win;
132 m_data = NULL;
133 m_retValue = wxDragCancel;
134
135 m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
136 m_goaheadCursor = wxCursor( wxCURSOR_HAND );
137 #endif
138 }
139
140 wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
141 {
142 #if 0
143 g_blockEventsOnDrag = true;
144
145 m_window = win;
146 m_widget = win->m_widget;
147 if (win->m_wxwindow) m_widget = win->m_wxwindow;
148 m_retValue = wxDragCancel;
149
150 m_data = &data;
151
152 m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
153 m_goaheadCursor = wxCursor( wxCURSOR_HAND );
154 #endif
155 }
156
157 void wxDropSource::SetData( wxDataObject &data )
158 {
159 // m_data = &data;
160 }
161
162 wxDropSource::~wxDropSource(void)
163 {
164 // if (m_data) delete m_data;
165 }
166
167 wxDragResult wxDropSource::DoDragDrop( int WXUNUSED(flags) )
168 {
169 // wxASSERT_MSG( m_data, "wxDragSource: no data" );
170
171 return wxDragNone;
172 #if 0
173 if (!m_data) return (wxDragResult) wxDragNone;
174 if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone;
175
176 RegisterWindow();
177
178 // TODO
179
180 UnregisterWindow();
181
182 g_blockEventsOnDrag = false;
183
184 return m_retValue;
185 #endif
186 }
187
188 #if 0
189 void wxDropSource::RegisterWindow(void)
190 {
191 if (!m_data) return;
192
193 wxString formats;
194
195 wxDataFormat df = m_data->GetPreferredFormat();
196
197 switch (df)
198 {
199 case wxDF_TEXT:
200 formats += "text/plain";
201 break;
202 case wxDF_FILENAME:
203 formats += "file:ALL";
204 break;
205 default:
206 break;
207 }
208
209 char *str = WXSTRINGCAST formats;
210
211 // TODO
212 }
213
214 void wxDropSource::UnregisterWindow(void)
215 {
216 if (!m_widget) return;
217
218 // TODO
219 }
220 #endif
221
222 wxPrivateDropTarget::wxPrivateDropTarget()
223 {
224 m_id = wxTheApp->GetAppName();
225 }
226
227 size_t wxPrivateDropTarget::GetFormatCount() const
228 {
229 return 1;
230 }
231
232 wxDataFormat wxPrivateDropTarget::GetFormat(size_t n) const
233 {
234 return wxDF_INVALID;
235 }
236
237 #endif
238 // wxUSE_DRAG_AND_DROP