]>
Commit | Line | Data |
---|---|---|
3f364be8 | 1 | /////////////////////////////////////////////////////////////////////////////// |
8b445796 | 2 | // Name: src/common/dobjcmn.cpp |
3f364be8 VZ |
3 | // Purpose: implementation of data object methods common to all platforms |
4 | // Author: Vadim Zeitlin, Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 19.10.99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets Team |
65571936 | 9 | // Licence: wxWindows licence |
3f364be8 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
8b445796 | 12 | // For compilers that support precompilation, includes "wx.h". |
3f364be8 VZ |
13 | #include "wx/wxprec.h" |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_DATAOBJ |
20 | ||
e7c80f9e WS |
21 | #include "wx/dataobj.h" |
22 | ||
3f364be8 VZ |
23 | #ifndef WX_PRECOMP |
24 | #include "wx/app.h" | |
8b445796 | 25 | #endif |
3f364be8 | 26 | |
3f364be8 VZ |
27 | // ---------------------------------------------------------------------------- |
28 | // lists | |
29 | // ---------------------------------------------------------------------------- | |
30 | ||
31 | #include "wx/listimpl.cpp" | |
32 | ||
259c43f6 | 33 | WX_DEFINE_LIST(wxSimpleDataObjectList) |
3f364be8 | 34 | |
0c2b453f VZ |
35 | // ---------------------------------------------------------------------------- |
36 | // globals | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | static wxDataFormat dataFormatInvalid; | |
31e78e0c | 40 | WXDLLEXPORT const wxDataFormat& wxFormatInvalid = dataFormatInvalid; |
0c2b453f | 41 | |
3f364be8 VZ |
42 | // ============================================================================ |
43 | // implementation | |
44 | // ============================================================================ | |
45 | ||
46 | // ---------------------------------------------------------------------------- | |
47 | // wxDataObjectBase | |
48 | // ---------------------------------------------------------------------------- | |
49 | ||
50 | wxDataObjectBase::~wxDataObjectBase() | |
51 | { | |
52 | } | |
53 | ||
d9317fd4 VZ |
54 | bool wxDataObjectBase::IsSupported(const wxDataFormat& format, |
55 | Direction dir) const | |
56 | { | |
8b445796 | 57 | size_t nFormatCount = GetFormatCount( dir ); |
d9317fd4 VZ |
58 | if ( nFormatCount == 1 ) |
59 | { | |
8b445796 | 60 | return format == GetPreferredFormat( dir ); |
d9317fd4 VZ |
61 | } |
62 | else | |
63 | { | |
64 | wxDataFormat *formats = new wxDataFormat[nFormatCount]; | |
8b445796 | 65 | GetAllFormats( formats, dir ); |
d9317fd4 VZ |
66 | |
67 | size_t n; | |
68 | for ( n = 0; n < nFormatCount; n++ ) | |
69 | { | |
70 | if ( formats[n] == format ) | |
71 | break; | |
72 | } | |
73 | ||
74 | delete [] formats; | |
75 | ||
76 | // found? | |
77 | return n < nFormatCount; | |
78 | } | |
79 | } | |
80 | ||
3f364be8 VZ |
81 | // ---------------------------------------------------------------------------- |
82 | // wxDataObjectComposite | |
83 | // ---------------------------------------------------------------------------- | |
84 | ||
e6b01b78 VZ |
85 | wxDataObjectComposite::wxDataObjectComposite() |
86 | { | |
87 | m_preferred = 0; | |
c072c757 | 88 | m_receivedFormat = wxFormatInvalid; |
222ed1d6 | 89 | } |
e6b01b78 | 90 | |
222ed1d6 MB |
91 | wxDataObjectComposite::~wxDataObjectComposite() |
92 | { | |
8b445796 | 93 | WX_CLEAR_LIST( wxSimpleDataObjectList, m_dataObjects ); |
e6b01b78 VZ |
94 | } |
95 | ||
3f364be8 | 96 | wxDataObjectSimple * |
dc892843 | 97 | wxDataObjectComposite::GetObject(const wxDataFormat& format, wxDataObjectBase::Direction dir) const |
3f364be8 | 98 | { |
222ed1d6 | 99 | wxSimpleDataObjectList::compatibility_iterator node = m_dataObjects.GetFirst(); |
dc892843 | 100 | |
3f364be8 VZ |
101 | while ( node ) |
102 | { | |
103 | wxDataObjectSimple *dataObj = node->GetData(); | |
104 | ||
dc892843 RR |
105 | if (dataObj->IsSupported(format,dir)) |
106 | return dataObj; | |
3f364be8 VZ |
107 | node = node->GetNext(); |
108 | } | |
d3b9f782 | 109 | return NULL; |
3f364be8 VZ |
110 | } |
111 | ||
112 | void wxDataObjectComposite::Add(wxDataObjectSimple *dataObject, bool preferred) | |
113 | { | |
114 | if ( preferred ) | |
115 | m_preferred = m_dataObjects.GetCount(); | |
c82f9bcf | 116 | |
3f364be8 VZ |
117 | m_dataObjects.Append( dataObject ); |
118 | } | |
119 | ||
c072c757 RD |
120 | wxDataFormat wxDataObjectComposite::GetReceivedFormat() const |
121 | { | |
122 | return m_receivedFormat; | |
123 | } | |
124 | ||
3f364be8 VZ |
125 | wxDataFormat |
126 | wxDataObjectComposite::GetPreferredFormat(Direction WXUNUSED(dir)) const | |
127 | { | |
222ed1d6 | 128 | wxSimpleDataObjectList::compatibility_iterator node = m_dataObjects.Item( m_preferred ); |
3f364be8 | 129 | |
2ee3ee1b | 130 | wxCHECK_MSG( node, wxFormatInvalid, wxT("no preferred format") ); |
3f364be8 VZ |
131 | |
132 | wxDataObjectSimple* dataObj = node->GetData(); | |
133 | ||
134 | return dataObj->GetFormat(); | |
135 | } | |
136 | ||
e1b435af | 137 | #if defined(__WXMSW__) |
7d584866 | 138 | |
e1b435af MB |
139 | size_t wxDataObjectComposite::GetBufferOffset( const wxDataFormat& format ) |
140 | { | |
141 | wxDataObjectSimple *dataObj = GetObject(format); | |
142 | ||
f7f50f49 | 143 | wxCHECK_MSG( dataObj, 0, |
e1b435af MB |
144 | wxT("unsupported format in wxDataObjectComposite")); |
145 | ||
146 | return dataObj->GetBufferOffset( format ); | |
147 | } | |
148 | ||
7d584866 | 149 | |
e1b435af MB |
150 | const void* wxDataObjectComposite::GetSizeFromBuffer( const void* buffer, |
151 | size_t* size, | |
152 | const wxDataFormat& format ) | |
153 | { | |
154 | wxDataObjectSimple *dataObj = GetObject(format); | |
155 | ||
f7f50f49 | 156 | wxCHECK_MSG( dataObj, NULL, |
e1b435af MB |
157 | wxT("unsupported format in wxDataObjectComposite")); |
158 | ||
159 | return dataObj->GetSizeFromBuffer( buffer, size, format ); | |
160 | } | |
161 | ||
7d584866 | 162 | |
e1b435af MB |
163 | void* wxDataObjectComposite::SetSizeInBuffer( void* buffer, size_t size, |
164 | const wxDataFormat& format ) | |
165 | { | |
8b445796 | 166 | wxDataObjectSimple *dataObj = GetObject( format ); |
e1b435af | 167 | |
f7f50f49 | 168 | wxCHECK_MSG( dataObj, NULL, |
e1b435af MB |
169 | wxT("unsupported format in wxDataObjectComposite")); |
170 | ||
171 | return dataObj->SetSizeInBuffer( buffer, size, format ); | |
172 | } | |
173 | ||
174 | #endif | |
175 | ||
9113ffaf | 176 | size_t wxDataObjectComposite::GetFormatCount(Direction dir) const |
3f364be8 | 177 | { |
9113ffaf FM |
178 | size_t n = 0; |
179 | ||
180 | // NOTE: some wxDataObjectSimple objects may return a number greater than 1 | |
181 | // from GetFormatCount(): this is the case of e.g. wxTextDataObject | |
182 | // under wxMac and wxGTK | |
183 | wxSimpleDataObjectList::compatibility_iterator node; | |
184 | for ( node = m_dataObjects.GetFirst(); node; node = node->GetNext() ) | |
185 | n += node->GetData()->GetFormatCount(dir); | |
186 | ||
187 | return n; | |
3f364be8 VZ |
188 | } |
189 | ||
190 | void wxDataObjectComposite::GetAllFormats(wxDataFormat *formats, | |
0dd48109 | 191 | Direction dir) const |
3f364be8 | 192 | { |
0dd48109 | 193 | size_t index(0); |
222ed1d6 | 194 | wxSimpleDataObjectList::compatibility_iterator node; |
0dd48109 | 195 | |
3f364be8 VZ |
196 | for ( node = m_dataObjects.GetFirst(); node; node = node->GetNext() ) |
197 | { | |
9113ffaf FM |
198 | // NOTE: some wxDataObjectSimple objects may return more than 1 format |
199 | // from GetAllFormats(): this is the case of e.g. wxTextDataObject | |
200 | // under wxMac and wxGTK | |
201 | node->GetData()->GetAllFormats(formats+index, dir); | |
202 | index += node->GetData()->GetFormatCount(dir); | |
3f364be8 VZ |
203 | } |
204 | } | |
205 | ||
206 | size_t wxDataObjectComposite::GetDataSize(const wxDataFormat& format) const | |
207 | { | |
208 | wxDataObjectSimple *dataObj = GetObject(format); | |
209 | ||
210 | wxCHECK_MSG( dataObj, 0, | |
211 | wxT("unsupported format in wxDataObjectComposite")); | |
212 | ||
213 | return dataObj->GetDataSize(); | |
214 | } | |
215 | ||
216 | bool wxDataObjectComposite::GetDataHere(const wxDataFormat& format, | |
217 | void *buf) const | |
218 | { | |
8b445796 | 219 | wxDataObjectSimple *dataObj = GetObject( format ); |
3f364be8 | 220 | |
68379eaf | 221 | wxCHECK_MSG( dataObj, false, |
3f364be8 VZ |
222 | wxT("unsupported format in wxDataObjectComposite")); |
223 | ||
8b445796 | 224 | return dataObj->GetDataHere( buf ); |
3f364be8 VZ |
225 | } |
226 | ||
227 | bool wxDataObjectComposite::SetData(const wxDataFormat& format, | |
228 | size_t len, | |
229 | const void *buf) | |
230 | { | |
8b445796 | 231 | wxDataObjectSimple *dataObj = GetObject( format ); |
3f364be8 | 232 | |
68379eaf | 233 | wxCHECK_MSG( dataObj, false, |
3f364be8 VZ |
234 | wxT("unsupported format in wxDataObjectComposite")); |
235 | ||
c072c757 | 236 | m_receivedFormat = format; |
8b445796 | 237 | return dataObj->SetData( len, buf ); |
3f364be8 VZ |
238 | } |
239 | ||
240 | // ---------------------------------------------------------------------------- | |
241 | // wxTextDataObject | |
242 | // ---------------------------------------------------------------------------- | |
243 | ||
98ecad06 VZ |
244 | #ifdef wxNEEDS_UTF8_FOR_TEXT_DATAOBJ |
245 | ||
246 | // FIXME-UTF8: we should be able to merge wchar_t and UTF-8 versions once we | |
247 | // have a way to get UTF-8 string (and its length) in both builds | |
248 | // without loss of efficiency (i.e. extra buffer copy/strlen call) | |
249 | ||
250 | #if wxUSE_UNICODE_WCHAR | |
c7d6d883 | 251 | |
f4370741 VZ |
252 | static inline wxMBConv& GetConv(const wxDataFormat& format) |
253 | { | |
254 | // use UTF8 for wxDF_UNICODETEXT and UCS4 for wxDF_TEXT | |
255 | return format == wxDF_UNICODETEXT ? wxConvUTF8 : wxConvLibc; | |
256 | } | |
257 | ||
c7d6d883 RR |
258 | size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const |
259 | { | |
f4370741 | 260 | wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); |
8b445796 | 261 | |
2c906a49 | 262 | return buffer ? strlen( buffer ) : 0; |
c7d6d883 RR |
263 | } |
264 | ||
265 | bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const | |
266 | { | |
f7570f57 | 267 | if ( !buf ) |
8b445796 DS |
268 | return false; |
269 | ||
f4370741 | 270 | wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); |
f7570f57 RR |
271 | if ( !buffer ) |
272 | return false; | |
f4370741 | 273 | |
f7570f57 RR |
274 | memcpy( (char*) buf, buffer, GetDataSize(format) ); |
275 | // strcpy( (char*) buf, buffer ); | |
68379eaf WS |
276 | |
277 | return true; | |
c7d6d883 RR |
278 | } |
279 | ||
280 | bool wxTextDataObject::SetData(const wxDataFormat& format, | |
281 | size_t WXUNUSED(len), const void *buf) | |
282 | { | |
8b445796 | 283 | if ( buf == NULL ) |
f4370741 VZ |
284 | return false; |
285 | ||
8b445796 | 286 | wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf ); |
8b445796 DS |
287 | |
288 | SetText( buffer ); | |
68379eaf WS |
289 | |
290 | return true; | |
c7d6d883 RR |
291 | } |
292 | ||
98ecad06 VZ |
293 | #else // wxUSE_UNICODE_UTF8 |
294 | ||
295 | size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const | |
296 | { | |
297 | if ( format == wxDF_UNICODETEXT || wxLocaleIsUtf8 ) | |
298 | { | |
299 | return m_text.utf8_length(); | |
300 | } | |
301 | else // wxDF_TEXT | |
302 | { | |
303 | const wxCharBuffer buf(wxConvLocal.cWC2MB(m_text.wc_str())); | |
304 | return buf ? strlen(buf) : 0; | |
305 | } | |
306 | } | |
307 | ||
308 | bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const | |
309 | { | |
310 | if ( !buf ) | |
311 | return false; | |
312 | ||
313 | if ( format == wxDF_UNICODETEXT || wxLocaleIsUtf8 ) | |
314 | { | |
315 | memcpy(buf, m_text.utf8_str(), m_text.utf8_length()); | |
316 | } | |
317 | else // wxDF_TEXT | |
318 | { | |
319 | const wxCharBuffer bufLocal(wxConvLocal.cWC2MB(m_text.wc_str())); | |
320 | if ( !bufLocal ) | |
321 | return false; | |
322 | ||
323 | memcpy(buf, bufLocal, strlen(bufLocal)); | |
324 | } | |
325 | ||
326 | return true; | |
327 | } | |
328 | ||
329 | bool wxTextDataObject::SetData(const wxDataFormat& format, | |
330 | size_t len, const void *buf_) | |
331 | { | |
5c33522f | 332 | const char * const buf = static_cast<const char *>(buf_); |
98ecad06 VZ |
333 | |
334 | if ( buf == NULL ) | |
335 | return false; | |
336 | ||
337 | if ( format == wxDF_UNICODETEXT || wxLocaleIsUtf8 ) | |
338 | { | |
339 | // normally the data is in UTF-8 so we could use FromUTF8Unchecked() | |
340 | // but it's not absolutely clear what GTK+ does if the clipboard data | |
341 | // is not in UTF-8 so do an extra check for tranquility, it shouldn't | |
342 | // matter much if we lose a bit of performance when pasting from | |
343 | // clipboard | |
344 | m_text = wxString::FromUTF8(buf, len); | |
345 | } | |
346 | else // wxDF_TEXT, convert from current (non-UTF8) locale | |
347 | { | |
348 | m_text = wxConvLocal.cMB2WC(buf, len, NULL); | |
349 | } | |
350 | ||
351 | return true; | |
352 | } | |
353 | ||
354 | #endif // wxUSE_UNICODE_WCHAR/wxUSE_UNICODE_UTF8 | |
355 | ||
356 | #elif defined(wxNEEDS_UTF16_FOR_TEXT_DATAOBJ) | |
25758297 | 357 | |
8b445796 | 358 | static wxMBConvUTF16 sUTF16Converter; |
671478ee SC |
359 | |
360 | static inline wxMBConv& GetConv(const wxDataFormat& format) | |
361 | { | |
8b445796 DS |
362 | return |
363 | format == wxDF_UNICODETEXT | |
364 | ? (wxMBConv&) sUTF16Converter | |
365 | : (wxMBConv&) wxConvLocal; | |
671478ee SC |
366 | } |
367 | ||
25758297 SC |
368 | size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const |
369 | { | |
8b445796 DS |
370 | size_t len = GetConv(format).WC2MB( NULL, GetText().c_str(), 0 ); |
371 | len += (format == wxDF_UNICODETEXT ? 2 : 1); | |
372 | ||
373 | return len; | |
25758297 SC |
374 | } |
375 | ||
376 | bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const | |
377 | { | |
8b445796 | 378 | if ( buf == NULL ) |
671478ee SC |
379 | return false; |
380 | ||
8b445796 | 381 | wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); |
671478ee | 382 | |
8b445796 DS |
383 | size_t len = GetConv(format).WC2MB( NULL, GetText().c_str(), 0 ); |
384 | len += (format == wxDF_UNICODETEXT ? 2 : 1); | |
385 | ||
386 | // trailing (uni)char 0 | |
387 | memcpy( (char*)buf, (const char*)buffer, len ); | |
68379eaf WS |
388 | |
389 | return true; | |
25758297 SC |
390 | } |
391 | ||
392 | bool wxTextDataObject::SetData(const wxDataFormat& format, | |
393 | size_t WXUNUSED(len), const void *buf) | |
394 | { | |
8b445796 | 395 | if ( buf == NULL ) |
671478ee | 396 | return false; |
8b445796 DS |
397 | |
398 | wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf ); | |
399 | ||
400 | SetText( buffer ); | |
401 | ||
68379eaf | 402 | return true; |
25758297 SC |
403 | } |
404 | ||
98ecad06 | 405 | #else // !wxNEEDS_UTF{8,16}_FOR_TEXT_DATAOBJ |
c7d6d883 RR |
406 | |
407 | size_t wxTextDataObject::GetDataSize() const | |
408 | { | |
e1b435af | 409 | return GetTextLength() * sizeof(wxChar); |
3f364be8 VZ |
410 | } |
411 | ||
412 | bool wxTextDataObject::GetDataHere(void *buf) const | |
413 | { | |
f453d7ea FM |
414 | // NOTE: use wxTmemcpy() instead of wxStrncpy() to allow |
415 | // retrieval of strings with embedded NULLs | |
416 | wxTmemcpy( (wxChar*)buf, GetText().c_str(), GetTextLength() ); | |
3f364be8 | 417 | |
68379eaf | 418 | return true; |
3f364be8 VZ |
419 | } |
420 | ||
f453d7ea | 421 | bool wxTextDataObject::SetData(size_t len, const void *buf) |
3f364be8 | 422 | { |
f453d7ea | 423 | SetText( wxString((const wxChar*)buf, len/sizeof(wxChar)) ); |
3f364be8 | 424 | |
68379eaf | 425 | return true; |
3f364be8 VZ |
426 | } |
427 | ||
98ecad06 | 428 | #endif // different wxTextDataObject implementations |
9e2896e5 | 429 | |
3f364be8 VZ |
430 | // ---------------------------------------------------------------------------- |
431 | // wxCustomDataObject | |
432 | // ---------------------------------------------------------------------------- | |
433 | ||
775e1c62 RD |
434 | wxCustomDataObject::wxCustomDataObject(const wxDataFormat& format) |
435 | : wxDataObjectSimple(format) | |
436 | { | |
8b445796 DS |
437 | m_data = NULL; |
438 | m_size = 0; | |
775e1c62 RD |
439 | } |
440 | ||
3f364be8 VZ |
441 | wxCustomDataObject::~wxCustomDataObject() |
442 | { | |
443 | Free(); | |
444 | } | |
445 | ||
446 | void wxCustomDataObject::TakeData(size_t size, void *data) | |
447 | { | |
448 | Free(); | |
449 | ||
450 | m_size = size; | |
451 | m_data = data; | |
452 | } | |
453 | ||
454 | void *wxCustomDataObject::Alloc(size_t size) | |
455 | { | |
456 | return (void *)new char[size]; | |
457 | } | |
458 | ||
459 | void wxCustomDataObject::Free() | |
460 | { | |
8b445796 | 461 | delete [] (char*)m_data; |
3f364be8 | 462 | m_size = 0; |
d3b9f782 | 463 | m_data = NULL; |
3f364be8 VZ |
464 | } |
465 | ||
466 | size_t wxCustomDataObject::GetDataSize() const | |
467 | { | |
468 | return GetSize(); | |
469 | } | |
470 | ||
471 | bool wxCustomDataObject::GetDataHere(void *buf) const | |
472 | { | |
8b445796 DS |
473 | if ( buf == NULL ) |
474 | return false; | |
475 | ||
3f364be8 | 476 | void *data = GetData(); |
8b445796 | 477 | if ( data == NULL ) |
68379eaf | 478 | return false; |
3f364be8 | 479 | |
8b445796 | 480 | memcpy( buf, data, GetSize() ); |
3f364be8 | 481 | |
68379eaf | 482 | return true; |
3f364be8 VZ |
483 | } |
484 | ||
9e2896e5 | 485 | bool wxCustomDataObject::SetData(size_t size, const void *buf) |
3f364be8 VZ |
486 | { |
487 | Free(); | |
488 | ||
489 | m_data = Alloc(size); | |
8b445796 | 490 | if ( m_data == NULL ) |
68379eaf | 491 | return false; |
3f364be8 | 492 | |
8b445796 DS |
493 | m_size = size; |
494 | memcpy( m_data, buf, m_size ); | |
3f364be8 | 495 | |
68379eaf | 496 | return true; |
3f364be8 VZ |
497 | } |
498 | ||
8ee9d618 VZ |
499 | // ============================================================================ |
500 | // some common dnd related code | |
501 | // ============================================================================ | |
502 | ||
8fb3a512 JS |
503 | #if wxUSE_DRAG_AND_DROP |
504 | ||
8ee9d618 VZ |
505 | #include "wx/dnd.h" |
506 | ||
507 | // ---------------------------------------------------------------------------- | |
508 | // wxTextDropTarget | |
509 | // ---------------------------------------------------------------------------- | |
510 | ||
f3ac12aa VZ |
511 | // NB: we can't use "new" in ctor initializer lists because this provokes an |
512 | // internal compiler error with VC++ 5.0 (hey, even gcc compiles this!), | |
513 | // so use SetDataObject() instead | |
514 | ||
8ee9d618 | 515 | wxTextDropTarget::wxTextDropTarget() |
8ee9d618 | 516 | { |
f3ac12aa | 517 | SetDataObject(new wxTextDataObject); |
8ee9d618 VZ |
518 | } |
519 | ||
520 | wxDragResult wxTextDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def) | |
521 | { | |
522 | if ( !GetData() ) | |
523 | return wxDragNone; | |
524 | ||
525 | wxTextDataObject *dobj = (wxTextDataObject *)m_dataObject; | |
8b445796 | 526 | return OnDropText( x, y, dobj->GetText() ) ? def : wxDragNone; |
8ee9d618 VZ |
527 | } |
528 | ||
529 | // ---------------------------------------------------------------------------- | |
530 | // wxFileDropTarget | |
531 | // ---------------------------------------------------------------------------- | |
532 | ||
533 | wxFileDropTarget::wxFileDropTarget() | |
8ee9d618 | 534 | { |
f3ac12aa | 535 | SetDataObject(new wxFileDataObject); |
8ee9d618 VZ |
536 | } |
537 | ||
538 | wxDragResult wxFileDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def) | |
539 | { | |
540 | if ( !GetData() ) | |
541 | return wxDragNone; | |
542 | ||
543 | wxFileDataObject *dobj = (wxFileDataObject *)m_dataObject; | |
8b445796 | 544 | return OnDropFiles( x, y, dobj->GetFilenames() ) ? def : wxDragNone; |
8ee9d618 VZ |
545 | } |
546 | ||
1e6feb95 | 547 | #endif // wxUSE_DRAG_AND_DROP |
8fb3a512 | 548 | |
1e6feb95 | 549 | #endif // wxUSE_DATAOBJ |