1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/dataobj.cpp
3 // Purpose: implementation of wxDataObject class
4 // Author: Stefan Csomor
8 // Copyright: (c) 1999 Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/dataobj.h"
22 #include "wx/dcmemory.h"
26 #include "wx/mstream.h"
27 #include "wx/metafile.h"
28 #include "wx/tokenzr.h"
29 #include "wx/filename.h"
31 #include "wx/osx/private.h"
33 #if wxOSX_USE_COCOA_OR_CARBON
34 #include <QuickTime/QuickTime.h>
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 wxDataFormat::wxDataFormat()
43 m_type
= wxDF_INVALID
;
47 wxDataFormat::wxDataFormat( wxDataFormatId vType
)
50 m_type
= wxDF_INVALID
;
54 wxDataFormat::wxDataFormat( const wxChar
*zId
)
57 m_type
= wxDF_INVALID
;
61 wxDataFormat::wxDataFormat( const wxString
& rId
)
64 m_type
= wxDF_INVALID
;
68 wxDataFormat::wxDataFormat(const wxDataFormat
& rFormat
)
70 if ( rFormat
.m_format
)
71 m_format
= (NativeFormat
) CFStringCreateCopy(NULL
, (CFStringRef
)rFormat
.m_format
);
74 m_type
= rFormat
.m_type
;
78 wxDataFormat::wxDataFormat( NativeFormat vFormat
)
81 m_type
= wxDF_INVALID
;
85 wxDataFormat::~wxDataFormat()
89 CFRelease( (CFStringRef
) m_format
);
94 // in order to be correct for 10.3 we restrict to the available types there
95 // http://developer.apple.com/qa/qa2005/qa1406.html
96 // TODO : Use UTCoreTypes.h constants once we support 10.4+ only
98 wxDataFormat
& wxDataFormat::operator=(const wxDataFormat
& rFormat
)
102 CFRelease( (CFStringRef
) m_format
);
105 if ( rFormat
.m_format
)
106 m_format
= (NativeFormat
) CFStringCreateCopy(NULL
, (CFStringRef
)rFormat
.m_format
);
107 m_type
= rFormat
.m_type
;
112 void wxDataFormat::SetType( wxDataFormatId dataType
)
117 CFRelease( (CFStringRef
) m_format
);
124 m_format
= (long) CFStringCreateCopy( NULL
, kUTTypePlainText
);
127 case wxDF_UNICODETEXT
:
128 m_format
= (long) CFStringCreateCopy( NULL
, kUTTypeUTF16PlainText
);
132 m_format
= (long) CFStringCreateCopy( NULL
, kUTTypeHTML
);
136 m_format
= (long) CFStringCreateCopy( NULL
, kUTTypeTIFF
);
139 m_format
= (long) CFStringCreateCopy( NULL
, kUTTypePDF
);
143 m_format
= (long) CFStringCreateCopy( NULL
, kUTTypeFileURL
);
147 wxFAIL_MSG( wxT("invalid data format") );
152 wxString
wxDataFormat::GetId() const
154 return wxCFStringRef(wxCFRetain((CFStringRef
)m_format
)).AsString();
157 void wxDataFormat::SetId( NativeFormat format
)
161 CFRelease( (CFStringRef
) m_format
);
164 m_format
= (NativeFormat
) CFStringCreateCopy(NULL
, (CFStringRef
)format
);
165 if ( UTTypeConformsTo( (CFStringRef
)format
, kUTTypeHTML
) )
169 if ( UTTypeConformsTo( (CFStringRef
)format
, kUTTypeUTF16PlainText
) )
171 m_type
= wxDF_UNICODETEXT
;
173 else if ( UTTypeConformsTo( (CFStringRef
)format
,kUTTypeUTF16ExternalPlainText
) )
175 m_type
= wxDF_UNICODETEXT
;
177 else if ( UTTypeConformsTo( (CFStringRef
)format
,kUTTypeUTF8PlainText
) )
179 m_type
= wxDF_UNICODETEXT
;
181 else if ( UTTypeConformsTo( (CFStringRef
)format
, kUTTypePlainText
) )
185 else if ( UTTypeConformsTo( (CFStringRef
)format
, kUTTypeImage
) )
187 m_type
= wxDF_BITMAP
;
189 else if ( UTTypeConformsTo( (CFStringRef
)format
, kUTTypePDF
) )
191 m_type
= wxDF_METAFILE
;
193 else if ( UTTypeConformsTo( (CFStringRef
)format
, kUTTypeFileURL
) ||
194 UTTypeConformsTo( (CFStringRef
)format
, kPasteboardTypeFileURLPromise
))
196 m_type
= wxDF_FILENAME
;
200 m_type
= wxDF_PRIVATE
;
201 m_id
= wxCFStringRef( (CFStringRef
) CFRetain((CFStringRef
) format
)).AsString();
205 void wxDataFormat::SetId( const wxString
& zId
)
207 m_type
= wxDF_PRIVATE
;
211 CFRelease( (CFStringRef
) m_format
);
214 // since it is private, no need to conform to anything ...
215 m_format
= (long) wxCFRetain( (CFStringRef
) wxCFStringRef(m_id
) );
218 bool wxDataFormat::operator==(const wxDataFormat
& format
) const
220 if (IsStandard() || format
.IsStandard())
221 return (format
.m_type
== m_type
);
223 return ( UTTypeConformsTo( (CFStringRef
) m_format
, (CFStringRef
) format
.m_format
) );
226 //-------------------------------------------------------------------------
228 //-------------------------------------------------------------------------
230 wxDataObject::wxDataObject()
234 bool wxDataObject::IsSupportedFormat( const wxDataFormat
& rFormat
, Direction vDir
) const
236 size_t nFormatCount
= GetFormatCount( vDir
);
239 if (nFormatCount
== 1)
241 found
= (rFormat
== GetPreferredFormat());
245 wxDataFormat
*pFormats
= new wxDataFormat
[nFormatCount
];
246 GetAllFormats( pFormats
, vDir
);
248 for (size_t n
= 0; n
< nFormatCount
; n
++)
250 if (pFormats
[n
] == rFormat
)
263 void wxDataObject::AddToPasteboard( void * pb
, int itemID
)
265 PasteboardRef pasteboard
= (PasteboardRef
) pb
;
266 // get formats from wxDataObjects
267 wxDataFormat
*array
= new wxDataFormat
[ GetFormatCount() ];
268 GetAllFormats( array
);
270 for (size_t i
= 0; i
< GetFormatCount(); i
++)
272 wxDataFormat thisFormat
= array
[ i
];
274 // add four bytes at the end for data objs like text that
275 // have a datasize = strlen but still need a buffer for the
276 // string including trailing zero
278 size_t datasize
= GetDataSize( thisFormat
);
279 if ( datasize
== wxCONV_FAILED
&& thisFormat
.GetType() == wxDF_TEXT
)
281 // conversion to local text failed, so we must use unicode
282 // if wxDF_UNICODETEXT is already on the 'todo' list, skip this iteration
283 // otherwise force it
285 for (j
= 0; j
< GetFormatCount(); j
++)
287 if ( array
[j
].GetType() == wxDF_UNICODETEXT
)
290 if ( j
< GetFormatCount() )
293 thisFormat
.SetType(wxDF_UNICODETEXT
);
294 datasize
= GetDataSize( thisFormat
);
297 size_t sz
= datasize
+ 4;
298 void* buf
= malloc( sz
);
301 // empty the buffer because in some case GetDataHere does not fill buf
302 memset( buf
, 0, sz
);
303 if ( GetDataHere( thisFormat
, buf
) )
306 if ( thisFormat
.GetType() == wxDF_FILENAME
)
308 // the data is D-normalized UTF8 strings of filenames delimited with \n
309 char *fname
= strtok((char*) buf
,"\n");
310 while (fname
!= NULL
)
312 // translate the filepath into a fileurl and put that into the pasteobard
313 CFStringRef path
= CFStringCreateWithBytes(NULL
,(UInt8
*)fname
,strlen(fname
),kCFStringEncodingUTF8
,false);
314 CFURLRef url
= CFURLCreateWithFileSystemPath(NULL
, path
, kCFURLPOSIXPathStyle
, false);
316 CFDataRef data
= CFURLCreateData(NULL
,url
,kCFStringEncodingUTF8
,true);
318 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) counter
,
319 (CFStringRef
) thisFormat
.GetFormatId() , data
, kPasteboardFlavorNoFlags
);
322 fname
= strtok (NULL
,"\n");
328 CFDataRef data
= CFDataCreate( kCFAllocatorDefault
, (UInt8
*)buf
, datasize
);
329 if ( thisFormat
.GetType() == wxDF_TEXT
)
330 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) itemID
,
331 CFSTR("com.apple.traditional-mac-plain-text") , data
, kPasteboardFlavorNoFlags
);
333 PasteboardPutItemFlavor( pasteboard
, (PasteboardItemID
) itemID
,
334 (CFStringRef
) thisFormat
.GetFormatId() , data
, kPasteboardFlavorNoFlags
);
345 bool wxDataObject::IsFormatInPasteboard( void * pb
, const wxDataFormat
&dataFormat
)
347 PasteboardRef pasteboard
= (PasteboardRef
) pb
;
348 bool hasData
= false;
349 OSStatus err
= noErr
;
352 // we synchronize here once again, so we don't mind which flags get returned
353 PasteboardSynchronize( pasteboard
);
355 err
= PasteboardGetItemCount( pasteboard
, &itemCount
);
358 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
&& hasData
== false ; itemIndex
++ )
360 PasteboardItemID itemID
;
361 CFArrayRef flavorTypeArray
;
364 err
= PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
);
368 err
= PasteboardCopyItemFlavors( pasteboard
, itemID
, &flavorTypeArray
);
372 flavorCount
= CFArrayGetCount( flavorTypeArray
);
374 for( CFIndex flavorIndex
= 0; flavorIndex
< flavorCount
&& hasData
== false ; flavorIndex
++ )
376 CFStringRef flavorType
;
378 flavorType
= (CFStringRef
)CFArrayGetValueAtIndex( flavorTypeArray
,
381 wxDataFormat
flavorFormat( (wxDataFormat::NativeFormat
) flavorType
);
382 if ( dataFormat
== flavorFormat
)
384 else if ( dataFormat
.GetType() == wxDF_UNICODETEXT
&& flavorFormat
.GetType() == wxDF_TEXT
)
387 CFRelease (flavorTypeArray
);
394 bool wxDataObject::GetFromPasteboard( void * pb
)
396 PasteboardRef pasteboard
= (PasteboardRef
) pb
;
398 size_t formatcount
= GetFormatCount(wxDataObject::Set
);
399 wxDataFormat
*array
= new wxDataFormat
[ formatcount
];
400 GetAllFormats(array
, wxDataObject::Set
);
402 ItemCount itemCount
= 0;
403 wxString filenamesPassed
;
404 bool transferred
= false;
405 bool pastelocationset
= false;
407 // we synchronize here once again, so we don't mind which flags get returned
408 PasteboardSynchronize( pasteboard
);
410 OSStatus err
= PasteboardGetItemCount( pasteboard
, &itemCount
);
413 for (size_t i
= 0; !transferred
&& i
< formatcount
; i
++)
415 // go through the data in our order of preference
416 wxDataFormat dataFormat
= array
[ i
];
418 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
&& transferred
== false ; itemIndex
++ )
420 PasteboardItemID itemID
= 0;
421 CFArrayRef flavorTypeArray
= NULL
;
422 CFIndex flavorCount
= 0;
424 err
= PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
);
428 err
= PasteboardCopyItemFlavors( pasteboard
, itemID
, &flavorTypeArray
);
432 flavorCount
= CFArrayGetCount( flavorTypeArray
);
434 for( CFIndex flavorIndex
= 0; !transferred
&& flavorIndex
< flavorCount
; flavorIndex
++ )
436 CFStringRef flavorType
;
437 CFDataRef flavorData
;
438 CFIndex flavorDataSize
;
440 flavorType
= (CFStringRef
)CFArrayGetValueAtIndex( flavorTypeArray
,
443 wxDataFormat
flavorFormat( (wxDataFormat::NativeFormat
) flavorType
);
445 if ( dataFormat
== flavorFormat
)
447 if ( UTTypeConformsTo( (CFStringRef
)flavorType
, kPasteboardTypeFileURLPromise
) )
449 if ( !pastelocationset
)
451 wxString tempdir
= wxFileName::GetTempDir() + wxFILE_SEP_PATH
+ "wxtemp.XXXXXX";
452 char* result
= mkdtemp((char*)tempdir
.fn_str().data());
457 wxCFRef
<CFURLRef
> dest(CFURLCreateFromFileSystemRepresentation(NULL
,(const UInt8
*)result
,strlen(result
),true));
458 PasteboardSetPasteLocation(pasteboard
, dest
);
459 pastelocationset
= true;
462 else if ( flavorFormat
.GetType() != wxDF_PRIVATE
)
464 // indicate the expected format for the type, benefiting from native conversions eg utf8 -> utf16
465 flavorType
= (CFStringRef
) wxDataFormat( flavorFormat
.GetType()).GetFormatId();
468 err
= PasteboardCopyItemFlavorData( pasteboard
, itemID
, flavorType
, &flavorData
);
471 flavorDataSize
= CFDataGetLength( flavorData
);
472 if (dataFormat
.GetType() == wxDF_FILENAME
)
474 // revert the translation and decomposition to arrive at a proper utf8 string again
475 CFURLRef url
= CFURLCreateWithBytes( kCFAllocatorDefault
, CFDataGetBytePtr( flavorData
), flavorDataSize
, kCFStringEncodingUTF8
, NULL
);
476 CFStringRef cfString
= CFURLCopyFileSystemPath( url
, kCFURLPOSIXPathStyle
);
478 CFMutableStringRef cfMutableString
= CFStringCreateMutableCopy(NULL
, 0, cfString
);
479 CFRelease( cfString
);
480 CFStringNormalize(cfMutableString
,kCFStringNormalizationFormC
);
481 wxString path
= wxCFStringRef(cfMutableString
).AsString();
483 filenamesPassed
+= path
+ wxT("\n");
487 // because some data implementation expect trailing a trailing NUL, we add some headroom
488 void *buf
= malloc( flavorDataSize
+ 4 );
491 memset( buf
, 0, flavorDataSize
+ 4 );
492 memcpy( buf
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
494 if (dataFormat
.GetType() == wxDF_TEXT
)
495 wxMacConvertNewlines10To13( (char*) buf
);
496 SetData( flavorFormat
, flavorDataSize
, buf
);
501 CFRelease (flavorData
);
504 else if ( dataFormat
.GetType() == wxDF_UNICODETEXT
&& flavorFormat
.GetType() == wxDF_TEXT
)
506 err
= PasteboardCopyItemFlavorData( pasteboard
, itemID
, flavorType
, &flavorData
);
509 flavorDataSize
= CFDataGetLength( flavorData
);
510 void *asciibuf
= malloc( flavorDataSize
+ 1 );
513 memset( asciibuf
, 0, flavorDataSize
+ 1 );
514 memcpy( asciibuf
, CFDataGetBytePtr( flavorData
), flavorDataSize
);
515 CFRelease (flavorData
);
517 SetData( wxDF_TEXT
, flavorDataSize
, asciibuf
);
522 CFRelease (flavorData
);
526 CFRelease( flavorTypeArray
);
528 if ( !filenamesPassed
.empty() )
530 wxCharBuffer buf
= filenamesPassed
.fn_str();
531 SetData( wxDF_FILENAME
, strlen( buf
), (const char*)buf
);
539 bool wxDataObject::HasDataInPasteboard( void * pb
)
541 PasteboardRef pasteboard
= (PasteboardRef
) pb
;
542 size_t formatcount
= GetFormatCount(wxDataObject::Set
);
543 wxDataFormat
*array
= new wxDataFormat
[ formatcount
];
544 GetAllFormats(array
, wxDataObject::Set
);
545 ItemCount itemCount
= 0;
546 bool hasData
= false;
548 // we synchronize here once again, so we don't mind which flags get returned
549 PasteboardSynchronize( pasteboard
);
551 OSStatus err
= PasteboardGetItemCount( pasteboard
, &itemCount
);
554 for (size_t i
= 0; !hasData
&& i
< formatcount
; i
++)
556 // go through the data in our order of preference
557 wxDataFormat dataFormat
= array
[ i
];
559 for( UInt32 itemIndex
= 1; itemIndex
<= itemCount
&& hasData
== false ; itemIndex
++ )
561 PasteboardItemID itemID
= 0;
562 CFArrayRef flavorTypeArray
= NULL
;
563 CFIndex flavorCount
= 0;
565 err
= PasteboardGetItemIdentifier( pasteboard
, itemIndex
, &itemID
);
569 err
= PasteboardCopyItemFlavors( pasteboard
, itemID
, &flavorTypeArray
);
573 flavorCount
= CFArrayGetCount( flavorTypeArray
);
575 for( CFIndex flavorIndex
= 0; !hasData
&& flavorIndex
< flavorCount
; flavorIndex
++ )
577 CFStringRef flavorType
;
579 flavorType
= (CFStringRef
)CFArrayGetValueAtIndex( flavorTypeArray
,
582 wxDataFormat
flavorFormat( (wxDataFormat::NativeFormat
) flavorType
);
584 if ( dataFormat
== flavorFormat
||
585 (dataFormat
.GetType() == wxDF_UNICODETEXT
&& flavorFormat
.GetType() == wxDF_TEXT
) )
590 CFRelease( flavorTypeArray
);
599 void wxDataObject::AddSupportedTypes( void* cfarray
)
601 size_t nFormats
= GetFormatCount(wxDataObject::Set
);
602 wxDataFormat
*array
= new wxDataFormat
[nFormats
];
603 GetAllFormats(array
, wxDataObject::Set
);
605 for (size_t i
= 0; i
< nFormats
; i
++)
607 wxDataFormat dataFormat
= array
[ i
];
609 if ( dataFormat
.GetType() == wxDF_UNICODETEXT
|| dataFormat
.GetType() == wxDF_TEXT
)
611 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypeUTF16PlainText
);
612 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypePlainText
);
614 else if ( dataFormat
.GetType() == wxDF_FILENAME
)
616 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypeFileURL
);
617 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kPasteboardTypeFileURLPromise
);
619 else if ( dataFormat
.GetType() == wxDF_HTML
)
621 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypeHTML
);
623 else if ( dataFormat
.GetType() == wxDF_BITMAP
)
625 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypeTIFF
);
626 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypePICT
);
628 else if ( dataFormat
.GetType() == wxDF_METAFILE
)
630 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, kUTTypePDF
);
632 else if ( dataFormat
.GetType() == wxDF_PRIVATE
)
634 CFArrayAppendValue((CFMutableArrayRef
)cfarray
, (CFStringRef
) dataFormat
.GetFormatId());
642 // ----------------------------------------------------------------------------
644 // ----------------------------------------------------------------------------
647 void wxTextDataObject::GetAllFormats(wxDataFormat
*formats
,
648 wxDataObjectBase::Direction
WXUNUSED(dir
)) const
650 *formats
++ = wxDataFormat(wxDF_UNICODETEXT
);
651 *formats
= wxDataFormat(wxDF_TEXT
);
655 // ----------------------------------------------------------------------------
657 // ----------------------------------------------------------------------------
659 void wxFileDataObject::GetFileNames( wxCharBuffer
&buf
) const
663 for (size_t i
= 0; i
< m_filenames
.GetCount(); i
++)
665 filenames
+= m_filenames
[i
];
666 filenames
+= wxT('\n');
669 buf
= filenames
.fn_str();
672 bool wxFileDataObject::GetDataHere( void *pBuf
) const
681 buffLength
= strlen( buf
);
682 memcpy( pBuf
, (const char*)buf
, buffLength
+ 1 );
687 size_t wxFileDataObject::GetDataSize() const
693 buffLength
= strlen( buf
);
695 return buffLength
+ 1;
698 bool wxFileDataObject::SetData( size_t WXUNUSED(nSize
), const void *pBuf
)
703 filenames
= wxString( (const char*)pBuf
, *wxConvFileName
);
705 filenames
= wxString (wxConvLocal
.cWC2WX(wxConvFileName
->cMB2WC( (const char*)pBuf
)));
708 m_filenames
= wxStringTokenize( filenames
, wxT("\n"), wxTOKEN_STRTOK
);
713 void wxFileDataObject::AddFile( const wxString
& rFilename
)
715 m_filenames
.Add( rFilename
);
718 // ----------------------------------------------------------------------------
719 // wxBitmapDataObject
720 // ----------------------------------------------------------------------------
722 wxBitmapDataObject::wxBitmapDataObject()
727 wxBitmapDataObject::wxBitmapDataObject( const wxBitmap
& rBitmap
)
728 : wxBitmapDataObjectBase( rBitmap
)
734 SetBitmap( rBitmap
);
738 wxBitmapDataObject::~wxBitmapDataObject()
743 void wxBitmapDataObject::SetBitmap( const wxBitmap
& rBitmap
)
746 wxBitmapDataObjectBase::SetBitmap( rBitmap
);
749 CGImageRef cgImageRef
= (CGImageRef
) m_bitmap
.CreateCGImage();
751 CFMutableDataRef data
= CFDataCreateMutable(kCFAllocatorDefault
, 0);
752 CGImageDestinationRef destination
= CGImageDestinationCreateWithData( data
, kUTTypeTIFF
, 1 , NULL
);
755 CGImageDestinationAddImage( destination
, cgImageRef
, NULL
);
756 CGImageDestinationFinalize( destination
);
757 CFRelease( destination
);
759 m_pictHandle
= NewHandle(CFDataGetLength(data
));
762 memcpy( *(Handle
)m_pictHandle
, (const char *)CFDataGetBytePtr(data
), CFDataGetLength(data
) );
766 CGImageRelease(cgImageRef
);
770 void wxBitmapDataObject::Init()
773 m_pictCreated
= false;
776 void wxBitmapDataObject::Clear()
778 if (m_pictHandle
!= NULL
)
780 DisposeHandle( (Handle
) m_pictHandle
);
783 m_pictCreated
= false;
786 bool wxBitmapDataObject::GetDataHere( void *pBuf
) const
788 if (m_pictHandle
== NULL
)
790 wxFAIL_MSG( wxT("attempt to copy empty bitmap failed") );
797 memcpy( pBuf
, *(Handle
)m_pictHandle
, GetHandleSize( (Handle
)m_pictHandle
) );
802 size_t wxBitmapDataObject::GetDataSize() const
804 if (m_pictHandle
!= NULL
)
805 return GetHandleSize( (Handle
)m_pictHandle
);
810 Handle
MacCreateDataReferenceHandle(Handle theDataHandle
)
812 Handle dataRef
= NULL
;
815 // Create a data reference handle for our data.
816 err
= PtrToHand( &theDataHandle
, &dataRef
, sizeof(Handle
));
821 bool wxBitmapDataObject::SetData( size_t nSize
, const void *pBuf
)
825 if ((pBuf
== NULL
) || (nSize
== 0))
828 Handle picHandle
= NewHandle( nSize
);
829 memcpy( *picHandle
, pBuf
, nSize
);
830 m_pictHandle
= picHandle
;
831 CGImageRef cgImageRef
= 0;
833 CFDataRef data
= CFDataCreateWithBytesNoCopy( kCFAllocatorDefault
, (const UInt8
*) pBuf
, nSize
, kCFAllocatorNull
);
834 CGImageSourceRef source
= CGImageSourceCreateWithData( data
, NULL
);
837 cgImageRef
= CGImageSourceCreateImageAtIndex(source
, 0, NULL
);
844 m_bitmap
.Create( CGImageGetWidth(cgImageRef
) , CGImageGetHeight(cgImageRef
) );
845 CGRect r
= CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef
) , CGImageGetHeight(cgImageRef
) );
846 // since our context is upside down we dont use CGContextDrawImage
847 wxMacDrawCGImage( (CGContextRef
) m_bitmap
.GetHBITMAP() , &r
, cgImageRef
) ;
848 CGImageRelease(cgImageRef
);
852 return m_bitmap
.IsOk();