X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/276ee5334d28762520abad9653d51f8e81812ebc..50b8a33651e5571899bfab5f72ea56cb18954def:/src/mac/carbon/graphics.cpp diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index 78992a2f28..d0f3507011 100644 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -117,7 +117,7 @@ public : { wxASSERT( bmp && bmp->Ok() ); - Init( (CGImageRef) bmp->CGImageCreate() , transform ); + Init( (CGImageRef) bmp->CreateCGImage() , transform ); } // ImagePattern takes ownership of CGImageRef passed in @@ -483,6 +483,26 @@ static const char *gs_stripedback_xpm[] = { wxBitmap gs_stripedback_bmp( wxImage( (const char* const* ) gs_stripedback_xpm ), -1 ) ; +// make sure we all use one class for all conversions from wx to native colour + +class wxMacCoreGraphicsColour +{ + public: + wxMacCoreGraphicsColour(); + wxMacCoreGraphicsColour(const wxBrush &brush); + ~wxMacCoreGraphicsColour(); + + void Apply( CGContextRef cgContext ); + protected: + void Init(); + wxMacCFRefHolder m_color; + wxMacCFRefHolder m_colorSpace; + + bool m_isPattern; + wxMacCFRefHolder m_pattern; + CGFloat* m_patternColorComponents; +} ; + wxMacCoreGraphicsColour::~wxMacCoreGraphicsColour() { delete[] m_patternColorComponents; @@ -519,18 +539,7 @@ wxMacCoreGraphicsColour::wxMacCoreGraphicsColour( const wxBrush &brush ) Init(); if ( brush.GetStyle() == wxSOLID ) { - if ( brush.MacGetBrushKind() == kwxMacBrushTheme ) - { - CGColorRef color ; - HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color ); - m_color.Set( color ) ; - } - else - { - CGFloat components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 , - brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ; - m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ; - } + m_color.Set( brush.GetColour().CreateCGColor() ); } else if ( brush.IsHatch() ) { @@ -1641,7 +1650,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 ) {