# endif
#endif
-#ifndef __DARWIN__
-# include <Scrap.h>
-#endif
+#include "wx/mac/uma.h"
// since we have decided that we only support 8.6 upwards we are
// checking for these minimum requirements in the startup code of
{
}
-void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded )
+void UMAInitToolbox( UInt16 WXUNUSED(inMoreMastersCalls),
+ bool WXUNUSED(isEmbedded) )
{
::InitCursor();
macKey = 0 ;
glyph = kMenuF1Glyph + ( key - WXK_F1 ) ;
if ( key >= WXK_F13 )
- glyph += 13 ;
+ glyph += 12 ;
}
else
{
#endif
-OSStatus UMAPutScrap( Size size , OSType type , void *data )
-{
- OSStatus err = noErr ;
-
-#if !TARGET_CARBON
- err = PutScrap( size , type , data ) ;
-#else
- ScrapRef scrap;
- err = GetCurrentScrap( &scrap );
- if ( err == noErr )
- err = PutScrapFlavor( scrap, type , 0, size, data );
-#endif
-
- return err ;
-}
-
Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
{
GetControlBounds( theControl , bounds ) ;
return bounds ;
}
+size_t UMAPutBytesCFRefCallback( void *info, const void *bytes, size_t count )
+{
+ CFMutableDataRef data = (CFMutableDataRef) info;
+ if ( data )
+ {
+ CFDataAppendBytes( data, (const UInt8*) bytes, count );
+ }
+ return count;
+}
+
+void UMAReleaseCFDataProviderCallback( void *info, const void *data, size_t count )
+{
+ if ( info )
+ CFRelease( (CFDataRef) info );
+}
+
+void UMAReleaseCFDataConsumerCallback( void *info )
+{
+ if ( info )
+ CFRelease( (CFDataRef) info );
+}
+
+CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data )
+{
+ if ( data == NULL )
+ return NULL;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ if( &CGDataProviderCreateWithCFData != NULL )
+ {
+ return CGDataProviderCreateWithCFData( data );
+ }
+#endif
+
+ // make sure we keep it until done
+ CFRetain( data );
+ CGDataProviderRef provider = CGDataProviderCreateWithData( (void*) data , CFDataGetBytePtr( data ) ,
+ CFDataGetLength( data ), UMAReleaseCFDataProviderCallback );
+ // if provider couldn't be created, release the data again
+ if ( provider == NULL )
+ CFRelease( data );
+ return provider;
+}
+
+CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data )
+{
+ if ( data == NULL )
+ return NULL;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ if( &CGDataConsumerCreateWithCFData != NULL )
+ {
+ return CGDataConsumerCreateWithCFData( data );
+ }
+#endif
+ // make sure we keep it until done
+ CFRetain( data );
+ CGDataConsumerCallbacks callbacks;
+ callbacks.putBytes = UMAPutBytesCFRefCallback;
+ callbacks.releaseConsumer = UMAReleaseCFDataConsumerCallback;
+ CGDataConsumerRef consumer = CGDataConsumerCreate( data , &callbacks );
+ // if consumer couldn't be created, release the data again
+ if ( consumer == NULL )
+ CFRelease( data );
+ return consumer;
+}
#endif // wxUSE_GUI
#if wxUSE_BASE