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