if ( bmp && bmp->Ok() )
{
m_colorSpace.Set( CGColorSpaceCreatePattern( NULL ) );
- m_pattern.Set( *( new ImagePattern( bmp , CGAffineTransformMakeTranslation( 0,0 ) ) ) );
+ m_pattern.Set( *( new ImagePattern( bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) );
m_patternColorComponents = new CGFloat[1] ;
m_patternColorComponents[0] = 1.0;
m_isPattern = true;
{
m_isPattern = true;
m_colorSpace.Set( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
- m_pattern.Set( *( new HatchPattern( pen.GetStyle() , CGAffineTransformMakeTranslation( 0,0 ) ) ) );
+ m_pattern.Set( *( new HatchPattern( pen.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
m_patternColorComponents = new CGFloat[4] ;
m_patternColorComponents[0] = pen.GetColour().Red() / 255.0;
m_patternColorComponents[1] = pen.GetColour().Green() / 255.0;
if ( m_isPattern )
{
+ CGAffineTransform matrix = CGContextGetCTM( cg );
+ CGContextSetPatternPhase( cg, CGSizeMake(matrix.tx, matrix.ty) );
CGContextSetStrokeColorSpace( cg , m_colorSpace );
CGContextSetStrokePattern( cg, m_pattern , m_patternColorComponents );
}
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_isPattern = true;
m_colorSpace.Set( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
- m_pattern.Set( *( new HatchPattern( brush.GetStyle() , CGAffineTransformMakeTranslation( 0,0 ) ) ) );
+ m_pattern.Set( *( new HatchPattern( brush.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
m_patternColorComponents = new CGFloat[4] ;
m_patternColorComponents[0] = brush.GetColour().Red() / 255.0;
m_patternColorComponents = new CGFloat[1] ;
m_patternColorComponents[0] = 1.0;
m_colorSpace.Set( CGColorSpaceCreatePattern( NULL ) );
- m_pattern.Set( *( new ImagePattern( bmp , CGAffineTransformMakeTranslation( 0,0 ) ) ) );
+ m_pattern.Set( *( new ImagePattern( bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) );
}
}
}
if ( m_isShading )
{
+ // nothing to set as shades are processed by clipping using the path and filling
}
else
{
if ( m_isPattern )
{
+ CGAffineTransform matrix = CGContextGetCTM( cg );
+ CGContextSetPatternPhase( cg, CGSizeMake(matrix.tx, matrix.ty) );
CGContextSetFillColorSpace( cg , m_colorSpace );
CGContextSetFillPattern( cg, m_pattern , m_patternColorComponents );
}
{
const CGAffineTransform* tm = (CGAffineTransform*) t->GetNativeMatrix();
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- if ( CGAffineTransformEqualToTransform )
+ if ( CGAffineTransformEqualToTransform!=NULL )
{
return CGAffineTransformEqualToTransform(m_matrix, *((CGAffineTransform*) t->GetNativeMatrix()));
}
bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, int fillStyle) const
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- if ( CGPathContainsPoint )
+ if ( CGPathContainsPoint!=NULL )
{
return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE );
}
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));
}
}
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
Rect rect;
-/*
- // TODO
- if ( m_backgroundMode == wxSOLID )
- {
- wxGraphicsPath* path = m_graphicContext->CreatePath();
- path->MoveToPoint( drawX , drawY );
- path->AddLineToPoint(
- (int) (drawX + sin(angle / RAD2DEG) * FixedToInt(ascent + descent)) ,
- (int) (drawY + cos(angle / RAD2DEG) * FixedToInt(ascent + descent)) );
- path->AddLineToPoint(
- (int) (drawX + sin(angle / RAD2DEG) * FixedToInt(ascent + descent ) + cos(angle / RAD2DEG) * FixedToInt(textAfter)) ,
- (int) (drawY + cos(angle / RAD2DEG) * FixedToInt(ascent + descent) - sin(angle / RAD2DEG) * FixedToInt(textAfter)) );
- path->AddLineToPoint(
- (int) (drawX + cos(angle / RAD2DEG) * FixedToInt(textAfter)) ,
- (int) (drawY - sin(angle / RAD2DEG) * FixedToInt(textAfter)) );
-
- m_graphicContext->FillPath( path , m_textBackgroundColour );
- delete path;
- }
-*/
- x += (int)(sin(angle / RAD2DEG) * FixedToInt(ascent));
- y += (int)(cos(angle / RAD2DEG) * FixedToInt(ascent));
+ x += (int)(sin(angle) * FixedToInt(ascent));
+ y += (int)(cos(angle) * FixedToInt(ascent));
status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
IntToFixed(x) , IntToFixed(y) , &rect );
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
virtual wxGraphicsContext * CreateContext( wxWindow* window );
+
+ virtual wxGraphicsContext * CreateMeasuringContext();
// Path
return new wxMacCoreGraphicsContext(this, window );
}
+wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateMeasuringContext()
+{
+ return new wxMacCoreGraphicsContext(this);
+}
+
// Path
wxGraphicsPath wxMacCoreGraphicsRenderer::CreatePath()