X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a01d9a255c8887521b4d47c15b6637bf38c4b688..79b7b95aed76eb742deef93d046886c20452fb36:/src/mac/carbon/graphics.cpp diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index 0f7889d7a9..c0ea9f714b 100644 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -35,10 +35,6 @@ #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 } @@ -117,7 +114,7 @@ public : { wxASSERT( bmp && bmp->Ok() ); - Init( (CGImageRef) bmp->CGImageCreate() , transform ); + Init( (CGImageRef) bmp->CreateCGImage() , transform ); } // ImagePattern takes ownership of CGImageRef passed in @@ -708,6 +705,8 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere { m_macATSUIStyle = NULL; +#ifdef wxMAC_USE_CORE_TEXT +#elif defined(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 defined(WXMAC_USE_CG_TEXT) +#endif } wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData() { +#ifdef wxMAC_USE_CORE_TEXT +#elif defined(wxMAC_USE_ATSU_TEXT) if ( m_macATSUIStyle ) { ::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle); m_macATSUIStyle = NULL; } +#elif defined(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 ) ; @@ -1650,7 +1658,7 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDo { EnsureIsValid(); - CGImageRef image = (CGImageRef)( bmp.CGImageCreate() ); + CGImageRef image = (CGImageRef)( bmp.CreateCGImage() ); HIRect r = CGRectMake( x , y , w , h ); if ( bmp.GetDepth() == 1 ) { @@ -1711,7 +1719,17 @@ void wxMacCoreGraphicsContext::PopState() void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) { + if ( m_font.IsNull() ) + return; + + EnsureIsValid(); +#ifdef wxMAC_USE_CORE_TEXT + // TODO core text implementation here +#elif defined(wxMAC_USE_ATSU_TEXT) DrawText(str, x, y, 0.0); +#elif defined(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 +1738,10 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub return; EnsureIsValid(); - +#ifdef wxMAC_USE_CORE_TEXT + // default implementation takes care of rotation and calls non rotated DrawText afterwards + wxGraphicsContext::DrawText( str, x, y, angle ); +#elif defined(wxMAC_USE_ATSU_TEXT) OSStatus status = noErr; ATSUTextLayout atsuLayout; UniCharCount chars = str.length(); @@ -1826,6 +1847,10 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub #if SIZEOF_WCHAR_T == 4 free( ubuf ); #endif +#elif defined(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 +1870,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid if (str.empty()) return; +#ifdef wxMAC_USE_CORE_TEXT + // TODO core text implementation here +#elif defined(wxMAC_USE_ATSU_TEXT) OSStatus status = noErr; ATSUTextLayout atsuLayout; @@ -1899,6 +1927,9 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid #if SIZEOF_WCHAR_T == 4 free( ubuf ) ; #endif +#elif defined(WXMAC_USE_CG_TEXT) + // TODO core graphics text implementation here +#endif } void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const @@ -1909,6 +1940,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr if (text.empty()) return; +#ifdef wxMAC_USE_CORE_TEXT + // TODO core text implementation here +#elif defined(wxMAC_USE_ATSU_TEXT) ATSUTextLayout atsuLayout; UniCharCount chars = text.length(); UniChar* ubuf = NULL; @@ -1960,6 +1994,9 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr #if SIZEOF_WCHAR_T == 4 free( ubuf ) ; #endif +#elif defined(WXMAC_USE_CG_TEXT) + // TODO core graphics text implementation here +#endif } void * wxMacCoreGraphicsContext::GetNativeContext()