]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/graphics.cpp
cleanup, fixing exports
[wxWidgets.git] / src / mac / carbon / graphics.cpp
index d0f3507011873c7a562df08936ca5fa547f01e09..2f284a1abacc5dbb49801589f6fa9af4106f9f41 100644 (file)
 
 #include "wx/mac/private.h"
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
-typedef float CGFloat;
-#endif
-
 //-----------------------------------------------------------------------------
 // constants
 //-----------------------------------------------------------------------------
@@ -66,8 +62,9 @@ OSStatus wxMacDrawCGImage(
 #ifdef __LP64__
     // todo flip
     CGContextDrawImage(inContext, *inBounds, inImage );
+    return noErr;
 #else
-    HIViewDrawCGImage( inContext, inBounds, inImage );
+    return HIViewDrawCGImage( inContext, inBounds, inImage );
 #endif
 }
 
@@ -708,6 +705,8 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
 {
     m_macATSUIStyle = NULL;
 
+#if wxMAC_USE_CORE_TEXT
+#elif wxMAC_USE_ATSU_TEXT
     OSStatus status;
 
     status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , &m_macATSUIStyle );
@@ -740,15 +739,21 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
         atsuTags, atsuSizes, atsuValues);
 
     wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
+#elif WXMAC_USE_CG_TEXT
+#endif
 }
 
 wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
 {
+#if wxMAC_USE_CORE_TEXT
+#elif wxMAC_USE_ATSU_TEXT
     if ( m_macATSUIStyle )
     {
         ::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle);
         m_macATSUIStyle = NULL;
     }
+#elif WXMAC_USE_CG_TEXT
+#endif
 }
 
 //
@@ -1320,9 +1325,12 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer
     int originX , originY;
     originX = originY = 0;
     window->MacWindowToRootWindow( &originX , &originY );
-    Rect bounds;
-    GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds );
 
+    Rect bounds = { 0,0,0,0 };
+#ifdef __LP64__
+#else
+    GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds );
+#endif
     m_windowTransform = CGAffineTransformMakeTranslation( 0 , bounds.bottom - bounds.top );
     m_windowTransform = CGAffineTransformScale( m_windowTransform , 1 , -1 );
     m_windowTransform = CGAffineTransformTranslate( m_windowTransform, originX, originY ) ;
@@ -1436,18 +1444,14 @@ void wxMacCoreGraphicsContext::Clip( const wxRegion &region )
 {
     if( m_cgContext )
     {
-        HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
-        HIShapeReplacePathInCGContext( shape, m_cgContext );
+        HIShapeReplacePathInCGContext( region.GetWXHRGN() , m_cgContext );
         CGContextClip( m_cgContext );
-        CFRelease( shape );
     }
     else
     {
         // this offsetting to device coords is not really correct, but since we cannot apply affine transforms
         // to regions we try at least to have correct translations
-        wxMacCFRefHolder<HIShapeRef> hishape ;
-        hishape.Set( HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
-        HIMutableShapeRef mutableShape = HIShapeCreateMutableCopy( hishape );
+        HIMutableShapeRef mutableShape = HIShapeCreateMutableCopy( region.GetWXHRGN() );
         
         CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero, m_windowTransform );
         HIShapeOffset( mutableShape, transformedOrigin.x, transformedOrigin.y );
@@ -1711,7 +1715,17 @@ void wxMacCoreGraphicsContext::PopState()
 
 void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y )
 {
+    if ( m_font.IsNull() )
+        return;
+    
+    EnsureIsValid();
+#if wxMAC_USE_CORE_TEXT
+    // TODO core text implementation here
+#elif wxMAC_USE_ATSU_TEXT
     DrawText(str, x, y, 0.0);
+#elif WXMAC_USE_CG_TEXT
+    // TODO core graphics text implementation here
+#endif
 }
 
 void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
@@ -1720,7 +1734,10 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
         return;
 
     EnsureIsValid();
-
+#if wxMAC_USE_CORE_TEXT
+    // default implementation takes care of rotation and calls non rotated DrawText afterwards
+    wxGraphicsContext::DrawText( str, x, y, angle );
+#elif wxMAC_USE_ATSU_TEXT
     OSStatus status = noErr;
     ATSUTextLayout atsuLayout;
     UniCharCount chars = str.length();
@@ -1826,6 +1843,10 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
 #if SIZEOF_WCHAR_T == 4
     free( ubuf );
 #endif
+#elif WXMAC_USE_CG_TEXT
+    // default implementation takes care of rotation and calls non rotated DrawText afterwards
+    wxGraphicsContext::DrawText( str, x, y, angle );
+#endif
 }
 
 void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height,
@@ -1845,6 +1866,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid
     if (str.empty())
         return;
 
+#if wxMAC_USE_CORE_TEXT
+    // TODO core text implementation here
+#elif wxMAC_USE_ATSU_TEXT
     OSStatus status = noErr;
 
     ATSUTextLayout atsuLayout;
@@ -1899,6 +1923,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid
 #if SIZEOF_WCHAR_T == 4
     free( ubuf ) ;
 #endif
+#elif WXMAC_USE_CG_TEXT
+    // TODO core graphics text implementation here
+#endif
 }
 
 void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const
@@ -1909,6 +1936,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr
     if (text.empty())
         return;
 
+#if wxMAC_USE_CORE_TEXT
+    // TODO core text implementation here
+#elif wxMAC_USE_ATSU_TEXT
     ATSUTextLayout atsuLayout;
     UniCharCount chars = text.length();
     UniChar* ubuf = NULL;
@@ -1960,6 +1990,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr
 #if SIZEOF_WCHAR_T == 4
     free( ubuf ) ;
 #endif
+#elif WXMAC_USE_CG_TEXT
+    // TODO core graphics text implementation here
+#endif
 }
 
 void * wxMacCoreGraphicsContext::GetNativeContext()