if ( brush.GetStyle() == wxSOLID )
{
- float components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
+ if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ if ( HIThemeBrushCreateCGColor != 0 )
+ {
+ CGColorRef color ;
+ HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
+ m_color.Set( color ) ;
+ }
+ else
+#endif
+ {
+ // as close as we can get, unfortunately < 10.4 things get difficult
+ RGBColor color;
+ GetThemeBrushAsColor( brush.MacGetTheme(), 32, true, &color );
+ float components[4] = { (CGFloat) color.red / 65536,
+ (CGFloat) color.green / 65536, (CGFloat) color.blue / 65536, 1 } ;
+ m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
+ }
+ }
+ else
+ {
+ float 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( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
+ }
}
else if ( brush.IsHatch() )
{
m_releaseContext = true;
if ( !HIShapeIsEmpty(m_clipRgn) )
{
- HIShapeReplacePathInCGContext( m_clipRgn, m_cgContext );
+ // the clip region is in device coordinates, so we convert this again to user coordinates
+ wxMacCFRefHolder<HIMutableShapeRef> hishape ;
+ hishape.Set( HIShapeCreateMutableCopy( m_clipRgn ) );
+ CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero,m_windowTransform);
+ HIShapeOffset( hishape, -transformedOrigin.x, -transformedOrigin.y );
+ HIShapeReplacePathInCGContext( hishape, m_cgContext );
CGContextClip( m_cgContext );
}
CGContextSaveGState( m_cgContext );
}
else
{
- m_clipRgn.Set(HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
+ // 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 );
+
+ CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero, m_windowTransform );
+ HIShapeOffset( mutableShape, transformedOrigin.x, transformedOrigin.y );
+ m_clipRgn.Set(mutableShape);
}
}
}
else
{
+ // the clipping itself must be stored as device coordinates, otherwise
+ // we cannot apply it back correctly
+ r.origin= CGPointApplyAffineTransform( r.origin, m_windowTransform );
m_clipRgn.Set(HIShapeCreateWithRect(&r));
}
}