]>
Commit | Line | Data |
---|---|---|
0e320a79 | 1 | ///////////////////////////////////////////////////////////////////////////// |
cb7d7375 | 2 | // Name: src/os2/clipbrd.cpp |
0e320a79 | 3 | // Purpose: Clipboard functionality |
37f214d5 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
37f214d5 | 6 | // Created: 10/13/99 |
37f214d5 | 7 | // Copyright: (c) David Webster |
65571936 | 8 | // Licence: wxWindows licence |
0e320a79 DW |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
37f214d5 DW |
11 | // For compilers that support precompilation, includes "wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
37f214d5 DW |
14 | #if wxUSE_CLIPBOARD |
15 | ||
e4db172a WS |
16 | #include "wx/clipbrd.h" |
17 | ||
37f214d5 DW |
18 | #ifndef WX_PRECOMP |
19 | #include "wx/object.h" | |
20 | #include "wx/event.h" | |
21 | #include "wx/app.h" | |
22 | #include "wx/frame.h" | |
23 | #include "wx/bitmap.h" | |
24 | #include "wx/utils.h" | |
25 | #include "wx/intl.h" | |
e4db172a | 26 | #include "wx/log.h" |
28f92d74 | 27 | #include "wx/dataobj.h" |
37f214d5 DW |
28 | #endif |
29 | ||
30 | #if wxUSE_METAFILE | |
31 | #include "wx/metafile.h" | |
0e320a79 DW |
32 | #endif |
33 | ||
0e320a79 DW |
34 | #include <string.h> |
35 | ||
37f214d5 DW |
36 | #include "wx/os2/private.h" |
37 | ||
38 | // wxDataObject is tied to OLE/drag and drop implementation, | |
39 | // therefore so is wxClipboard :-( | |
0e320a79 | 40 | |
37f214d5 DW |
41 | // =========================================================================== |
42 | // implementation | |
43 | // =========================================================================== | |
44 | ||
45 | // --------------------------------------------------------------------------- | |
46 | // old-style clipboard functions using Windows API | |
47 | // --------------------------------------------------------------------------- | |
48 | ||
cb7d7375 | 49 | static bool gs_wxClipboardIsOpen = false; |
37f214d5 | 50 | |
0e320a79 DW |
51 | bool wxOpenClipboard() |
52 | { | |
6670f564 | 53 | wxCHECK_MSG( !gs_wxClipboardIsOpen, true, wxT("clipboard already opened.") ); |
37f214d5 DW |
54 | // TODO: |
55 | /* | |
56 | wxWindow *win = wxTheApp->GetTopWindow(); | |
57 | if ( win ) | |
58 | { | |
59 | gs_wxClipboardIsOpen = ::OpenClipboard((HWND)win->GetHWND()) != 0; | |
60 | ||
61 | if ( !gs_wxClipboardIsOpen ) | |
43b2d5e7 | 62 | { |
37f214d5 | 63 | wxLogSysError(_("Failed to open the clipboard.")); |
43b2d5e7 | 64 | } |
37f214d5 DW |
65 | |
66 | return gs_wxClipboardIsOpen; | |
67 | } | |
68 | else | |
69 | { | |
4c51a665 | 70 | wxLogDebug(wxT("Cannot open clipboard without a main window.")); |
37f214d5 | 71 | |
cb7d7375 | 72 | return false; |
37f214d5 DW |
73 | } |
74 | */ | |
cb7d7375 | 75 | return false; |
0e320a79 DW |
76 | } |
77 | ||
78 | bool wxCloseClipboard() | |
79 | { | |
cb7d7375 | 80 | wxCHECK_MSG( gs_wxClipboardIsOpen, false, wxT("clipboard is not opened") ); |
37f214d5 DW |
81 | // TODO: |
82 | /* | |
cb7d7375 | 83 | gs_wxClipboardIsOpen = false; |
37f214d5 DW |
84 | |
85 | if ( ::CloseClipboard() == 0 ) | |
86 | { | |
87 | wxLogSysError(_("Failed to close the clipboard.")); | |
88 | ||
cb7d7375 | 89 | return false; |
37f214d5 DW |
90 | } |
91 | */ | |
6670f564 | 92 | return true; |
0e320a79 DW |
93 | } |
94 | ||
95 | bool wxEmptyClipboard() | |
96 | { | |
37f214d5 DW |
97 | // TODO: |
98 | /* | |
99 | if ( ::EmptyClipboard() == 0 ) | |
100 | { | |
101 | wxLogSysError(_("Failed to empty the clipboard.")); | |
102 | ||
cb7d7375 | 103 | return false; |
37f214d5 DW |
104 | } |
105 | */ | |
6670f564 | 106 | return true; |
0e320a79 DW |
107 | } |
108 | ||
37f214d5 | 109 | bool wxIsClipboardOpened() |
0e320a79 | 110 | { |
37f214d5 | 111 | return gs_wxClipboardIsOpen; |
0e320a79 DW |
112 | } |
113 | ||
6670f564 | 114 | bool wxIsClipboardFormatAvailable(wxDataFormat WXUNUSED(dataFormat)) |
0e320a79 | 115 | { |
37f214d5 | 116 | // TODO: return ::IsClipboardFormatAvailable(dataFormat) != 0; |
6670f564 | 117 | return false; |
0e320a79 DW |
118 | } |
119 | ||
9923c37d | 120 | #if 0 |
37f214d5 DW |
121 | #if wxUSE_DRAG_AND_DROP |
122 | static bool wxSetClipboardData(wxDataObject *data) | |
0e320a79 | 123 | { |
37f214d5 DW |
124 | // TODO: |
125 | /* | |
126 | size_t size = data->GetDataSize(); | |
127 | HANDLE hGlobal = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size); | |
128 | if ( !hGlobal ) | |
129 | { | |
130 | wxLogSysError(_("Failed to allocate %dKb of memory for clipboard " | |
131 | "transfer."), size / 1024); | |
132 | ||
cb7d7375 | 133 | return false; |
37f214d5 DW |
134 | } |
135 | ||
136 | LPVOID lpGlobalMemory = ::GlobalLock(hGlobal); | |
137 | ||
138 | data->GetDataHere(lpGlobalMemory); | |
139 | ||
140 | GlobalUnlock(hGlobal); | |
141 | ||
142 | wxDataFormat format = data->GetPreferredFormat(); | |
143 | if ( !::SetClipboardData(format, hGlobal) ) | |
144 | { | |
145 | wxLogSysError(_("Failed to set clipboard data in format %s"), | |
146 | wxDataObject::GetFormatName(format)); | |
147 | ||
cb7d7375 | 148 | return false; |
37f214d5 DW |
149 | } |
150 | */ | |
6670f564 | 151 | return true; |
37f214d5 DW |
152 | } |
153 | #endif // wxUSE_DRAG_AND_DROP | |
9923c37d | 154 | #endif |
37f214d5 | 155 | |
cb7d7375 WS |
156 | bool wxSetClipboardData(wxDataFormat WXUNUSED(dataFormat), |
157 | const void *WXUNUSED(data), | |
158 | int WXUNUSED(width), int WXUNUSED(height)) | |
37f214d5 DW |
159 | { |
160 | // TODO: | |
161 | /* | |
162 | HANDLE handle = 0; // return value of SetClipboardData | |
163 | switch (dataFormat) | |
164 | { | |
165 | case wxDF_BITMAP: | |
166 | { | |
167 | wxBitmap *bitmap = (wxBitmap *)data; | |
168 | ||
169 | HDC hdcMem = CreateCompatibleDC((HDC) NULL); | |
170 | HDC hdcSrc = CreateCompatibleDC((HDC) NULL); | |
171 | HBITMAP old = (HBITMAP) | |
172 | ::SelectObject(hdcSrc, (HBITMAP)bitmap->GetHBITMAP()); | |
173 | HBITMAP hBitmap = CreateCompatibleBitmap(hdcSrc, | |
174 | bitmap->GetWidth(), | |
175 | bitmap->GetHeight()); | |
176 | if (!hBitmap) | |
177 | { | |
178 | SelectObject(hdcSrc, old); | |
179 | DeleteDC(hdcMem); | |
180 | DeleteDC(hdcSrc); | |
cb7d7375 | 181 | return false; |
37f214d5 DW |
182 | } |
183 | ||
184 | HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hBitmap); | |
185 | BitBlt(hdcMem, 0, 0, bitmap->GetWidth(), bitmap->GetHeight(), | |
186 | hdcSrc, 0, 0, SRCCOPY); | |
187 | ||
188 | // Select new bitmap out of memory DC | |
189 | SelectObject(hdcMem, old1); | |
190 | ||
191 | // Set the data | |
192 | handle = ::SetClipboardData(CF_BITMAP, hBitmap); | |
193 | ||
194 | // Clean up | |
195 | SelectObject(hdcSrc, old); | |
196 | DeleteDC(hdcSrc); | |
197 | DeleteDC(hdcMem); | |
198 | break; | |
199 | } | |
200 | ||
201 | case wxDF_DIB: | |
202 | { | |
203 | #if wxUSE_IMAGE_LOADING_IN_MSW | |
204 | wxBitmap *bitmap = (wxBitmap *)data; | |
205 | HBITMAP hBitmap = (HBITMAP)bitmap->GetHBITMAP(); | |
206 | // NULL palette means to use the system one | |
207 | HANDLE hDIB = wxBitmapToDIB(hBitmap, (HPALETTE)NULL); | |
208 | handle = SetClipboardData(CF_DIB, hDIB); | |
209 | #endif | |
210 | break; | |
211 | } | |
212 | ||
213 | #if wxUSE_METAFILE | |
214 | case wxDF_METAFILE: | |
215 | { | |
216 | wxMetafile *wxMF = (wxMetafile *)data; | |
217 | HANDLE data = GlobalAlloc(GHND, sizeof(METAFILEPICT) + 1); | |
218 | METAFILEPICT *mf = (METAFILEPICT *)GlobalLock(data); | |
219 | ||
220 | mf->mm = wxMF->GetWindowsMappingMode(); | |
221 | mf->xExt = width; | |
222 | mf->yExt = height; | |
223 | mf->hMF = (HMETAFILE) wxMF->GetHMETAFILE(); | |
224 | GlobalUnlock(data); | |
225 | wxMF->SetHMETAFILE((WXHANDLE) NULL); | |
226 | ||
227 | handle = SetClipboardData(CF_METAFILEPICT, data); | |
228 | break; | |
229 | } | |
230 | #endif | |
231 | case CF_SYLK: | |
232 | case CF_DIF: | |
233 | case CF_TIFF: | |
234 | case CF_PALETTE: | |
235 | default: | |
236 | { | |
237 | wxLogError(_("Unsupported clipboard format.")); | |
cb7d7375 | 238 | return false; |
37f214d5 DW |
239 | } |
240 | ||
241 | case wxDF_OEMTEXT: | |
242 | dataFormat = wxDF_TEXT; | |
243 | // fall through | |
244 | ||
245 | case wxDF_TEXT: | |
246 | { | |
247 | char *s = (char *)data; | |
248 | ||
249 | width = strlen(s) + 1; | |
250 | height = 1; | |
251 | DWORD l = (width * height); | |
252 | HANDLE hGlobalMemory = GlobalAlloc(GHND, l); | |
253 | if ( hGlobalMemory ) | |
254 | { | |
255 | LPSTR lpGlobalMemory = (LPSTR)GlobalLock(hGlobalMemory); | |
256 | ||
257 | memcpy(lpGlobalMemory, s, l); | |
258 | ||
259 | GlobalUnlock(hGlobalMemory); | |
260 | } | |
261 | ||
262 | handle = SetClipboardData(dataFormat, hGlobalMemory); | |
263 | break; | |
264 | } | |
265 | } | |
266 | ||
267 | if ( handle == 0 ) | |
268 | { | |
269 | wxLogSysError(_("Failed to set clipboard data.")); | |
270 | ||
cb7d7375 | 271 | return false; |
37f214d5 DW |
272 | } |
273 | */ | |
6670f564 | 274 | return true; |
0e320a79 DW |
275 | } |
276 | ||
cb7d7375 | 277 | void *wxGetClipboardData(wxDataFormat WXUNUSED(dataFormat), long *WXUNUSED(len)) |
0e320a79 | 278 | { |
9923c37d | 279 | // void *retval = NULL; |
37f214d5 DW |
280 | // TODO: |
281 | /* | |
282 | switch ( dataFormat ) | |
283 | { | |
284 | case wxDF_BITMAP: | |
285 | { | |
286 | BITMAP bm; | |
287 | HBITMAP hBitmap = (HBITMAP) GetClipboardData(CF_BITMAP); | |
288 | if (!hBitmap) | |
289 | break; | |
290 | ||
291 | HDC hdcMem = CreateCompatibleDC((HDC) NULL); | |
292 | HDC hdcSrc = CreateCompatibleDC((HDC) NULL); | |
293 | ||
294 | HBITMAP old = (HBITMAP) ::SelectObject(hdcSrc, hBitmap); | |
295 | GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); | |
296 | ||
297 | HBITMAP hNewBitmap = CreateBitmapIndirect(&bm); | |
298 | ||
299 | if (!hNewBitmap) | |
300 | { | |
301 | SelectObject(hdcSrc, old); | |
302 | DeleteDC(hdcMem); | |
303 | DeleteDC(hdcSrc); | |
304 | break; | |
305 | } | |
306 | ||
307 | HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hNewBitmap); | |
308 | BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, | |
309 | hdcSrc, 0, 0, SRCCOPY); | |
310 | ||
311 | // Select new bitmap out of memory DC | |
312 | SelectObject(hdcMem, old1); | |
313 | ||
314 | // Clean up | |
315 | SelectObject(hdcSrc, old); | |
316 | DeleteDC(hdcSrc); | |
317 | DeleteDC(hdcMem); | |
318 | ||
319 | // Create and return a new wxBitmap | |
320 | wxBitmap *wxBM = new wxBitmap; | |
321 | wxBM->SetHBITMAP((WXHBITMAP) hNewBitmap); | |
322 | wxBM->SetWidth(bm.bmWidth); | |
323 | wxBM->SetHeight(bm.bmHeight); | |
324 | wxBM->SetDepth(bm.bmPlanes); | |
6670f564 | 325 | wxBM->SetOk(true); |
37f214d5 DW |
326 | retval = wxBM; |
327 | break; | |
328 | } | |
329 | ||
330 | case wxDF_METAFILE: | |
331 | case CF_SYLK: | |
332 | case CF_DIF: | |
333 | case CF_TIFF: | |
334 | case CF_PALETTE: | |
335 | case wxDF_DIB: | |
336 | { | |
337 | wxLogError(_("Unsupported clipboard format.")); | |
cb7d7375 | 338 | return NULL; |
37f214d5 DW |
339 | } |
340 | ||
341 | case wxDF_OEMTEXT: | |
342 | dataFormat = wxDF_TEXT; | |
343 | // fall through | |
344 | ||
345 | case wxDF_TEXT: | |
346 | { | |
347 | HANDLE hGlobalMemory = ::GetClipboardData(dataFormat); | |
348 | if (!hGlobalMemory) | |
349 | break; | |
350 | ||
351 | DWORD hsize = ::GlobalSize(hGlobalMemory); | |
352 | if (len) | |
353 | *len = hsize; | |
354 | ||
355 | char *s = new char[hsize]; | |
356 | if (!s) | |
357 | break; | |
358 | ||
359 | LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory); | |
360 | ||
361 | memcpy(s, lpGlobalMemory, hsize); | |
362 | ||
363 | ::GlobalUnlock(hGlobalMemory); | |
364 | ||
365 | retval = s; | |
366 | break; | |
367 | } | |
368 | ||
369 | default: | |
370 | { | |
371 | HANDLE hGlobalMemory = ::GetClipboardData(dataFormat); | |
372 | if ( !hGlobalMemory ) | |
373 | break; | |
374 | ||
375 | DWORD size = ::GlobalSize(hGlobalMemory); | |
376 | if ( len ) | |
377 | *len = size; | |
378 | ||
379 | void *buf = malloc(size); | |
380 | if ( !buf ) | |
381 | break; | |
382 | ||
383 | LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory); | |
384 | ||
385 | memcpy(buf, lpGlobalMemory, size); | |
386 | ||
387 | ::GlobalUnlock(hGlobalMemory); | |
388 | ||
389 | retval = buf; | |
390 | break; | |
391 | } | |
392 | } | |
393 | ||
394 | if ( !retval ) | |
395 | { | |
396 | wxLogSysError(_("Failed to retrieve data from the clipboard.")); | |
397 | } | |
398 | ||
399 | return retval; | |
400 | */ | |
0e320a79 DW |
401 | return NULL; |
402 | } | |
403 | ||
37f214d5 | 404 | wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat) |
0e320a79 | 405 | { |
37f214d5 DW |
406 | // TODO: return ::EnumClipboardFormats(dataFormat); |
407 | return dataFormat; | |
0e320a79 DW |
408 | } |
409 | ||
cb7d7375 | 410 | int wxRegisterClipboardFormat(wxChar *WXUNUSED(formatName)) |
0e320a79 | 411 | { |
37f214d5 DW |
412 | // TODO: return ::RegisterClipboardFormat(formatName); |
413 | return 0; | |
0e320a79 DW |
414 | } |
415 | ||
cb7d7375 WS |
416 | bool wxGetClipboardFormatName(wxDataFormat WXUNUSED(dataFormat), |
417 | wxChar *WXUNUSED(formatName), | |
418 | int WXUNUSED(maxCount)) | |
0e320a79 | 419 | { |
37f214d5 DW |
420 | // TODO: return ::GetClipboardFormatName((int)dataFormat, formatName, maxCount) > 0; |
421 | return 0; | |
0e320a79 DW |
422 | } |
423 | ||
37f214d5 DW |
424 | // --------------------------------------------------------------------------- |
425 | // wxClipboard | |
426 | // --------------------------------------------------------------------------- | |
0e320a79 | 427 | |
37f214d5 | 428 | IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) |
0e320a79 | 429 | |
0e320a79 DW |
430 | wxClipboard::wxClipboard() |
431 | { | |
0e320a79 DW |
432 | } |
433 | ||
434 | wxClipboard::~wxClipboard() | |
435 | { | |
37f214d5 | 436 | Clear(); |
0e320a79 DW |
437 | } |
438 | ||
37f214d5 | 439 | void wxClipboard::Clear() |
0e320a79 | 440 | { |
37f214d5 | 441 | } |
0e320a79 | 442 | |
6dddc146 DW |
443 | bool wxClipboard::Flush() |
444 | { | |
445 | // TODO: | |
cb7d7375 | 446 | return false; |
6dddc146 DW |
447 | } |
448 | ||
37f214d5 DW |
449 | bool wxClipboard::Open() |
450 | { | |
451 | return wxOpenClipboard(); | |
0e320a79 DW |
452 | } |
453 | ||
6dddc146 DW |
454 | bool wxClipboard::IsOpened() const |
455 | { | |
456 | return wxIsClipboardOpened(); | |
457 | } | |
458 | ||
cb7d7375 | 459 | bool wxClipboard::SetData( wxDataObject *WXUNUSED(data) ) |
0e320a79 | 460 | { |
37f214d5 DW |
461 | (void)wxEmptyClipboard(); |
462 | // TODO: | |
463 | /* | |
464 | if ( data ) | |
465 | return AddData(data); | |
466 | else | |
6670f564 | 467 | return true; |
37f214d5 | 468 | */ |
6670f564 | 469 | return true; |
37f214d5 | 470 | } |
0e320a79 | 471 | |
37f214d5 DW |
472 | bool wxClipboard::AddData( wxDataObject *data ) |
473 | { | |
cb7d7375 | 474 | wxCHECK_MSG( data, false, wxT("data is invalid") ); |
0e320a79 | 475 | |
37f214d5 | 476 | #if wxUSE_DRAG_AND_DROP |
cb7d7375 | 477 | wxCHECK_MSG( wxIsClipboardOpened(), false, wxT("clipboard not open") ); |
0e320a79 | 478 | |
2dab12be | 479 | // wxDataFormat format = data->GetPreferredFormat(); |
37f214d5 DW |
480 | // TODO: |
481 | /* | |
482 | switch ( format ) | |
483 | { | |
484 | case wxDF_TEXT: | |
485 | case wxDF_OEMTEXT: | |
486 | { | |
487 | wxTextDataObject* textDataObject = (wxTextDataObject*) data; | |
488 | wxString str(textDataObject->GetText()); | |
489 | return wxSetClipboardData(format, str.c_str()); | |
490 | } | |
491 | ||
492 | case wxDF_BITMAP: | |
493 | case wxDF_DIB: | |
494 | { | |
495 | wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; | |
496 | wxBitmap bitmap(bitmapDataObject->GetBitmap()); | |
2dab12be | 497 | return wxSetClipboardData(data->GetPreferredFormat(), &bitmap); |
37f214d5 DW |
498 | } |
499 | ||
500 | #if wxUSE_METAFILE | |
501 | case wxDF_METAFILE: | |
502 | { | |
503 | wxMetafileDataObject* metaFileDataObject = | |
504 | (wxMetafileDataObject*) data; | |
505 | wxMetafile metaFile = metaFileDataObject->GetMetafile(); | |
506 | return wxSetClipboardData(wxDF_METAFILE, &metaFile, | |
507 | metaFileDataObject->GetWidth(), | |
508 | metaFileDataObject->GetHeight()); | |
509 | } | |
510 | #endif // wxUSE_METAFILE | |
511 | ||
512 | default: | |
513 | return wxSetClipboardData(data); | |
0e320a79 | 514 | } |
37f214d5 DW |
515 | #else // !wxUSE_DRAG_AND_DROP |
516 | */ | |
cb7d7375 | 517 | return false; |
19193a2c | 518 | #else |
cb7d7375 | 519 | return false; |
37f214d5 | 520 | #endif // wxUSE_DRAG_AND_DROP/!wxUSE_DRAG_AND_DROP |
0e320a79 DW |
521 | } |
522 | ||
37f214d5 | 523 | void wxClipboard::Close() |
0e320a79 | 524 | { |
37f214d5 | 525 | wxCloseClipboard(); |
0e320a79 DW |
526 | } |
527 | ||
2af18715 | 528 | bool wxClipboard::IsSupported( const wxDataFormat& format ) |
0e320a79 | 529 | { |
37f214d5 DW |
530 | return wxIsClipboardFormatAvailable(format); |
531 | } | |
0e320a79 | 532 | |
cb7d7375 | 533 | bool wxClipboard::GetData( wxDataObject& WXUNUSED(data) ) |
37f214d5 | 534 | { |
cb7d7375 | 535 | wxCHECK_MSG( wxIsClipboardOpened(), false, wxT("clipboard not open") ); |
0e320a79 | 536 | |
37f214d5 | 537 | #if wxUSE_DRAG_AND_DROP |
2dab12be | 538 | // wxDataFormat format = data.GetPreferredFormat(); |
37f214d5 DW |
539 | // TODO: |
540 | /* | |
541 | switch ( format ) | |
542 | { | |
543 | case wxDF_TEXT: | |
544 | case wxDF_OEMTEXT: | |
545 | { | |
efe7d6ff | 546 | wxTextDataObject& textDataObject = (wxTextDataObject&) data; |
37f214d5 DW |
547 | char* s = (char*) wxGetClipboardData(format); |
548 | if ( s ) | |
549 | { | |
efe7d6ff | 550 | textDataObject.SetText(s); |
37f214d5 | 551 | delete[] s; |
6670f564 | 552 | return true; |
37f214d5 DW |
553 | } |
554 | else | |
cb7d7375 | 555 | return false; |
37f214d5 DW |
556 | } |
557 | ||
558 | case wxDF_BITMAP: | |
559 | case wxDF_DIB: | |
560 | { | |
efe7d6ff | 561 | wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data; |
2dab12be | 562 | wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetPreferredFormat()); |
37f214d5 DW |
563 | if (bitmap) |
564 | { | |
efe7d6ff | 565 | bitmapDataObject.SetBitmap(* bitmap); |
37f214d5 | 566 | delete bitmap; |
6670f564 | 567 | return true; |
37f214d5 DW |
568 | } |
569 | else | |
cb7d7375 | 570 | return false; |
37f214d5 DW |
571 | } |
572 | #if wxUSE_METAFILE | |
573 | case wxDF_METAFILE: | |
574 | { | |
efe7d6ff | 575 | wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data; |
37f214d5 DW |
576 | wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE); |
577 | if (metaFile) | |
578 | { | |
efe7d6ff | 579 | metaFileDataObject.SetMetafile(*metaFile); |
37f214d5 | 580 | delete metaFile; |
6670f564 | 581 | return true; |
37f214d5 DW |
582 | } |
583 | else | |
cb7d7375 | 584 | return false; |
37f214d5 DW |
585 | } |
586 | #endif | |
587 | default: | |
588 | { | |
589 | long len; | |
590 | void *buf = wxGetClipboardData(format, &len); | |
591 | if ( buf ) | |
592 | { | |
cb7d7375 | 593 | // FIXME this is for testing only! |
efe7d6ff | 594 | ((wxPrivateDataObject &)data).SetData(buf, len); |
37f214d5 DW |
595 | free(buf); |
596 | ||
6670f564 | 597 | return true; |
37f214d5 DW |
598 | } |
599 | } | |
600 | ||
cb7d7375 | 601 | return false; |
37f214d5 DW |
602 | } |
603 | #else | |
604 | */ | |
cb7d7375 | 605 | return false; |
19193a2c | 606 | #else |
cb7d7375 | 607 | return false; |
37f214d5 DW |
608 | #endif |
609 | } | |
0e320a79 | 610 | |
37f214d5 | 611 | #endif // wxUSE_CLIPBOARD |