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