X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ecbbb06b3ba9b619ce9c3f493a5ce8e70a810989..47e175a24f862aa8b7ca7dd4a2bb5957991e7f2d:/src/osx/carbon/graphics.cpp diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 90a6d6446c..c42ffba7f7 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -147,27 +147,13 @@ OSStatus wxMacDrawCGImage( CGColorRef wxMacCreateCGColor( const wxColour& col ) { - CGColorRef retval = 0; -#ifdef __WXMAC__ - retval = col.CreateCGColor(); -#else -// TODO add conversion NSColor - CGColorRef (obj-c) -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( CGColorCreateGenericRGB ) - retval = CGColorCreateGenericRGB( col.Red() / 255.0 , col.Green() / 255.0, col.Blue() / 255.0, col.Alpha() / 255.0 ); - else -#endif - { - CGFloat components[4] = { col.Red() / 255.0, col.Green() / 255.0, col.Blue() / 255.0, col.Alpha() / 255.0 } ; - retval = CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ; - } + CGColorRef retval = col.CreateCGColor(); -#endif wxASSERT(retval != NULL); return retval; } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && wxOSX_USE_CORE_TEXT +#if wxOSX_USE_CORE_TEXT CTFontRef wxMacCreateCTFont( const wxFont& font ) { @@ -1500,7 +1486,7 @@ public: // fast convenience methods - virtual void DrawRectangleX( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); void SetNativeContext( CGContextRef cg ); @@ -1933,7 +1919,7 @@ bool wxMacCoreGraphicsContext::SetCompositionMode(wxCompositionMode op) mode = kCGBlendModeDestinationAtop; break; case wxCOMPOSITION_XOR: - mode = kCGBlendModeXOR; + mode = kCGBlendModeExclusion; // Not kCGBlendModeXOR! break; case wxCOMPOSITION_ADD: @@ -2285,11 +2271,11 @@ void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDoubl if (m_composition == wxCOMPOSITION_DEST) return; - CGRect r = CGRectMake( (CGFloat) 0.0 , (CGFloat) 0.0 , (CGFloat) w , (CGFloat) h ); CGContextSaveGState( m_cgContext ); CGContextTranslateCTM( m_cgContext,(CGFloat) x ,(CGFloat) (y + h) ); CGContextScaleCTM( m_cgContext, 1, -1 ); #if wxOSX_USE_COCOA_OR_CARBON + CGRect r = CGRectMake( (CGFloat) 0.0 , (CGFloat) 0.0 , (CGFloat) w , (CGFloat) h ); PlotIconRefInContext( m_cgContext , &r , kAlignNone , kTransformNone , NULL , kPlotIconRefNormalFlags , icon.GetHICON() ); #endif @@ -2720,11 +2706,21 @@ void * wxMacCoreGraphicsContext::GetNativeContext() } -void wxMacCoreGraphicsContext::DrawRectangleX( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) +void wxMacCoreGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) { + if (!EnsureIsValid()) + return; + if (m_composition == wxCOMPOSITION_DEST) return; + // when using shading, we have to go back to drawing paths + if ( !m_brush.IsNull() && ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() ) + { + wxGraphicsContext::DrawRectangle( x,y,w,h ); + return; + } + CGRect rect = CGRectMake( (CGFloat) x , (CGFloat) y , (CGFloat) w , (CGFloat) h ); if ( !m_brush.IsNull() ) {