CGColorRef wxMacCreateCGColor( const wxColour& col )
{
- CGColorRef retval = 0;
-#ifdef __WXMAC__
- retval = col.CreateCGColor();
-#else
-// TODO add conversion NSColor - CGColorRef (obj-c)
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- if ( CGColorCreateGenericRGB )
- retval = CGColorCreateGenericRGB( col.Red() / 255.0 , col.Green() / 255.0, col.Blue() / 255.0, col.Alpha() / 255.0 );
- else
-#endif
- {
- CGFloat components[4] = { col.Red() / 255.0, col.Green() / 255.0, col.Blue() / 255.0, col.Alpha() / 255.0 } ;
- retval = CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ;
- }
+ CGColorRef retval = col.CreateCGColor();
-#endif
wxASSERT(retval != NULL);
return retval;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 && wxOSX_USE_CORE_TEXT
+#if wxOSX_USE_CORE_TEXT
CTFontRef wxMacCreateCTFont( const wxFont& font )
{
// fast convenience methods
- virtual void DrawRectangleX( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
+ virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
void SetNativeContext( CGContextRef cg );
mode = kCGBlendModeDestinationAtop;
break;
case wxCOMPOSITION_XOR:
- mode = kCGBlendModeXOR;
+ mode = kCGBlendModeExclusion; // Not kCGBlendModeXOR!
break;
case wxCOMPOSITION_ADD:
if (m_composition == wxCOMPOSITION_DEST)
return;
- CGRect r = CGRectMake( (CGFloat) 0.0 , (CGFloat) 0.0 , (CGFloat) w , (CGFloat) h );
CGContextSaveGState( m_cgContext );
CGContextTranslateCTM( m_cgContext,(CGFloat) x ,(CGFloat) (y + h) );
CGContextScaleCTM( m_cgContext, 1, -1 );
#if wxOSX_USE_COCOA_OR_CARBON
+ CGRect r = CGRectMake( (CGFloat) 0.0 , (CGFloat) 0.0 , (CGFloat) w , (CGFloat) h );
PlotIconRefInContext( m_cgContext , &r , kAlignNone , kTransformNone ,
NULL , kPlotIconRefNormalFlags , icon.GetHICON() );
#endif
return;
#if wxOSX_USE_CORE_TEXT
- if ( UMAGetSystemVersion() >= 0x1050 )
{
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
wxCFStringRef text(str, wxLocale::GetSystemEncoding() );
return;
#if wxOSX_USE_CORE_TEXT
- if ( UMAGetSystemVersion() >= 0x1050 )
{
// default implementation takes care of rotation and calls non rotated DrawText afterwards
wxGraphicsContext::DoDrawRotatedText( str, x, y, angle );
return;
#if wxOSX_USE_CORE_TEXT
- if ( UMAGetSystemVersion() >= 0x1050 )
{
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
CTFontRef font = fref->OSXGetCTFont();
}
-void wxMacCoreGraphicsContext::DrawRectangleX( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+void wxMacCoreGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
+ if (!EnsureIsValid())
+ return;
+
if (m_composition == wxCOMPOSITION_DEST)
return;
+ // when using shading, we have to go back to drawing paths
+ if ( !m_brush.IsNull() && ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() )
+ {
+ wxGraphicsContext::DrawRectangle( x,y,w,h );
+ return;
+ }
+
CGRect rect = CGRectMake( (CGFloat) x , (CGFloat) y , (CGFloat) w , (CGFloat) h );
if ( !m_brush.IsNull() )
{