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 );
}
{
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 );
}
CGImageRef image = (CGImageRef)( bmp.CGImageCreate() );
HIRect r = CGRectMake( x , y , w , h );
- HIViewDrawCGImage( m_cgContext , &r , image );
+ if ( bmp.GetDepth() == 1 )
+ {
+ // is is a mask, the '1' in the mask tell where to draw the current brush
+ if ( !m_brush.IsNull() )
+ {
+ if ( ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() )
+ {
+ // TODO clip to mask
+ /*
+ CGContextSaveGState( m_cgContext );
+ CGContextAddPath( m_cgContext , (CGPathRef) path.GetNativePath() );
+ CGContextClip( m_cgContext );
+ CGContextDrawShading( m_cgContext, ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->GetShading() );
+ CGContextRestoreGState( m_cgContext);
+ */
+ }
+ else
+ {
+ ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this);
+ HIViewDrawCGImage( m_cgContext , &r , image );
+ }
+ }
+ }
+ else
+ {
+ HIViewDrawCGImage( m_cgContext , &r , image );
+ }
CGImageRelease( image );
}
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()