1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/dccg.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #if wxUSE_GRAPHICS_CONTEXT && wxMAC_USE_CORE_GRAPHICS
16 #include "wx/graphics.h"
19 #include "wx/dcclient.h"
21 #include "wx/region.h"
24 #include "wx/mac/uma.h"
29 // in case our functions were defined outside std, we make it known all the same
35 #include "wx/mac/private.h"
37 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
38 typedef float CGFloat
;
40 #ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
41 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
42 #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 1
44 #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
48 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
52 #if !defined( __DARWIN__ ) || defined(__MWERKS__)
54 const double M_PI
= 3.14159265358979;
58 static const double RAD2DEG
= 180.0 / M_PI
;
61 // Pen, Brushes and Fonts
65 #pragma mark wxMacCoreGraphicsPattern, ImagePattern, HatchPattern classes
67 // CGPattern wrapper class: always allocate on heap, never call destructor
69 class wxMacCoreGraphicsPattern
72 wxMacCoreGraphicsPattern() {}
74 // is guaranteed to be called only with a non-Null CGContextRef
75 virtual void Render( CGContextRef ctxRef
) = 0;
77 operator CGPatternRef() const { return m_patternRef
; }
80 virtual ~wxMacCoreGraphicsPattern()
82 // as this is called only when the m_patternRef is been released;
83 // don't release it again
86 static void _Render( void *info
, CGContextRef ctxRef
)
88 wxMacCoreGraphicsPattern
* self
= (wxMacCoreGraphicsPattern
*) info
;
90 self
->Render( ctxRef
);
93 static void _Dispose( void *info
)
95 wxMacCoreGraphicsPattern
* self
= (wxMacCoreGraphicsPattern
*) info
;
99 CGPatternRef m_patternRef
;
101 static const CGPatternCallbacks ms_Callbacks
;
104 const CGPatternCallbacks
wxMacCoreGraphicsPattern::ms_Callbacks
= { 0, &wxMacCoreGraphicsPattern::_Render
, &wxMacCoreGraphicsPattern::_Dispose
};
106 class ImagePattern
: public wxMacCoreGraphicsPattern
109 ImagePattern( const wxBitmap
* bmp
, const CGAffineTransform
& transform
)
111 wxASSERT( bmp
&& bmp
->Ok() );
113 Init( (CGImageRef
) bmp
->CGImageCreate() , transform
);
116 // ImagePattern takes ownership of CGImageRef passed in
117 ImagePattern( CGImageRef image
, const CGAffineTransform
& transform
)
122 Init( image
, transform
);
125 virtual void Render( CGContextRef ctxRef
)
128 HIViewDrawCGImage( ctxRef
, &m_imageBounds
, m_image
);
132 void Init( CGImageRef image
, const CGAffineTransform
& transform
)
137 m_imageBounds
= CGRectMake( 0.0, 0.0, (CGFloat
)CGImageGetWidth( m_image
), (CGFloat
)CGImageGetHeight( m_image
) );
138 m_patternRef
= CGPatternCreate(
139 this , m_imageBounds
, transform
,
140 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
141 kCGPatternTilingNoDistortion
, true , &wxMacCoreGraphicsPattern::ms_Callbacks
);
145 virtual ~ImagePattern()
148 CGImageRelease( m_image
);
152 CGRect m_imageBounds
;
155 class HatchPattern
: public wxMacCoreGraphicsPattern
158 HatchPattern( int hatchstyle
, const CGAffineTransform
& transform
)
160 m_hatch
= hatchstyle
;
161 m_imageBounds
= CGRectMake( 0.0, 0.0, 8.0 , 8.0 );
162 m_patternRef
= CGPatternCreate(
163 this , m_imageBounds
, transform
,
164 m_imageBounds
.size
.width
, m_imageBounds
.size
.height
,
165 kCGPatternTilingNoDistortion
, false , &wxMacCoreGraphicsPattern::ms_Callbacks
);
168 void StrokeLineSegments( CGContextRef ctxRef
, const CGPoint pts
[] , size_t count
)
170 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
171 if ( CGContextStrokeLineSegments
!=NULL
)
173 CGContextStrokeLineSegments( ctxRef
, pts
, count
);
178 CGContextBeginPath( ctxRef
);
179 for (size_t i
= 0; i
< count
; i
+= 2)
181 CGContextMoveToPoint(ctxRef
, pts
[i
].x
, pts
[i
].y
);
182 CGContextAddLineToPoint(ctxRef
, pts
[i
+1].x
, pts
[i
+1].y
);
184 CGContextStrokePath(ctxRef
);
188 virtual void Render( CGContextRef ctxRef
)
192 case wxBDIAGONAL_HATCH
:
196 { 8.0 , 0.0 } , { 0.0 , 8.0 }
198 StrokeLineSegments( ctxRef
, pts
, 2 );
202 case wxCROSSDIAG_HATCH
:
206 { 0.0 , 0.0 } , { 8.0 , 8.0 } ,
207 { 8.0 , 0.0 } , { 0.0 , 8.0 }
209 StrokeLineSegments( ctxRef
, pts
, 4 );
213 case wxFDIAGONAL_HATCH
:
217 { 0.0 , 0.0 } , { 8.0 , 8.0 }
219 StrokeLineSegments( ctxRef
, pts
, 2 );
227 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
228 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
230 StrokeLineSegments( ctxRef
, pts
, 4 );
234 case wxHORIZONTAL_HATCH
:
238 { 0.0 , 4.0 } , { 8.0 , 4.0 } ,
240 StrokeLineSegments( ctxRef
, pts
, 2 );
244 case wxVERTICAL_HATCH
:
248 { 4.0 , 0.0 } , { 4.0 , 8.0 } ,
250 StrokeLineSegments( ctxRef
, pts
, 2 );
260 virtual ~HatchPattern() {}
262 CGRect m_imageBounds
;
266 class wxMacCoreGraphicsPenData
: public wxGraphicsObjectRefData
269 wxMacCoreGraphicsPenData( wxGraphicsRenderer
* renderer
, const wxPen
&pen
);
270 ~wxMacCoreGraphicsPenData();
273 virtual void Apply( wxGraphicsContext
* context
);
274 virtual wxDouble
GetWidth() { return m_width
; }
278 wxMacCFRefHolder
<CGColorRef
> m_color
;
279 wxMacCFRefHolder
<CGColorSpaceRef
> m_colorSpace
;
285 const CGFloat
*m_lengths
;
286 CGFloat
*m_userLengths
;
290 wxMacCFRefHolder
<CGPatternRef
> m_pattern
;
291 CGFloat
* m_patternColorComponents
;
294 wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer
* renderer
, const wxPen
&pen
) :
295 wxGraphicsObjectRefData( renderer
)
299 float components
[4] = { pen
.GetColour().Red() / 255.0 , pen
.GetColour().Green() / 255.0 ,
300 pen
.GetColour().Blue() / 255.0 , pen
.GetColour().Alpha() / 255.0 } ;
301 m_color
.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components
) ) ;
303 // TODO: * m_dc->m_scaleX
304 m_width
= pen
.GetWidth();
308 switch ( pen
.GetCap() )
311 m_cap
= kCGLineCapRound
;
314 case wxCAP_PROJECTING
:
315 m_cap
= kCGLineCapSquare
;
319 m_cap
= kCGLineCapButt
;
323 m_cap
= kCGLineCapButt
;
327 switch ( pen
.GetJoin() )
330 m_join
= kCGLineJoinBevel
;
334 m_join
= kCGLineJoinMiter
;
338 m_join
= kCGLineJoinRound
;
342 m_join
= kCGLineJoinMiter
;
346 const CGFloat dashUnit
= m_width
< 1.0 ? 1.0 : m_width
;
348 const CGFloat dotted
[] = { dashUnit
, dashUnit
+ 2.0 };
349 static const CGFloat short_dashed
[] = { 9.0 , 6.0 };
350 static const CGFloat dashed
[] = { 19.0 , 9.0 };
351 static const CGFloat dotted_dashed
[] = { 9.0 , 6.0 , 3.0 , 3.0 };
353 switch ( pen
.GetStyle() )
359 m_count
= WXSIZEOF(dotted
);
360 m_userLengths
= new CGFloat
[ m_count
] ;
361 memcpy( m_userLengths
, dotted
, sizeof(dotted
) );
362 m_lengths
= m_userLengths
;
366 m_count
= WXSIZEOF(dashed
);
371 m_count
= WXSIZEOF(short_dashed
);
372 m_lengths
= short_dashed
;
376 m_count
= WXSIZEOF(dotted_dashed
);
377 m_lengths
= dotted_dashed
;
382 m_count
= pen
.GetDashes( &dashes
);
383 if ((dashes
!= NULL
) && (m_count
> 0))
385 m_userLengths
= new CGFloat
[m_count
];
386 for ( int i
= 0; i
< m_count
; ++i
)
388 m_userLengths
[i
] = dashes
[i
] * dashUnit
;
390 if ( i
% 2 == 1 && m_userLengths
[i
] < dashUnit
+ 2.0 )
391 m_userLengths
[i
] = dashUnit
+ 2.0;
392 else if ( i
% 2 == 0 && m_userLengths
[i
] < dashUnit
)
393 m_userLengths
[i
] = dashUnit
;
396 m_lengths
= m_userLengths
;
401 wxBitmap
* bmp
= pen
.GetStipple();
402 if ( bmp
&& bmp
->Ok() )
404 m_colorSpace
.Set( CGColorSpaceCreatePattern( NULL
) );
405 m_pattern
.Set( *( new ImagePattern( bmp
, CGAffineTransformMakeScale( 1,-1 ) ) ) );
406 m_patternColorComponents
= new CGFloat
[1] ;
407 m_patternColorComponents
[0] = 1.0;
416 m_colorSpace
.Set( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
417 m_pattern
.Set( *( new HatchPattern( pen
.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
418 m_patternColorComponents
= new CGFloat
[4] ;
419 m_patternColorComponents
[0] = pen
.GetColour().Red() / 255.0;
420 m_patternColorComponents
[1] = pen
.GetColour().Green() / 255.0;
421 m_patternColorComponents
[2] = pen
.GetColour().Blue() / 255.0;
422 m_patternColorComponents
[3] = pen
.GetColour().Alpha() / 255.0;
426 if ((m_lengths
!= NULL
) && (m_count
> 0))
428 // force the line cap, otherwise we get artifacts (overlaps) and just solid lines
429 m_cap
= kCGLineCapButt
;
433 wxMacCoreGraphicsPenData::~wxMacCoreGraphicsPenData()
435 delete[] m_userLengths
;
436 delete[] m_patternColorComponents
;
439 void wxMacCoreGraphicsPenData::Init()
442 m_userLengths
= NULL
;
445 m_patternColorComponents
= NULL
;
449 void wxMacCoreGraphicsPenData::Apply( wxGraphicsContext
* context
)
451 CGContextRef cg
= (CGContextRef
) context
->GetNativeContext();
452 CGContextSetLineWidth( cg
, m_width
);
453 CGContextSetLineJoin( cg
, m_join
);
455 CGContextSetLineDash( cg
, 0 , m_lengths
, m_count
);
456 CGContextSetLineCap( cg
, m_cap
);
460 CGAffineTransform matrix
= CGContextGetCTM( cg
);
461 CGContextSetPatternPhase( cg
, CGSizeMake(matrix
.tx
, matrix
.ty
) );
462 CGContextSetStrokeColorSpace( cg
, m_colorSpace
);
463 CGContextSetStrokePattern( cg
, m_pattern
, m_patternColorComponents
);
467 if ( context
->GetLogicalFunction() == wxINVERT
|| context
->GetLogicalFunction() == wxXOR
)
469 CGContextSetRGBStrokeColor( cg
, 1.0, 1.0 , 1.0, 1.0 );
472 CGContextSetStrokeColorWithColor( cg
, m_color
);
480 class wxMacCoreGraphicsBrushData
: public wxGraphicsObjectRefData
483 wxMacCoreGraphicsBrushData( wxGraphicsRenderer
* renderer
);
484 wxMacCoreGraphicsBrushData( wxGraphicsRenderer
* renderer
, const wxBrush
&brush
);
485 ~wxMacCoreGraphicsBrushData ();
487 virtual void Apply( wxGraphicsContext
* context
);
488 void CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
489 const wxColour
&c1
, const wxColour
&c2
);
490 void CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
491 const wxColour
&oColor
, const wxColour
&cColor
);
493 virtual bool IsShading() { return m_isShading
; }
494 CGShadingRef
GetShading() { return m_shading
; }
496 CGFunctionRef
CreateGradientFunction( const wxColour
& c1
, const wxColour
& c2
);
497 static void CalculateShadingValues (void *info
, const CGFloat
*in
, CGFloat
*out
);
500 wxMacCFRefHolder
<CGColorRef
> m_color
;
501 wxMacCFRefHolder
<CGColorSpaceRef
> m_colorSpace
;
504 wxMacCFRefHolder
<CGPatternRef
> m_pattern
;
505 CGFloat
* m_patternColorComponents
;
508 CGFunctionRef m_gradientFunction
;
509 CGShadingRef m_shading
;
510 CGFloat
*m_gradientComponents
;
513 wxMacCoreGraphicsBrushData::wxMacCoreGraphicsBrushData( wxGraphicsRenderer
* renderer
) : wxGraphicsObjectRefData( renderer
)
518 void wxMacCoreGraphicsBrushData::CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
519 const wxColour
&c1
, const wxColour
&c2
)
521 m_gradientFunction
= CreateGradientFunction( c1
, c2
);
522 m_shading
= CGShadingCreateAxial( wxMacGetGenericRGBColorSpace(), CGPointMake(x1
,y1
), CGPointMake(x2
,y2
), m_gradientFunction
, true, true ) ;
526 void wxMacCoreGraphicsBrushData::CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
527 const wxColour
&oColor
, const wxColour
&cColor
)
529 m_gradientFunction
= CreateGradientFunction( oColor
, cColor
);
530 m_shading
= CGShadingCreateRadial( wxMacGetGenericRGBColorSpace(), CGPointMake(xo
,yo
), 0, CGPointMake(xc
,yc
), radius
, m_gradientFunction
, true, true ) ;
534 wxMacCoreGraphicsBrushData::wxMacCoreGraphicsBrushData(wxGraphicsRenderer
* renderer
, const wxBrush
&brush
) : wxGraphicsObjectRefData( renderer
)
538 if ( brush
.GetStyle() == wxSOLID
)
540 if ( brush
.MacGetBrushKind() == kwxMacBrushTheme
)
542 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
543 if ( HIThemeBrushCreateCGColor
!= 0 )
546 HIThemeBrushCreateCGColor( brush
.MacGetTheme(), &color
);
547 m_color
.Set( color
) ;
552 // as close as we can get, unfortunately < 10.4 things get difficult
554 GetThemeBrushAsColor( brush
.MacGetTheme(), 32, true, &color
);
555 float components
[4] = { (CGFloat
) color
.red
/ 65536,
556 (CGFloat
) color
.green
/ 65536, (CGFloat
) color
.blue
/ 65536, 1 } ;
557 m_color
.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components
) ) ;
562 float components
[4] = { brush
.GetColour().Red() / 255.0 , brush
.GetColour().Green() / 255.0 ,
563 brush
.GetColour().Blue() / 255.0 , brush
.GetColour().Alpha() / 255.0 } ;
564 m_color
.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components
) ) ;
567 else if ( brush
.IsHatch() )
570 m_colorSpace
.Set( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
571 m_pattern
.Set( *( new HatchPattern( brush
.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
573 m_patternColorComponents
= new CGFloat
[4] ;
574 m_patternColorComponents
[0] = brush
.GetColour().Red() / 255.0;
575 m_patternColorComponents
[1] = brush
.GetColour().Green() / 255.0;
576 m_patternColorComponents
[2] = brush
.GetColour().Blue() / 255.0;
577 m_patternColorComponents
[3] = brush
.GetColour().Alpha() / 255.0;
581 // now brush is a bitmap
582 wxBitmap
* bmp
= brush
.GetStipple();
583 if ( bmp
&& bmp
->Ok() )
586 m_patternColorComponents
= new CGFloat
[1] ;
587 m_patternColorComponents
[0] = 1.0;
588 m_colorSpace
.Set( CGColorSpaceCreatePattern( NULL
) );
589 m_pattern
.Set( *( new ImagePattern( bmp
, CGAffineTransformMakeScale( 1,-1 ) ) ) );
594 wxMacCoreGraphicsBrushData::~wxMacCoreGraphicsBrushData()
597 CGShadingRelease(m_shading
);
599 if( m_gradientFunction
)
600 CGFunctionRelease(m_gradientFunction
);
602 delete[] m_gradientComponents
;
603 delete[] m_patternColorComponents
;
606 void wxMacCoreGraphicsBrushData::Init()
608 m_patternColorComponents
= NULL
;
609 m_gradientFunction
= NULL
;
612 m_gradientComponents
= NULL
;
616 void wxMacCoreGraphicsBrushData::Apply( wxGraphicsContext
* context
)
618 CGContextRef cg
= (CGContextRef
) context
->GetNativeContext();
622 // nothing to set as shades are processed by clipping using the path and filling
628 CGAffineTransform matrix
= CGContextGetCTM( cg
);
629 CGContextSetPatternPhase( cg
, CGSizeMake(matrix
.tx
, matrix
.ty
) );
630 CGContextSetFillColorSpace( cg
, m_colorSpace
);
631 CGContextSetFillPattern( cg
, m_pattern
, m_patternColorComponents
);
635 CGContextSetFillColorWithColor( cg
, m_color
);
640 void wxMacCoreGraphicsBrushData::CalculateShadingValues (void *info
, const CGFloat
*in
, CGFloat
*out
)
642 CGFloat
* colors
= (CGFloat
*) info
;
644 for( int i
= 0 ; i
< 4 ; ++i
)
646 out
[i
] = colors
[i
] + ( colors
[4+i
] - colors
[i
] ) * f
;
650 CGFunctionRef
wxMacCoreGraphicsBrushData::CreateGradientFunction( const wxColour
& c1
, const wxColour
& c2
)
652 static const CGFunctionCallbacks callbacks
= { 0, &CalculateShadingValues
, NULL
};
653 static const CGFloat input_value_range
[2] = { 0, 1 };
654 static const CGFloat output_value_ranges
[8] = { 0, 1, 0, 1, 0, 1, 0, 1 };
655 m_gradientComponents
= new CGFloat
[8] ;
656 m_gradientComponents
[0] = c1
.Red() / 255.0;
657 m_gradientComponents
[1] = c1
.Green() / 255.0;
658 m_gradientComponents
[2] = c1
.Blue() / 255.0;
659 m_gradientComponents
[3] = c1
.Alpha() / 255.0;
660 m_gradientComponents
[4] = c2
.Red() / 255.0;
661 m_gradientComponents
[5] = c2
.Green() / 255.0;
662 m_gradientComponents
[6] = c2
.Blue() / 255.0;
663 m_gradientComponents
[7] = c2
.Alpha() / 255.0;
665 return CGFunctionCreate ( m_gradientComponents
, 1,
676 class wxMacCoreGraphicsFontData
: public wxGraphicsObjectRefData
679 wxMacCoreGraphicsFontData( wxGraphicsRenderer
* renderer
, const wxFont
&font
, const wxColour
& col
);
680 ~wxMacCoreGraphicsFontData();
682 virtual ATSUStyle
GetATSUStyle() { return m_macATSUIStyle
; }
684 ATSUStyle m_macATSUIStyle
;
687 wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer
* renderer
, const wxFont
&font
, const wxColour
& col
) : wxGraphicsObjectRefData( renderer
)
689 m_macATSUIStyle
= NULL
;
693 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) font
.MacGetATSUStyle() , &m_macATSUIStyle
);
695 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
697 // we need the scale here ...
699 Fixed atsuSize
= IntToFixed( int( 1 * font
.MacGetFontSize()) );
700 RGBColor atsuColor
= MAC_WXCOLORREF( col
.GetPixel() );
701 ATSUAttributeTag atsuTags
[] =
706 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
711 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
717 status
= ::ATSUSetAttributes(
718 m_macATSUIStyle
, sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
719 atsuTags
, atsuSizes
, atsuValues
);
721 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
724 wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
726 if ( m_macATSUIStyle
)
728 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
729 m_macATSUIStyle
= NULL
;
737 //-----------------------------------------------------------------------------
738 // wxMacCoreGraphicsMatrix declaration
739 //-----------------------------------------------------------------------------
741 class WXDLLIMPEXP_CORE wxMacCoreGraphicsMatrixData
: public wxGraphicsMatrixData
744 wxMacCoreGraphicsMatrixData(wxGraphicsRenderer
* renderer
) ;
746 virtual ~wxMacCoreGraphicsMatrixData() ;
748 virtual wxGraphicsObjectRefData
*Clone() const ;
750 // concatenates the matrix
751 virtual void Concat( const wxGraphicsMatrixData
*t
);
753 // sets the matrix to the respective values
754 virtual void Set(wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
755 wxDouble tx
=0.0, wxDouble ty
=0.0);
757 // makes this the inverse matrix
758 virtual void Invert();
760 // returns true if the elements of the transformation matrix are equal ?
761 virtual bool IsEqual( const wxGraphicsMatrixData
* t
) const ;
763 // return true if this is the identity matrix
764 virtual bool IsIdentity() const;
770 // add the translation to this matrix
771 virtual void Translate( wxDouble dx
, wxDouble dy
);
773 // add the scale to this matrix
774 virtual void Scale( wxDouble xScale
, wxDouble yScale
);
776 // add the rotation to this matrix (radians)
777 virtual void Rotate( wxDouble angle
);
780 // apply the transforms
783 // applies that matrix to the point
784 virtual void TransformPoint( wxDouble
*x
, wxDouble
*y
) const;
786 // applies the matrix except for translations
787 virtual void TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const;
789 // returns the native representation
790 virtual void * GetNativeMatrix() const;
793 CGAffineTransform m_matrix
;
796 //-----------------------------------------------------------------------------
797 // wxMacCoreGraphicsMatrix implementation
798 //-----------------------------------------------------------------------------
800 wxMacCoreGraphicsMatrixData::wxMacCoreGraphicsMatrixData(wxGraphicsRenderer
* renderer
) : wxGraphicsMatrixData(renderer
)
804 wxMacCoreGraphicsMatrixData::~wxMacCoreGraphicsMatrixData()
808 wxGraphicsObjectRefData
*wxMacCoreGraphicsMatrixData::Clone() const
810 wxMacCoreGraphicsMatrixData
* m
= new wxMacCoreGraphicsMatrixData(GetRenderer()) ;
811 m
->m_matrix
= m_matrix
;
815 // concatenates the matrix
816 void wxMacCoreGraphicsMatrixData::Concat( const wxGraphicsMatrixData
*t
)
818 m_matrix
= CGAffineTransformConcat(m_matrix
, *((CGAffineTransform
*) t
->GetNativeMatrix()) );
821 // sets the matrix to the respective values
822 void wxMacCoreGraphicsMatrixData::Set(wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
823 wxDouble tx
, wxDouble ty
)
825 m_matrix
= CGAffineTransformMake(a
,b
,c
,d
,tx
,ty
);
828 // makes this the inverse matrix
829 void wxMacCoreGraphicsMatrixData::Invert()
831 m_matrix
= CGAffineTransformInvert( m_matrix
);
834 // returns true if the elements of the transformation matrix are equal ?
835 bool wxMacCoreGraphicsMatrixData::IsEqual( const wxGraphicsMatrixData
* t
) const
837 const CGAffineTransform
* tm
= (CGAffineTransform
*) t
->GetNativeMatrix();
838 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
839 if ( CGAffineTransformEqualToTransform
!=NULL
)
841 return CGAffineTransformEqualToTransform(m_matrix
, *((CGAffineTransform
*) t
->GetNativeMatrix()));
847 m_matrix
.a
== tm
->a
&&
848 m_matrix
.b
== tm
->b
&&
849 m_matrix
.c
== tm
->c
&&
850 m_matrix
.d
== tm
->d
&&
851 m_matrix
.tx
== tm
->tx
&&
852 m_matrix
.ty
== tm
->ty
) ;
856 // return true if this is the identity matrix
857 bool wxMacCoreGraphicsMatrixData::IsIdentity() const
859 return ( m_matrix
.a
== 1 && m_matrix
.d
== 1 &&
860 m_matrix
.b
== 0 && m_matrix
.d
== 0 && m_matrix
.tx
== 0 && m_matrix
.ty
== 0);
867 // add the translation to this matrix
868 void wxMacCoreGraphicsMatrixData::Translate( wxDouble dx
, wxDouble dy
)
870 m_matrix
= CGAffineTransformTranslate( m_matrix
, dx
, dy
);
873 // add the scale to this matrix
874 void wxMacCoreGraphicsMatrixData::Scale( wxDouble xScale
, wxDouble yScale
)
876 m_matrix
= CGAffineTransformScale( m_matrix
, xScale
, yScale
);
879 // add the rotation to this matrix (radians)
880 void wxMacCoreGraphicsMatrixData::Rotate( wxDouble angle
)
882 m_matrix
= CGAffineTransformRotate( m_matrix
, angle
);
886 // apply the transforms
889 // applies that matrix to the point
890 void wxMacCoreGraphicsMatrixData::TransformPoint( wxDouble
*x
, wxDouble
*y
) const
892 CGPoint pt
= CGPointApplyAffineTransform( CGPointMake(*x
,*y
), m_matrix
);
898 // applies the matrix except for translations
899 void wxMacCoreGraphicsMatrixData::TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const
901 CGSize sz
= CGSizeApplyAffineTransform( CGSizeMake(*dx
,*dy
) , m_matrix
);
906 // returns the native representation
907 void * wxMacCoreGraphicsMatrixData::GetNativeMatrix() const
909 return (void*) &m_matrix
;
916 //-----------------------------------------------------------------------------
917 // wxMacCoreGraphicsPath declaration
918 //-----------------------------------------------------------------------------
920 class WXDLLEXPORT wxMacCoreGraphicsPathData
: public wxGraphicsPathData
923 wxMacCoreGraphicsPathData( wxGraphicsRenderer
* renderer
, CGMutablePathRef path
= NULL
);
925 ~wxMacCoreGraphicsPathData();
927 virtual wxGraphicsObjectRefData
*Clone() const;
929 // begins a new subpath at (x,y)
930 virtual void MoveToPoint( wxDouble x
, wxDouble y
);
932 // adds a straight line from the current point to (x,y)
933 virtual void AddLineToPoint( wxDouble x
, wxDouble y
);
935 // adds a cubic Bezier curve from the current point, using two control points and an end point
936 virtual void AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
);
938 // closes the current sub-path
939 virtual void CloseSubpath();
941 // gets the last point of the current path, (0,0) if not yet set
942 virtual void GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const;
944 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
945 virtual void AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
);
948 // These are convenience functions which - if not available natively will be assembled
949 // using the primitives from above
952 // adds a quadratic Bezier curve from the current point, using a control point and an end point
953 virtual void AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
);
955 // appends a rectangle as a new closed subpath
956 virtual void AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
958 // appends an ellipsis as a new closed subpath fitting the passed rectangle
959 virtual void AddCircle( wxDouble x
, wxDouble y
, wxDouble r
);
961 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
962 virtual void AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
);
965 virtual void AddPath( const wxGraphicsPathData
* path
);
967 // returns the native path
968 virtual void * GetNativePath() const { return m_path
; }
970 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
971 virtual void UnGetNativePath(void *p
) const {}
973 // transforms each point of this path by the matrix
974 virtual void Transform( const wxGraphicsMatrixData
* matrix
);
976 // gets the bounding box enclosing all points (possibly including control points)
977 virtual void GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*y
) const;
979 virtual bool Contains( wxDouble x
, wxDouble y
, int fillStyle
= wxODDEVEN_RULE
) const;
981 CGMutablePathRef m_path
;
984 //-----------------------------------------------------------------------------
985 // wxMacCoreGraphicsPath implementation
986 //-----------------------------------------------------------------------------
988 wxMacCoreGraphicsPathData::wxMacCoreGraphicsPathData( wxGraphicsRenderer
* renderer
, CGMutablePathRef path
) : wxGraphicsPathData(renderer
)
993 m_path
= CGPathCreateMutable();
996 wxMacCoreGraphicsPathData::~wxMacCoreGraphicsPathData()
998 CGPathRelease( m_path
);
1001 wxGraphicsObjectRefData
* wxMacCoreGraphicsPathData::Clone() const
1003 wxMacCoreGraphicsPathData
* clone
= new wxMacCoreGraphicsPathData(GetRenderer(),CGPathCreateMutableCopy(m_path
));
1008 // opens (starts) a new subpath
1009 void wxMacCoreGraphicsPathData::MoveToPoint( wxDouble x1
, wxDouble y1
)
1011 CGPathMoveToPoint( m_path
, NULL
, x1
, y1
);
1014 void wxMacCoreGraphicsPathData::AddLineToPoint( wxDouble x1
, wxDouble y1
)
1016 CGPathAddLineToPoint( m_path
, NULL
, x1
, y1
);
1019 void wxMacCoreGraphicsPathData::AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
)
1021 CGPathAddCurveToPoint( m_path
, NULL
, cx1
, cy1
, cx2
, cy2
, x
, y
);
1024 void wxMacCoreGraphicsPathData::AddQuadCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble x
, wxDouble y
)
1026 CGPathAddQuadCurveToPoint( m_path
, NULL
, cx1
, cy1
, x
, y
);
1029 void wxMacCoreGraphicsPathData::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
1031 CGRect cgRect
= { { x
, y
} , { w
, h
} };
1032 CGPathAddRect( m_path
, NULL
, cgRect
);
1035 void wxMacCoreGraphicsPathData::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
1037 CGPathAddArc( m_path
, NULL
, x
, y
, r
, 0.0 , 2 * M_PI
, true );
1040 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
1041 void wxMacCoreGraphicsPathData::AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
1043 // inverse direction as we the 'normal' state is a y axis pointing down, ie mirrored to the standard core graphics setup
1044 CGPathAddArc( m_path
, NULL
, x
, y
, r
, startAngle
, endAngle
, !clockwise
);
1047 void wxMacCoreGraphicsPathData::AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
)
1049 CGPathAddArcToPoint( m_path
, NULL
, x1
, y1
, x2
, y2
, r
);
1052 void wxMacCoreGraphicsPathData::AddPath( const wxGraphicsPathData
* path
)
1054 CGPathAddPath( m_path
, NULL
, (CGPathRef
) path
->GetNativePath() );
1057 // closes the current subpath
1058 void wxMacCoreGraphicsPathData::CloseSubpath()
1060 CGPathCloseSubpath( m_path
);
1063 // gets the last point of the current path, (0,0) if not yet set
1064 void wxMacCoreGraphicsPathData::GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const
1066 CGPoint p
= CGPathGetCurrentPoint( m_path
);
1071 // transforms each point of this path by the matrix
1072 void wxMacCoreGraphicsPathData::Transform( const wxGraphicsMatrixData
* matrix
)
1074 CGMutablePathRef p
= CGPathCreateMutable() ;
1075 CGPathAddPath( p
, (CGAffineTransform
*) matrix
->GetNativeMatrix() , m_path
);
1076 CGPathRelease( m_path
);
1080 // gets the bounding box enclosing all points (possibly including control points)
1081 void wxMacCoreGraphicsPathData::GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const
1083 CGRect bounds
= CGPathGetBoundingBox( m_path
) ;
1084 *x
= bounds
.origin
.x
;
1085 *y
= bounds
.origin
.y
;
1086 *w
= bounds
.size
.width
;
1087 *h
= bounds
.size
.height
;
1090 bool wxMacCoreGraphicsPathData::Contains( wxDouble x
, wxDouble y
, int fillStyle
) const
1092 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1093 if ( CGPathContainsPoint
!=NULL
)
1095 return CGPathContainsPoint( m_path
, NULL
, CGPointMake(x
,y
), fillStyle
== wxODDEVEN_RULE
);
1100 // TODO : implementation for 10.3
1101 CGRect bounds
= CGPathGetBoundingBox( m_path
) ;
1102 return CGRectContainsPoint( bounds
, CGPointMake(x
,y
) ) == 1;
1110 //-----------------------------------------------------------------------------
1111 // wxMacCoreGraphicsContext declaration
1112 //-----------------------------------------------------------------------------
1114 class WXDLLEXPORT wxMacCoreGraphicsContext
: public wxGraphicsContext
1117 wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
, CGContextRef cgcontext
);
1119 wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
, WindowRef window
);
1121 wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
, wxWindow
* window
);
1123 wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
);
1125 wxMacCoreGraphicsContext();
1127 ~wxMacCoreGraphicsContext();
1131 // push the current state of the context, ie the transformation matrix on a stack
1132 virtual void PushState();
1134 // pops a stored state from the stack
1135 virtual void PopState();
1137 // clips drawings to the region
1138 virtual void Clip( const wxRegion
®ion
);
1140 // clips drawings to the rect
1141 virtual void Clip( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
1143 // resets the clipping to original extent
1144 virtual void ResetClip();
1146 virtual void * GetNativeContext();
1148 bool SetLogicalFunction( int function
);
1154 virtual void Translate( wxDouble dx
, wxDouble dy
);
1157 virtual void Scale( wxDouble xScale
, wxDouble yScale
);
1160 virtual void Rotate( wxDouble angle
);
1162 // concatenates this transform with the current transform of this context
1163 virtual void ConcatTransform( const wxGraphicsMatrix
& matrix
);
1165 // sets the transform of this context
1166 virtual void SetTransform( const wxGraphicsMatrix
& matrix
);
1168 // gets the matrix of this context
1169 virtual wxGraphicsMatrix
GetTransform() const;
1171 // setting the paint
1174 // strokes along a path with the current pen
1175 virtual void StrokePath( const wxGraphicsPath
&path
);
1177 // fills a path with the current brush
1178 virtual void FillPath( const wxGraphicsPath
&path
, int fillStyle
= wxODDEVEN_RULE
);
1180 // draws a path by first filling and then stroking
1181 virtual void DrawPath( const wxGraphicsPath
&path
, int fillStyle
= wxODDEVEN_RULE
);
1183 virtual bool ShouldOffset() const
1186 if ( !m_pen
.IsNull() )
1188 penwidth
= (int)((wxMacCoreGraphicsPenData
*)m_pen
.GetRefData())->GetWidth();
1189 if ( penwidth
== 0 )
1192 return ( penwidth
% 2 ) == 1;
1198 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
);
1200 virtual void DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
);
1202 virtual void GetTextExtent( const wxString
&text
, wxDouble
*width
, wxDouble
*height
,
1203 wxDouble
*descent
, wxDouble
*externalLeading
) const;
1205 virtual void GetPartialTextExtents(const wxString
& text
, wxArrayDouble
& widths
) const;
1211 virtual void DrawBitmap( const wxBitmap
&bmp
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
1213 virtual void DrawIcon( const wxIcon
&icon
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
);
1215 void SetNativeContext( CGContextRef cg
);
1217 DECLARE_NO_COPY_CLASS(wxMacCoreGraphicsContext
)
1218 DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsContext
)
1221 void EnsureIsValid();
1223 CGContextRef m_cgContext
;
1224 WindowRef m_windowRef
;
1225 bool m_releaseContext
;
1226 CGAffineTransform m_windowTransform
;
1228 wxMacCFRefHolder
<HIShapeRef
> m_clipRgn
;
1231 //-----------------------------------------------------------------------------
1232 // device context implementation
1234 // more and more of the dc functionality should be implemented by calling
1235 // the appropricate wxMacCoreGraphicsContext, but we will have to do that step by step
1236 // also coordinate conversions should be moved to native matrix ops
1237 //-----------------------------------------------------------------------------
1239 // we always stock two context states, one at entry, to be able to preserve the
1240 // state we were called with, the other one after changing to HI Graphics orientation
1241 // (this one is used for getting back clippings etc)
1243 //-----------------------------------------------------------------------------
1244 // wxMacCoreGraphicsContext implementation
1245 //-----------------------------------------------------------------------------
1247 IMPLEMENT_DYNAMIC_CLASS(wxMacCoreGraphicsContext
, wxGraphicsContext
)
1249 void wxMacCoreGraphicsContext::Init()
1252 m_releaseContext
= false;
1255 HIRect r
= CGRectMake(0,0,0,0);
1256 m_clipRgn
.Set(HIShapeCreateWithRect(&r
));
1259 wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
, CGContextRef cgcontext
) : wxGraphicsContext(renderer
)
1262 SetNativeContext(cgcontext
);
1265 wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
, WindowRef window
): wxGraphicsContext(renderer
)
1268 m_windowRef
= window
;
1271 wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer
* renderer
, wxWindow
* window
): wxGraphicsContext(renderer
)
1274 m_windowRef
= (WindowRef
) window
->MacGetTopLevelWindowRef();
1275 int originX
, originY
;
1276 originX
= originY
= 0;
1277 window
->MacWindowToRootWindow( &originX
, &originY
);
1279 GetWindowBounds( m_windowRef
, kWindowContentRgn
, &bounds
);
1281 m_windowTransform
= CGAffineTransformMakeTranslation( 0 , bounds
.bottom
- bounds
.top
);
1282 m_windowTransform
= CGAffineTransformScale( m_windowTransform
, 1 , -1 );
1283 m_windowTransform
= CGAffineTransformTranslate( m_windowTransform
, originX
, originY
) ;
1286 wxMacCoreGraphicsContext::wxMacCoreGraphicsContext(wxGraphicsRenderer
* renderer
) : wxGraphicsContext(renderer
)
1291 wxMacCoreGraphicsContext::wxMacCoreGraphicsContext() : wxGraphicsContext(NULL
)
1294 wxLogDebug(wxT("Illegal Constructor called"));
1297 wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
1299 SetNativeContext(NULL
);
1302 void wxMacCoreGraphicsContext::EnsureIsValid()
1306 OSStatus status
= QDBeginCGContext( GetWindowPort( m_windowRef
) , &m_cgContext
);
1307 wxASSERT_MSG( status
== noErr
, wxT("Cannot nest wxDCs on the same window") );
1309 CGContextConcatCTM( m_cgContext
, m_windowTransform
);
1310 CGContextSaveGState( m_cgContext
);
1311 m_releaseContext
= true;
1312 if ( !HIShapeIsEmpty(m_clipRgn
) )
1314 // the clip region is in device coordinates, so we convert this again to user coordinates
1315 wxMacCFRefHolder
<HIMutableShapeRef
> hishape
;
1316 hishape
.Set( HIShapeCreateMutableCopy( m_clipRgn
) );
1317 CGPoint transformedOrigin
= CGPointApplyAffineTransform( CGPointZero
,m_windowTransform
);
1318 HIShapeOffset( hishape
, -transformedOrigin
.x
, -transformedOrigin
.y
);
1319 HIShapeReplacePathInCGContext( hishape
, m_cgContext
);
1320 CGContextClip( m_cgContext
);
1322 CGContextSaveGState( m_cgContext
);
1326 bool wxMacCoreGraphicsContext::SetLogicalFunction( int function
)
1328 if (m_logicalFunction
== function
)
1333 bool retval
= false;
1335 if ( function
== wxCOPY
)
1338 #if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
1339 if ( CGContextSetBlendMode
!= NULL
)
1341 CGContextSetBlendMode( m_cgContext
, kCGBlendModeNormal
);
1342 CGContextSetShouldAntialias( m_cgContext
, true );
1346 else if ( function
== wxINVERT
|| function
== wxXOR
)
1348 #if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
1349 if ( CGContextSetBlendMode
!= NULL
)
1351 // change color to white
1352 CGContextSetBlendMode( m_cgContext
, kCGBlendModeExclusion
);
1353 CGContextSetShouldAntialias( m_cgContext
, false );
1360 m_logicalFunction
= function
;
1364 void wxMacCoreGraphicsContext::Clip( const wxRegion
®ion
)
1368 HIShapeRef shape
= HIShapeCreateWithQDRgn( (RgnHandle
) region
.GetWXHRGN() );
1369 HIShapeReplacePathInCGContext( shape
, m_cgContext
);
1370 CGContextClip( m_cgContext
);
1375 // this offsetting to device coords is not really correct, but since we cannot apply affine transforms
1376 // to regions we try at least to have correct translations
1377 wxMacCFRefHolder
<HIShapeRef
> hishape
;
1378 hishape
.Set( HIShapeCreateWithQDRgn( (RgnHandle
) region
.GetWXHRGN() ));
1379 HIMutableShapeRef mutableShape
= HIShapeCreateMutableCopy( hishape
);
1381 CGPoint transformedOrigin
= CGPointApplyAffineTransform( CGPointZero
, m_windowTransform
);
1382 HIShapeOffset( mutableShape
, transformedOrigin
.x
, transformedOrigin
.y
);
1383 m_clipRgn
.Set(mutableShape
);
1387 // clips drawings to the rect
1388 void wxMacCoreGraphicsContext::Clip( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
1390 HIRect r
= CGRectMake( x
, y
, w
, h
);
1393 CGContextClipToRect( m_cgContext
, r
);
1397 // the clipping itself must be stored as device coordinates, otherwise
1398 // we cannot apply it back correctly
1399 r
.origin
= CGPointApplyAffineTransform( r
.origin
, m_windowTransform
);
1400 m_clipRgn
.Set(HIShapeCreateWithRect(&r
));
1404 // resets the clipping to original extent
1405 void wxMacCoreGraphicsContext::ResetClip()
1409 // there is no way for clearing the clip, we can only revert to the stored
1410 // state, but then we have to make sure everything else is NOT restored
1411 CGAffineTransform transform
= CGContextGetCTM( m_cgContext
);
1412 CGContextRestoreGState( m_cgContext
);
1413 CGContextSaveGState( m_cgContext
);
1414 CGAffineTransform transformNew
= CGContextGetCTM( m_cgContext
);
1415 transformNew
= CGAffineTransformInvert( transformNew
) ;
1416 CGContextConcatCTM( m_cgContext
, transformNew
);
1417 CGContextConcatCTM( m_cgContext
, transform
);
1421 HIRect r
= CGRectMake(0,0,0,0);
1422 m_clipRgn
.Set(HIShapeCreateWithRect(&r
));
1426 void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath
&path
)
1428 if ( m_pen
.IsNull() )
1433 bool offset
= ShouldOffset();
1435 CGContextTranslateCTM( m_cgContext
, 0.5, 0.5 );
1437 ((wxMacCoreGraphicsPenData
*)m_pen
.GetRefData())->Apply(this);
1438 CGContextAddPath( m_cgContext
, (CGPathRef
) path
.GetNativePath() );
1439 CGContextStrokePath( m_cgContext
);
1442 CGContextTranslateCTM( m_cgContext
, -0.5, -0.5 );
1445 void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath
&path
, int fillStyle
)
1447 if ( !m_brush
.IsNull() && ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->IsShading() )
1449 // when using shading, we cannot draw pen and brush at the same time
1450 // revert to the base implementation of first filling and then stroking
1451 wxGraphicsContext::DrawPath( path
, fillStyle
);
1455 CGPathDrawingMode mode
= kCGPathFill
;
1456 if ( m_brush
.IsNull() )
1458 if ( m_pen
.IsNull() )
1461 mode
= kCGPathStroke
;
1465 if ( m_pen
.IsNull() )
1467 if ( fillStyle
== wxODDEVEN_RULE
)
1468 mode
= kCGPathEOFill
;
1474 if ( fillStyle
== wxODDEVEN_RULE
)
1475 mode
= kCGPathEOFillStroke
;
1477 mode
= kCGPathFillStroke
;
1483 if ( !m_brush
.IsNull() )
1484 ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->Apply(this);
1485 if ( !m_pen
.IsNull() )
1486 ((wxMacCoreGraphicsPenData
*)m_pen
.GetRefData())->Apply(this);
1488 bool offset
= ShouldOffset();
1491 CGContextTranslateCTM( m_cgContext
, 0.5, 0.5 );
1493 CGContextAddPath( m_cgContext
, (CGPathRef
) path
.GetNativePath() );
1494 CGContextDrawPath( m_cgContext
, mode
);
1497 CGContextTranslateCTM( m_cgContext
, -0.5, -0.5 );
1500 void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath
&path
, int fillStyle
)
1502 if ( m_brush
.IsNull() )
1507 if ( ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->IsShading() )
1509 CGContextSaveGState( m_cgContext
);
1510 CGContextAddPath( m_cgContext
, (CGPathRef
) path
.GetNativePath() );
1511 CGContextClip( m_cgContext
);
1512 CGContextDrawShading( m_cgContext
, ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->GetShading() );
1513 CGContextRestoreGState( m_cgContext
);
1517 ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->Apply(this);
1518 CGContextAddPath( m_cgContext
, (CGPathRef
) path
.GetNativePath() );
1519 if ( fillStyle
== wxODDEVEN_RULE
)
1520 CGContextEOFillPath( m_cgContext
);
1522 CGContextFillPath( m_cgContext
);
1526 void wxMacCoreGraphicsContext::SetNativeContext( CGContextRef cg
)
1528 // we allow either setting or clearing but not replacing
1529 wxASSERT( m_cgContext
== NULL
|| cg
== NULL
);
1533 // TODO : when is this necessary - should we add a Flush() method ? CGContextSynchronize( m_cgContext );
1534 CGContextRestoreGState( m_cgContext
);
1535 CGContextRestoreGState( m_cgContext
);
1536 if ( m_releaseContext
)
1537 QDEndCGContext( GetWindowPort( m_windowRef
) , &m_cgContext
);
1539 CGContextRelease(m_cgContext
);
1545 // FIXME: This check is needed because currently we need to use a DC/GraphicsContext
1546 // in order to get font properties, like wxFont::GetPixelSize, but since we don't have
1547 // a native window attached to use, I create a wxGraphicsContext with a NULL CGContextRef
1548 // for this one operation.
1550 // When wxFont::GetPixelSize on Mac no longer needs a graphics context, this check
1554 CGContextRetain(m_cgContext
);
1555 CGContextSaveGState( m_cgContext
);
1556 CGContextSaveGState( m_cgContext
);
1557 m_releaseContext
= false;
1561 void wxMacCoreGraphicsContext::Translate( wxDouble dx
, wxDouble dy
)
1564 CGContextTranslateCTM( m_cgContext
, dx
, dy
);
1566 m_windowTransform
= CGAffineTransformTranslate(m_windowTransform
,dx
,dy
);
1569 void wxMacCoreGraphicsContext::Scale( wxDouble xScale
, wxDouble yScale
)
1572 CGContextScaleCTM( m_cgContext
, xScale
, yScale
);
1574 m_windowTransform
= CGAffineTransformScale(m_windowTransform
,xScale
,yScale
);
1577 void wxMacCoreGraphicsContext::Rotate( wxDouble angle
)
1580 CGContextRotateCTM( m_cgContext
, angle
);
1582 m_windowTransform
= CGAffineTransformRotate(m_windowTransform
,angle
);
1585 void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap
&bmp
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
1589 CGImageRef image
= (CGImageRef
)( bmp
.CGImageCreate() );
1590 HIRect r
= CGRectMake( x
, y
, w
, h
);
1591 if ( bmp
.GetDepth() == 1 )
1593 // is is a mask, the '1' in the mask tell where to draw the current brush
1594 if ( !m_brush
.IsNull() )
1596 if ( ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->IsShading() )
1598 // TODO clip to mask
1600 CGContextSaveGState( m_cgContext );
1601 CGContextAddPath( m_cgContext , (CGPathRef) path.GetNativePath() );
1602 CGContextClip( m_cgContext );
1603 CGContextDrawShading( m_cgContext, ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->GetShading() );
1604 CGContextRestoreGState( m_cgContext);
1609 ((wxMacCoreGraphicsBrushData
*)m_brush
.GetRefData())->Apply(this);
1610 HIViewDrawCGImage( m_cgContext
, &r
, image
);
1616 HIViewDrawCGImage( m_cgContext
, &r
, image
);
1618 CGImageRelease( image
);
1621 void wxMacCoreGraphicsContext::DrawIcon( const wxIcon
&icon
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
1625 CGRect r
= CGRectMake( 00 , 00 , w
, h
);
1626 CGContextSaveGState( m_cgContext
);
1627 CGContextTranslateCTM( m_cgContext
, x
, y
+ h
);
1628 CGContextScaleCTM( m_cgContext
, 1, -1 );
1629 PlotIconRefInContext( m_cgContext
, &r
, kAlignNone
, kTransformNone
,
1630 NULL
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) );
1631 CGContextRestoreGState( m_cgContext
);
1634 void wxMacCoreGraphicsContext::PushState()
1638 CGContextSaveGState( m_cgContext
);
1641 void wxMacCoreGraphicsContext::PopState()
1645 CGContextRestoreGState( m_cgContext
);
1648 void wxMacCoreGraphicsContext::DrawText( const wxString
&str
, wxDouble x
, wxDouble y
)
1650 DrawText(str
, x
, y
, 0.0);
1653 void wxMacCoreGraphicsContext::DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
)
1655 if ( m_font
.IsNull() )
1660 OSStatus status
= noErr
;
1661 ATSUTextLayout atsuLayout
;
1662 UniCharCount chars
= str
.length();
1663 UniChar
* ubuf
= NULL
;
1665 #if SIZEOF_WCHAR_T == 4
1666 wxMBConvUTF16 converter
;
1668 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 );
1669 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 );
1670 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 );
1672 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
);
1673 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 );
1674 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 );
1675 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 );
1677 chars
= unicharlen
/ 2;
1680 ubuf
= (UniChar
*) str
.wc_str();
1682 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
);
1683 chars
= wxWcslen( wchar
.data() );
1684 ubuf
= (UniChar
*) wchar
.data();
1688 ATSUStyle style
= (((wxMacCoreGraphicsFontData
*)m_font
.GetRefData())->GetATSUStyle());
1689 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1690 &chars
, &style
, &atsuLayout
);
1692 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1694 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true );
1695 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1697 int iAngle
= int( angle
* RAD2DEG
);
1698 if ( abs(iAngle
) > 0 )
1700 Fixed atsuAngle
= IntToFixed( iAngle
);
1701 ATSUAttributeTag atsuTags
[] =
1703 kATSULineRotationTag
,
1705 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
1709 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
1713 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
) / sizeof(ATSUAttributeTag
),
1714 atsuTags
, atsuSizes
, atsuValues
);
1718 ATSUAttributeTag atsuTags
[] =
1722 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
1724 sizeof( CGContextRef
) ,
1726 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
1730 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
) / sizeof(ATSUAttributeTag
),
1731 atsuTags
, atsuSizes
, atsuValues
);
1734 ATSUTextMeasurement textBefore
, textAfter
;
1735 ATSUTextMeasurement ascent
, descent
;
1737 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1738 &textBefore
, &textAfter
, &ascent
, &descent
);
1740 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1743 x
+= (int)(sin(angle
) * FixedToInt(ascent
));
1744 y
+= (int)(cos(angle
) * FixedToInt(ascent
));
1746 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1747 IntToFixed(x
) , IntToFixed(y
) , &rect
);
1748 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1750 CGContextSaveGState(m_cgContext
);
1751 CGContextTranslateCTM(m_cgContext
, x
, y
);
1752 CGContextScaleCTM(m_cgContext
, 1, -1);
1753 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1754 IntToFixed(0) , IntToFixed(0) );
1756 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1758 CGContextRestoreGState(m_cgContext
);
1760 ::ATSUDisposeTextLayout(atsuLayout
);
1762 #if SIZEOF_WCHAR_T == 4
1767 void wxMacCoreGraphicsContext::GetTextExtent( const wxString
&str
, wxDouble
*width
, wxDouble
*height
,
1768 wxDouble
*descent
, wxDouble
*externalLeading
) const
1770 wxCHECK_RET( !m_font
.IsNull(), wxT("wxDC(cg)::DoGetTextExtent - no valid font set") );
1772 OSStatus status
= noErr
;
1774 ATSUTextLayout atsuLayout
;
1775 UniCharCount chars
= str
.length();
1776 UniChar
* ubuf
= NULL
;
1778 #if SIZEOF_WCHAR_T == 4
1779 wxMBConvUTF16 converter
;
1781 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 );
1782 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 );
1783 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 );
1785 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
);
1786 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 );
1787 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 );
1788 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 );
1790 chars
= unicharlen
/ 2;
1793 ubuf
= (UniChar
*) str
.wc_str();
1795 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
);
1796 chars
= wxWcslen( wchar
.data() );
1797 ubuf
= (UniChar
*) wchar
.data();
1801 ATSUStyle style
= (((wxMacCoreGraphicsFontData
*)m_font
.GetRefData())->GetATSUStyle());
1802 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1803 &chars
, &style
, &atsuLayout
);
1805 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the text") );
1807 ATSUTextMeasurement textBefore
, textAfter
;
1808 ATSUTextMeasurement textAscent
, textDescent
;
1810 status
= ::ATSUGetUnjustifiedBounds( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1811 &textBefore
, &textAfter
, &textAscent
, &textDescent
);
1814 *height
= FixedToInt(textAscent
+ textDescent
);
1816 *descent
= FixedToInt(textDescent
);
1817 if ( externalLeading
)
1818 *externalLeading
= 0;
1820 *width
= FixedToInt(textAfter
- textBefore
);
1822 ::ATSUDisposeTextLayout(atsuLayout
);
1825 void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString
& text
, wxArrayDouble
& widths
) const
1828 widths
.Add(0, text
.length());
1833 ATSUTextLayout atsuLayout
;
1834 UniCharCount chars
= text
.length();
1835 UniChar
* ubuf
= NULL
;
1837 #if SIZEOF_WCHAR_T == 4
1838 wxMBConvUTF16 converter
;
1840 size_t unicharlen
= converter
.WC2MB( NULL
, text
.wc_str() , 0 );
1841 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 );
1842 converter
.WC2MB( (char*) ubuf
, text
.wc_str(), unicharlen
+ 2 );
1844 const wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
);
1845 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 );
1846 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 );
1847 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 );
1849 chars
= unicharlen
/ 2;
1852 ubuf
= (UniChar
*) text
.wc_str();
1854 wxWCharBuffer wchar
= text
.wc_str( wxConvLocal
);
1855 chars
= wxWcslen( wchar
.data() );
1856 ubuf
= (UniChar
*) wchar
.data();
1860 ATSUStyle style
= (((wxMacCoreGraphicsFontData
*)m_font
.GetRefData())->GetATSUStyle());
1861 ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1862 &chars
, &style
, &atsuLayout
);
1864 for ( int pos
= 0; pos
< (int)chars
; pos
++ )
1866 unsigned long actualNumberOfBounds
= 0;
1867 ATSTrapezoid glyphBounds
;
1869 // We get a single bound, since the text should only require one. If it requires more, there is an issue
1871 result
= ATSUGetGlyphBounds( atsuLayout
, 0, 0, kATSUFromTextBeginning
, pos
+ 1,
1872 kATSUseDeviceOrigins
, 1, &glyphBounds
, &actualNumberOfBounds
);
1873 if (result
!= noErr
|| actualNumberOfBounds
!= 1 )
1876 widths
[pos
] = FixedToInt( glyphBounds
.upperRight
.x
- glyphBounds
.upperLeft
.x
);
1877 //unsigned char uch = s[i];
1880 ::ATSUDisposeTextLayout(atsuLayout
);
1883 void * wxMacCoreGraphicsContext::GetNativeContext()
1888 // concatenates this transform with the current transform of this context
1889 void wxMacCoreGraphicsContext::ConcatTransform( const wxGraphicsMatrix
& matrix
)
1892 CGContextConcatCTM( m_cgContext
, *(CGAffineTransform
*) matrix
.GetNativeMatrix());
1894 m_windowTransform
= CGAffineTransformConcat(m_windowTransform
, *(CGAffineTransform
*) matrix
.GetNativeMatrix());
1897 // sets the transform of this context
1898 void wxMacCoreGraphicsContext::SetTransform( const wxGraphicsMatrix
& matrix
)
1902 CGAffineTransform transform
= CGContextGetCTM( m_cgContext
);
1903 transform
= CGAffineTransformInvert( transform
) ;
1904 CGContextConcatCTM( m_cgContext
, transform
);
1905 CGContextConcatCTM( m_cgContext
, *(CGAffineTransform
*) matrix
.GetNativeMatrix());
1909 m_windowTransform
= *(CGAffineTransform
*) matrix
.GetNativeMatrix();
1913 // gets the matrix of this context
1914 wxGraphicsMatrix
wxMacCoreGraphicsContext::GetTransform() const
1916 wxGraphicsMatrix m
= CreateMatrix();
1917 *((CGAffineTransform
*) m
.GetNativeMatrix()) = ( m_cgContext
== NULL
? m_windowTransform
:
1918 CGContextGetCTM( m_cgContext
));
1926 //-----------------------------------------------------------------------------
1927 // wxMacCoreGraphicsRenderer declaration
1928 //-----------------------------------------------------------------------------
1930 class WXDLLIMPEXP_CORE wxMacCoreGraphicsRenderer
: public wxGraphicsRenderer
1933 wxMacCoreGraphicsRenderer() {}
1935 virtual ~wxMacCoreGraphicsRenderer() {}
1939 virtual wxGraphicsContext
* CreateContext( const wxWindowDC
& dc
);
1941 virtual wxGraphicsContext
* CreateContextFromNativeContext( void * context
);
1943 virtual wxGraphicsContext
* CreateContextFromNativeWindow( void * window
);
1945 virtual wxGraphicsContext
* CreateContext( wxWindow
* window
);
1947 virtual wxGraphicsContext
* CreateMeasuringContext();
1951 virtual wxGraphicsPath
CreatePath();
1955 virtual wxGraphicsMatrix
CreateMatrix( wxDouble a
=1.0, wxDouble b
=0.0, wxDouble c
=0.0, wxDouble d
=1.0,
1956 wxDouble tx
=0.0, wxDouble ty
=0.0);
1959 virtual wxGraphicsPen
CreatePen(const wxPen
& pen
) ;
1961 virtual wxGraphicsBrush
CreateBrush(const wxBrush
& brush
) ;
1963 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
1964 virtual wxGraphicsBrush
CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
1965 const wxColour
&c1
, const wxColour
&c2
) ;
1967 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
1968 // with radius r and color cColor
1969 virtual wxGraphicsBrush
CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
1970 const wxColour
&oColor
, const wxColour
&cColor
) ;
1973 virtual wxGraphicsFont
CreateFont( const wxFont
&font
, const wxColour
&col
= *wxBLACK
) ;
1976 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsRenderer
)
1979 //-----------------------------------------------------------------------------
1980 // wxMacCoreGraphicsRenderer implementation
1981 //-----------------------------------------------------------------------------
1983 IMPLEMENT_DYNAMIC_CLASS(wxMacCoreGraphicsRenderer
,wxGraphicsRenderer
)
1985 static wxMacCoreGraphicsRenderer gs_MacCoreGraphicsRenderer
;
1987 wxGraphicsRenderer
* wxGraphicsRenderer::GetDefaultRenderer()
1989 return &gs_MacCoreGraphicsRenderer
;
1992 wxGraphicsContext
* wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC
& dc
)
1994 return new wxMacCoreGraphicsContext(this,(CGContextRef
)dc
.GetWindow()->MacGetCGContextRef() );
1997 wxGraphicsContext
* wxMacCoreGraphicsRenderer::CreateContextFromNativeContext( void * context
)
1999 return new wxMacCoreGraphicsContext(this,(CGContextRef
)context
);
2003 wxGraphicsContext
* wxMacCoreGraphicsRenderer::CreateContextFromNativeWindow( void * window
)
2005 return new wxMacCoreGraphicsContext(this,(WindowRef
)window
);
2008 wxGraphicsContext
* wxMacCoreGraphicsRenderer::CreateContext( wxWindow
* window
)
2010 return new wxMacCoreGraphicsContext(this, window
);
2013 wxGraphicsContext
* wxMacCoreGraphicsRenderer::CreateMeasuringContext()
2015 return new wxMacCoreGraphicsContext(this);
2020 wxGraphicsPath
wxMacCoreGraphicsRenderer::CreatePath()
2023 m
.SetRefData( new wxMacCoreGraphicsPathData(this));
2030 wxGraphicsMatrix
wxMacCoreGraphicsRenderer::CreateMatrix( wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
2031 wxDouble tx
, wxDouble ty
)
2034 wxMacCoreGraphicsMatrixData
* data
= new wxMacCoreGraphicsMatrixData( this );
2035 data
->Set( a
,b
,c
,d
,tx
,ty
) ;
2040 wxGraphicsPen
wxMacCoreGraphicsRenderer::CreatePen(const wxPen
& pen
)
2042 if ( !pen
.Ok() || pen
.GetStyle() == wxTRANSPARENT
)
2043 return wxNullGraphicsPen
;
2047 p
.SetRefData(new wxMacCoreGraphicsPenData( this, pen
));
2052 wxGraphicsBrush
wxMacCoreGraphicsRenderer::CreateBrush(const wxBrush
& brush
)
2054 if ( !brush
.Ok() || brush
.GetStyle() == wxTRANSPARENT
)
2055 return wxNullGraphicsBrush
;
2059 p
.SetRefData(new wxMacCoreGraphicsBrushData( this, brush
));
2064 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
2065 wxGraphicsBrush
wxMacCoreGraphicsRenderer::CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
2066 const wxColour
&c1
, const wxColour
&c2
)
2069 wxMacCoreGraphicsBrushData
* d
= new wxMacCoreGraphicsBrushData( this );
2070 d
->CreateLinearGradientBrush(x1
, y1
, x2
, y2
, c1
, c2
);
2075 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
2076 // with radius r and color cColor
2077 wxGraphicsBrush
wxMacCoreGraphicsRenderer::CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
2078 const wxColour
&oColor
, const wxColour
&cColor
)
2081 wxMacCoreGraphicsBrushData
* d
= new wxMacCoreGraphicsBrushData( this );
2082 d
->CreateRadialGradientBrush(xo
,yo
,xc
,yc
,radius
,oColor
,cColor
);
2088 wxGraphicsFont
wxMacCoreGraphicsRenderer::CreateFont( const wxFont
&font
, const wxColour
&col
)
2093 p
.SetRefData(new wxMacCoreGraphicsFontData( this , font
, col
));
2097 return wxNullGraphicsFont
;
2102 #endif // wxMAC_USE_CORE_GRAPHICS