]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/graphics.cpp
mac cleanup
[wxWidgets.git] / src / mac / carbon / graphics.cpp
index 78992a2f28eab10f9aa156682de138a21012bfe2..d0f3507011873c7a562df08936ca5fa547f01e09 100644 (file)
@@ -117,7 +117,7 @@ public :
     {
         wxASSERT( bmp && bmp->Ok() );
 
     {
         wxASSERT( bmp && bmp->Ok() );
 
-        Init( (CGImageRef) bmp->CGImageCreate() , transform );
+        Init( (CGImageRef) bmp->CreateCGImage() , transform );
     }
 
     // ImagePattern takes ownership of CGImageRef passed in
     }
 
     // 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 ) ;
 
 
 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<CGColorRef> m_color;
+        wxMacCFRefHolder<CGColorSpaceRef> m_colorSpace;
+        
+        bool m_isPattern;
+        wxMacCFRefHolder<CGPatternRef> m_pattern;
+        CGFloat* m_patternColorComponents;
+} ;
+
 wxMacCoreGraphicsColour::~wxMacCoreGraphicsColour()
 {
     delete[] m_patternColorComponents;
 wxMacCoreGraphicsColour::~wxMacCoreGraphicsColour()
 {
     delete[] m_patternColorComponents;
@@ -519,18 +539,7 @@ wxMacCoreGraphicsColour::wxMacCoreGraphicsColour( const wxBrush &brush )
     Init();
     if ( brush.GetStyle() == wxSOLID )
     {
     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() )
     {
     }
     else if ( brush.IsHatch() )
     {
@@ -1641,7 +1650,7 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDo
 {
     EnsureIsValid();
 
 {
     EnsureIsValid();
 
-    CGImageRef image = (CGImageRef)( bmp.CGImageCreate() );
+    CGImageRef image = (CGImageRef)( bmp.CreateCGImage() );
     HIRect r = CGRectMake( x , y , w , h );
     if ( bmp.GetDepth() == 1 )
     {
     HIRect r = CGRectMake( x , y , w , h );
     if ( bmp.GetDepth() == 1 )
     {