X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69541a2ef15e87b85a14b9ff078cdb2310fbbf65..83e8b44cc0bf8a2a8f162c67162f9ed68accd15f:/src/mac/carbon/graphics.cpp?ds=inline diff --git a/src/mac/carbon/graphics.cpp b/src/mac/carbon/graphics.cpp index ec1da84e6b..3778c0d47c 100755 --- a/src/mac/carbon/graphics.cpp +++ b/src/mac/carbon/graphics.cpp @@ -795,15 +795,22 @@ void wxMacCoreGraphicsMatrixData::Invert() bool wxMacCoreGraphicsMatrixData::IsEqual( const wxGraphicsMatrixData* t) const { const CGAffineTransform* tm = (CGAffineTransform*) t->GetNativeMatrix(); - return ( - m_matrix.a == tm->a && - m_matrix.b == tm->b && - m_matrix.c == tm->c && - m_matrix.d == tm->d && - m_matrix.tx == tm->tx && - m_matrix.ty == tm->ty ) ; - - return CGAffineTransformEqualToTransform(m_matrix, *((CGAffineTransform*) t->GetNativeMatrix())); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if ( CGAffineTransformEqualToTransform!=NULL ) + { + return CGAffineTransformEqualToTransform(m_matrix, *((CGAffineTransform*) t->GetNativeMatrix())); + } + else +#endif + { + return ( + m_matrix.a == tm->a && + m_matrix.b == tm->b && + m_matrix.c == tm->c && + m_matrix.d == tm->d && + m_matrix.tx == tm->tx && + m_matrix.ty == tm->ty ) ; + } } // return true if this is the identity matrix @@ -1042,7 +1049,18 @@ void wxMacCoreGraphicsPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wx bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, int fillStyle) const { - return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE ); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if ( CGPathContainsPoint!=NULL ) + { + return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE ); + } + else +#endif + { + // TODO : implementation for 10.3 + CGRect bounds = CGPathGetBoundingBox( m_path ) ; + return CGRectContainsPoint( bounds, CGPointMake(x,y) ) == 1; + } } // @@ -1294,8 +1312,15 @@ void wxMacCoreGraphicsContext::ResetClip() { if ( m_cgContext ) { + // there is no way for clearing the clip, we can only revert to the stored + // state, but then we have to make sure everything else is NOT restored + CGAffineTransform transform = CGContextGetCTM( m_cgContext ); CGContextRestoreGState( m_cgContext ); CGContextSaveGState( m_cgContext ); + CGAffineTransform transformNew = CGContextGetCTM( m_cgContext ); + transformNew = CGAffineTransformInvert( transformNew ) ; + CGContextConcatCTM( m_cgContext, transformNew); + CGContextConcatCTM( m_cgContext, transform); } else { @@ -1469,7 +1494,33 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDo 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 ); } @@ -1818,6 +1869,8 @@ public : virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ); virtual wxGraphicsContext * CreateContext( wxWindow* window ); + + virtual wxGraphicsContext * CreateMeasuringContext(); // Path @@ -1883,6 +1936,11 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( wxWindow* window ) return new wxMacCoreGraphicsContext(this, window ); } +wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateMeasuringContext() +{ + return new wxMacCoreGraphicsContext(this); +} + // Path wxGraphicsPath wxMacCoreGraphicsRenderer::CreatePath()