switching things to ref counting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -256,12 +256,11 @@ protected :
|
|||||||
int m_hatch;
|
int m_hatch;
|
||||||
};
|
};
|
||||||
|
|
||||||
class wxMacCoreGraphicsPen : public wxGraphicsPen
|
class wxMacCoreGraphicsPenData : public wxGraphicsObjectRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMacCoreGraphicsPen();
|
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
||||||
wxMacCoreGraphicsPen( wxGraphicsRenderer* renderer, const wxPen &pen );
|
~wxMacCoreGraphicsPenData();
|
||||||
~wxMacCoreGraphicsPen();
|
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
virtual void Apply( wxGraphicsContext* context );
|
virtual void Apply( wxGraphicsContext* context );
|
||||||
@@ -283,19 +282,10 @@ protected :
|
|||||||
bool m_isPattern;
|
bool m_isPattern;
|
||||||
wxMacCFRefHolder<CGPatternRef> m_pattern;
|
wxMacCFRefHolder<CGPatternRef> m_pattern;
|
||||||
CGFloat* m_patternColorComponents;
|
CGFloat* m_patternColorComponents;
|
||||||
private :
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsPen)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMacCoreGraphicsPen,wxGraphicsPen)
|
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) :
|
||||||
|
wxGraphicsObjectRefData( renderer )
|
||||||
wxMacCoreGraphicsPen::wxMacCoreGraphicsPen() : wxGraphicsPen( NULL )
|
|
||||||
{
|
|
||||||
wxLogDebug(wxT("Illegal Constructor called"));
|
|
||||||
}
|
|
||||||
|
|
||||||
wxMacCoreGraphicsPen::wxMacCoreGraphicsPen( wxGraphicsRenderer* renderer, const wxPen &pen ) :
|
|
||||||
wxGraphicsPen( renderer )
|
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
@@ -433,13 +423,13 @@ wxMacCoreGraphicsPen::wxMacCoreGraphicsPen( wxGraphicsRenderer* renderer, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsPen::~wxMacCoreGraphicsPen()
|
wxMacCoreGraphicsPenData::~wxMacCoreGraphicsPenData()
|
||||||
{
|
{
|
||||||
delete[] m_userLengths;
|
delete[] m_userLengths;
|
||||||
delete[] m_patternColorComponents;
|
delete[] m_patternColorComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsPen::Init()
|
void wxMacCoreGraphicsPenData::Init()
|
||||||
{
|
{
|
||||||
m_lengths = NULL;
|
m_lengths = NULL;
|
||||||
m_userLengths = NULL;
|
m_userLengths = NULL;
|
||||||
@@ -449,7 +439,7 @@ void wxMacCoreGraphicsPen::Init()
|
|||||||
m_isPattern = false;
|
m_isPattern = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsPen::Apply( wxGraphicsContext* context )
|
void wxMacCoreGraphicsPenData::Apply( wxGraphicsContext* context )
|
||||||
{
|
{
|
||||||
CGContextRef cg = (CGContextRef) context->GetNativeContext();
|
CGContextRef cg = (CGContextRef) context->GetNativeContext();
|
||||||
CGContextSetLineWidth( cg , m_width );
|
CGContextSetLineWidth( cg , m_width );
|
||||||
@@ -473,13 +463,12 @@ void wxMacCoreGraphicsPen::Apply( wxGraphicsContext* context )
|
|||||||
// Brush
|
// Brush
|
||||||
//
|
//
|
||||||
|
|
||||||
class wxMacCoreGraphicsBrush : public wxGraphicsBrush
|
class wxMacCoreGraphicsBrushData : public wxGraphicsObjectRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMacCoreGraphicsBrush();
|
wxMacCoreGraphicsBrushData( wxGraphicsRenderer* renderer );
|
||||||
wxMacCoreGraphicsBrush( wxGraphicsRenderer* renderer );
|
wxMacCoreGraphicsBrushData( wxGraphicsRenderer* renderer, const wxBrush &brush );
|
||||||
wxMacCoreGraphicsBrush( wxGraphicsRenderer* renderer, const wxBrush &brush );
|
~wxMacCoreGraphicsBrushData ();
|
||||||
~wxMacCoreGraphicsBrush ();
|
|
||||||
|
|
||||||
virtual void Apply( wxGraphicsContext* context );
|
virtual void Apply( wxGraphicsContext* context );
|
||||||
void CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
void CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||||
@@ -505,23 +494,14 @@ protected:
|
|||||||
CGFunctionRef m_gradientFunction;
|
CGFunctionRef m_gradientFunction;
|
||||||
CGShadingRef m_shading;
|
CGShadingRef m_shading;
|
||||||
CGFloat *m_gradientComponents;
|
CGFloat *m_gradientComponents;
|
||||||
private :
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsBrush)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMacCoreGraphicsBrush,wxGraphicsBrush)
|
wxMacCoreGraphicsBrushData::wxMacCoreGraphicsBrushData( wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData( renderer )
|
||||||
|
|
||||||
wxMacCoreGraphicsBrush::wxMacCoreGraphicsBrush() : wxGraphicsBrush( NULL )
|
|
||||||
{
|
|
||||||
wxLogDebug(wxT("Illegal Constructor called"));
|
|
||||||
}
|
|
||||||
|
|
||||||
wxMacCoreGraphicsBrush::wxMacCoreGraphicsBrush( wxGraphicsRenderer* renderer) : wxGraphicsBrush( renderer )
|
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsBrush::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
void wxMacCoreGraphicsBrushData::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||||
const wxColour&c1, const wxColour&c2 )
|
const wxColour&c1, const wxColour&c2 )
|
||||||
{
|
{
|
||||||
m_gradientFunction = CreateGradientFunction( c1, c2 );
|
m_gradientFunction = CreateGradientFunction( c1, c2 );
|
||||||
@@ -529,7 +509,7 @@ void wxMacCoreGraphicsBrush::CreateLinearGradientBrush( wxDouble x1, wxDouble y1
|
|||||||
m_isShading = true ;
|
m_isShading = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsBrush::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
void wxMacCoreGraphicsBrushData::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
||||||
const wxColour &oColor, const wxColour &cColor )
|
const wxColour &oColor, const wxColour &cColor )
|
||||||
{
|
{
|
||||||
m_gradientFunction = CreateGradientFunction( oColor, cColor );
|
m_gradientFunction = CreateGradientFunction( oColor, cColor );
|
||||||
@@ -537,7 +517,7 @@ void wxMacCoreGraphicsBrush::CreateRadialGradientBrush( wxDouble xo, wxDouble yo
|
|||||||
m_isShading = true ;
|
m_isShading = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsBrush::wxMacCoreGraphicsBrush(wxGraphicsRenderer* renderer, const wxBrush &brush) : wxGraphicsBrush( renderer )
|
wxMacCoreGraphicsBrushData::wxMacCoreGraphicsBrushData(wxGraphicsRenderer* renderer, const wxBrush &brush) : wxGraphicsObjectRefData( renderer )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
@@ -574,7 +554,7 @@ wxMacCoreGraphicsBrush::wxMacCoreGraphicsBrush(wxGraphicsRenderer* renderer, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsBrush::~wxMacCoreGraphicsBrush()
|
wxMacCoreGraphicsBrushData::~wxMacCoreGraphicsBrushData()
|
||||||
{
|
{
|
||||||
if ( m_shading )
|
if ( m_shading )
|
||||||
CGShadingRelease(m_shading);
|
CGShadingRelease(m_shading);
|
||||||
@@ -586,7 +566,7 @@ wxMacCoreGraphicsBrush::~wxMacCoreGraphicsBrush()
|
|||||||
delete[] m_patternColorComponents;
|
delete[] m_patternColorComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsBrush::Init()
|
void wxMacCoreGraphicsBrushData::Init()
|
||||||
{
|
{
|
||||||
m_patternColorComponents = NULL;
|
m_patternColorComponents = NULL;
|
||||||
m_gradientFunction = NULL;
|
m_gradientFunction = NULL;
|
||||||
@@ -596,7 +576,7 @@ void wxMacCoreGraphicsBrush::Init()
|
|||||||
m_isShading = false;
|
m_isShading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsBrush::Apply( wxGraphicsContext* context )
|
void wxMacCoreGraphicsBrushData::Apply( wxGraphicsContext* context )
|
||||||
{
|
{
|
||||||
CGContextRef cg = (CGContextRef) context->GetNativeContext();
|
CGContextRef cg = (CGContextRef) context->GetNativeContext();
|
||||||
|
|
||||||
@@ -617,7 +597,7 @@ void wxMacCoreGraphicsBrush::Apply( wxGraphicsContext* context )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsBrush::CalculateShadingValues (void *info, const CGFloat *in, CGFloat *out)
|
void wxMacCoreGraphicsBrushData::CalculateShadingValues (void *info, const CGFloat *in, CGFloat *out)
|
||||||
{
|
{
|
||||||
CGFloat* colors = (CGFloat*) info ;
|
CGFloat* colors = (CGFloat*) info ;
|
||||||
CGFloat f = *in;
|
CGFloat f = *in;
|
||||||
@@ -627,7 +607,7 @@ void wxMacCoreGraphicsBrush::CalculateShadingValues (void *info, const CGFloat *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGFunctionRef wxMacCoreGraphicsBrush::CreateGradientFunction( const wxColour& c1, const wxColour& c2 )
|
CGFunctionRef wxMacCoreGraphicsBrushData::CreateGradientFunction( const wxColour& c1, const wxColour& c2 )
|
||||||
{
|
{
|
||||||
static const CGFunctionCallbacks callbacks = { 0, &CalculateShadingValues, NULL };
|
static const CGFunctionCallbacks callbacks = { 0, &CalculateShadingValues, NULL };
|
||||||
static const CGFloat input_value_range [2] = { 0, 1 };
|
static const CGFloat input_value_range [2] = { 0, 1 };
|
||||||
@@ -653,28 +633,18 @@ CGFunctionRef wxMacCoreGraphicsBrush::CreateGradientFunction( const wxColour& c1
|
|||||||
// Font
|
// Font
|
||||||
//
|
//
|
||||||
|
|
||||||
class wxMacCoreGraphicsFont : public wxGraphicsFont
|
class wxMacCoreGraphicsFontData : public wxGraphicsObjectRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMacCoreGraphicsFont();
|
wxMacCoreGraphicsFontData( wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col );
|
||||||
wxMacCoreGraphicsFont( wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col );
|
~wxMacCoreGraphicsFontData();
|
||||||
~wxMacCoreGraphicsFont();
|
|
||||||
|
|
||||||
virtual void Apply( wxGraphicsContext* context );
|
|
||||||
virtual ATSUStyle GetATSUStyle() { return m_macATSUIStyle; }
|
virtual ATSUStyle GetATSUStyle() { return m_macATSUIStyle; }
|
||||||
private :
|
private :
|
||||||
ATSUStyle m_macATSUIStyle;
|
ATSUStyle m_macATSUIStyle;
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsFont)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMacCoreGraphicsFont,wxGraphicsFont)
|
wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col) : wxGraphicsObjectRefData( renderer )
|
||||||
|
|
||||||
wxMacCoreGraphicsFont::wxMacCoreGraphicsFont() : wxGraphicsFont( NULL )
|
|
||||||
{
|
|
||||||
wxLogDebug(wxT("Illegal Constructor called"));
|
|
||||||
}
|
|
||||||
|
|
||||||
wxMacCoreGraphicsFont::wxMacCoreGraphicsFont(wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col) : wxGraphicsFont( renderer )
|
|
||||||
{
|
{
|
||||||
m_macATSUIStyle = NULL;
|
m_macATSUIStyle = NULL;
|
||||||
|
|
||||||
@@ -711,7 +681,7 @@ wxMacCoreGraphicsFont::wxMacCoreGraphicsFont(wxGraphicsRenderer* renderer, const
|
|||||||
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsFont::~wxMacCoreGraphicsFont()
|
wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
|
||||||
{
|
{
|
||||||
if ( m_macATSUIStyle )
|
if ( m_macATSUIStyle )
|
||||||
{
|
{
|
||||||
@@ -720,11 +690,6 @@ wxMacCoreGraphicsFont::~wxMacCoreGraphicsFont()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsFont::Apply( wxGraphicsContext* WXUNUSED(context) )
|
|
||||||
{
|
|
||||||
// nothing to do here
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Graphics Matrix
|
// Graphics Matrix
|
||||||
//
|
//
|
||||||
@@ -1191,15 +1156,6 @@ public:
|
|||||||
// setting the paint
|
// setting the paint
|
||||||
//
|
//
|
||||||
|
|
||||||
// sets the pen
|
|
||||||
virtual void SetPen( wxGraphicsPen* pen , bool release = true );
|
|
||||||
|
|
||||||
// sets the brush for filling
|
|
||||||
virtual void SetBrush( wxGraphicsBrush* brush , bool release = true );
|
|
||||||
|
|
||||||
// sets the font
|
|
||||||
virtual void SetFont( wxGraphicsFont* font, bool release = true );
|
|
||||||
|
|
||||||
// strokes along a path with the current pen
|
// strokes along a path with the current pen
|
||||||
virtual void StrokePath( const wxGraphicsPath *path );
|
virtual void StrokePath( const wxGraphicsPath *path );
|
||||||
|
|
||||||
@@ -1212,9 +1168,9 @@ public:
|
|||||||
virtual bool ShouldOffset() const
|
virtual bool ShouldOffset() const
|
||||||
{
|
{
|
||||||
int penwidth = 0 ;
|
int penwidth = 0 ;
|
||||||
if ( m_pen )
|
if ( !m_pen.IsNull() )
|
||||||
{
|
{
|
||||||
penwidth = m_pen->GetWidth();
|
penwidth = ((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->GetWidth();
|
||||||
if ( penwidth == 0 )
|
if ( penwidth == 0 )
|
||||||
penwidth = 1;
|
penwidth = 1;
|
||||||
}
|
}
|
||||||
@@ -1331,10 +1287,6 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext() : wxGraphicsContext(NULL)
|
|||||||
|
|
||||||
wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
|
wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
|
||||||
{
|
{
|
||||||
SetPen(NULL);
|
|
||||||
SetFont(NULL);
|
|
||||||
SetBrush(NULL);
|
|
||||||
|
|
||||||
if ( m_cgContext )
|
if ( m_cgContext )
|
||||||
{
|
{
|
||||||
// TODO : when is this necessary - should we add a Flush() method ? CGContextSynchronize( m_cgContext );
|
// TODO : when is this necessary - should we add a Flush() method ? CGContextSynchronize( m_cgContext );
|
||||||
@@ -1415,7 +1367,7 @@ void wxMacCoreGraphicsContext::ResetClip()
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
||||||
{
|
{
|
||||||
if ( m_pen == NULL )
|
if ( m_pen.IsNull() )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
@@ -1424,7 +1376,7 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
|||||||
if ( offset )
|
if ( offset )
|
||||||
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
|
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
|
||||||
|
|
||||||
m_pen->Apply(this);
|
((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->Apply(this);
|
||||||
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
||||||
CGContextStrokePath( m_cgContext );
|
CGContextStrokePath( m_cgContext );
|
||||||
|
|
||||||
@@ -1434,7 +1386,7 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillStyle )
|
void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillStyle )
|
||||||
{
|
{
|
||||||
if ( m_brush != NULL && ((wxMacCoreGraphicsBrush*)m_brush)->IsShading() )
|
if ( !m_brush.IsNull() && ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() )
|
||||||
{
|
{
|
||||||
// when using shading, we cannot draw pen and brush at the same time
|
// when using shading, we cannot draw pen and brush at the same time
|
||||||
// revert to the base implementation of first filling and then stroking
|
// revert to the base implementation of first filling and then stroking
|
||||||
@@ -1443,16 +1395,16 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
CGPathDrawingMode mode = kCGPathFill ;
|
CGPathDrawingMode mode = kCGPathFill ;
|
||||||
if ( m_brush == NULL )
|
if ( m_brush.IsNull() )
|
||||||
{
|
{
|
||||||
if ( m_pen == NULL )
|
if ( m_pen.IsNull() )
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
mode = kCGPathStroke;
|
mode = kCGPathStroke;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( m_pen == NULL )
|
if ( m_pen.IsNull() )
|
||||||
{
|
{
|
||||||
if ( fillStyle == wxODDEVEN_RULE )
|
if ( fillStyle == wxODDEVEN_RULE )
|
||||||
mode = kCGPathEOFill;
|
mode = kCGPathEOFill;
|
||||||
@@ -1470,10 +1422,10 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillSt
|
|||||||
|
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
if ( m_brush )
|
if ( !m_brush.IsNull() )
|
||||||
m_brush->Apply(this);
|
((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this);
|
||||||
if ( m_pen )
|
if ( !m_pen.IsNull() )
|
||||||
m_pen->Apply(this);
|
((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->Apply(this);
|
||||||
|
|
||||||
bool offset = ShouldOffset();
|
bool offset = ShouldOffset();
|
||||||
|
|
||||||
@@ -1489,22 +1441,22 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillSt
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath *path , int fillStyle )
|
void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath *path , int fillStyle )
|
||||||
{
|
{
|
||||||
if ( m_brush == NULL )
|
if ( m_brush.IsNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
if ( ((wxMacCoreGraphicsBrush*)m_brush)->IsShading() )
|
if ( ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() )
|
||||||
{
|
{
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
||||||
CGContextClip( m_cgContext );
|
CGContextClip( m_cgContext );
|
||||||
CGContextDrawShading( m_cgContext, ((wxMacCoreGraphicsBrush*)m_brush)->GetShading() );
|
CGContextDrawShading( m_cgContext, ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->GetShading() );
|
||||||
CGContextRestoreGState( m_cgContext);
|
CGContextRestoreGState( m_cgContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_brush->Apply(this);
|
((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this);
|
||||||
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
||||||
if ( fillStyle == wxODDEVEN_RULE )
|
if ( fillStyle == wxODDEVEN_RULE )
|
||||||
CGContextEOFillPath( m_cgContext );
|
CGContextEOFillPath( m_cgContext );
|
||||||
@@ -1581,24 +1533,6 @@ void wxMacCoreGraphicsContext::PopState()
|
|||||||
CGContextRestoreGState( m_cgContext );
|
CGContextRestoreGState( m_cgContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets the pen
|
|
||||||
void wxMacCoreGraphicsContext::SetPen( wxGraphicsPen* pen , bool release )
|
|
||||||
{
|
|
||||||
wxGraphicsContext::SetPen( pen, release );
|
|
||||||
}
|
|
||||||
|
|
||||||
// sets the brush for filling
|
|
||||||
void wxMacCoreGraphicsContext::SetBrush( wxGraphicsBrush* brush , bool release )
|
|
||||||
{
|
|
||||||
wxGraphicsContext::SetBrush( brush, release );
|
|
||||||
}
|
|
||||||
|
|
||||||
// sets the font
|
|
||||||
void wxMacCoreGraphicsContext::SetFont( wxGraphicsFont* font, bool release )
|
|
||||||
{
|
|
||||||
wxGraphicsContext::SetFont( font, release );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y )
|
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y )
|
||||||
{
|
{
|
||||||
DrawText(str, x, y, 0.0);
|
DrawText(str, x, y, 0.0);
|
||||||
@@ -1606,7 +1540,7 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
|
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
|
||||||
{
|
{
|
||||||
if ( m_font == NULL )
|
if ( m_font.IsNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
@@ -1639,7 +1573,7 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ATSUStyle style = (((wxMacCoreGraphicsFont*)m_font)->GetATSUStyle());
|
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
||||||
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
||||||
&chars , &style , &atsuLayout );
|
&chars , &style , &atsuLayout );
|
||||||
|
|
||||||
@@ -1741,7 +1675,7 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
|
|||||||
void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height,
|
void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height,
|
||||||
wxDouble *descent, wxDouble *externalLeading ) const
|
wxDouble *descent, wxDouble *externalLeading ) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_font != NULL, wxT("wxDC(cg)::DoGetTextExtent - no valid font set") );
|
wxCHECK_RET( !m_font.IsNull(), wxT("wxDC(cg)::DoGetTextExtent - no valid font set") );
|
||||||
|
|
||||||
OSStatus status = noErr;
|
OSStatus status = noErr;
|
||||||
|
|
||||||
@@ -1772,7 +1706,7 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ATSUStyle style = (((wxMacCoreGraphicsFont*)m_font)->GetATSUStyle());
|
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
||||||
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
||||||
&chars , &style , &atsuLayout );
|
&chars , &style , &atsuLayout );
|
||||||
|
|
||||||
@@ -1831,7 +1765,7 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ATSUStyle style = (((wxMacCoreGraphicsFont*)m_font)->GetATSUStyle());
|
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
||||||
::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
||||||
&chars , &style , &atsuLayout );
|
&chars , &style , &atsuLayout );
|
||||||
|
|
||||||
@@ -1909,21 +1843,21 @@ public :
|
|||||||
wxDouble tx=0.0, wxDouble ty=0.0);
|
wxDouble tx=0.0, wxDouble ty=0.0);
|
||||||
|
|
||||||
|
|
||||||
virtual wxGraphicsPen* CreatePen(const wxPen& pen) ;
|
virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
|
||||||
|
|
||||||
virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ) ;
|
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
|
||||||
|
|
||||||
// sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
|
// sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
|
||||||
virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||||
const wxColour&c1, const wxColour&c2) ;
|
const wxColour&c1, const wxColour&c2) ;
|
||||||
|
|
||||||
// sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
|
// sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
|
||||||
// with radius r and color cColor
|
// with radius r and color cColor
|
||||||
virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
||||||
const wxColour &oColor, const wxColour &cColor) ;
|
const wxColour &oColor, const wxColour &cColor) ;
|
||||||
|
|
||||||
// sets the font
|
// sets the font
|
||||||
virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) ;
|
virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsRenderer)
|
||||||
@@ -1982,48 +1916,64 @@ wxGraphicsMatrix * wxMacCoreGraphicsRenderer::CreateMatrix( wxDouble a, wxDouble
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsPen* wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
|
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
|
||||||
{
|
{
|
||||||
if ( !pen.Ok() || pen.GetStyle() == wxTRANSPARENT )
|
if ( !pen.Ok() || pen.GetStyle() == wxTRANSPARENT )
|
||||||
return NULL;
|
return wxNullGraphicsPen;
|
||||||
else
|
else
|
||||||
return new wxMacCoreGraphicsPen( this, pen );
|
{
|
||||||
|
wxGraphicsPen p;
|
||||||
|
p.SetRefData(new wxMacCoreGraphicsPenData( this, pen ));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsBrush* wxMacCoreGraphicsRenderer::CreateBrush(const wxBrush& brush )
|
wxGraphicsBrush wxMacCoreGraphicsRenderer::CreateBrush(const wxBrush& brush )
|
||||||
{
|
{
|
||||||
if ( !brush.Ok() || brush.GetStyle() == wxTRANSPARENT )
|
if ( !brush.Ok() || brush.GetStyle() == wxTRANSPARENT )
|
||||||
return NULL;
|
return wxNullGraphicsBrush;
|
||||||
else
|
else
|
||||||
return new wxMacCoreGraphicsBrush( this, brush );
|
{
|
||||||
|
wxGraphicsBrush p;
|
||||||
|
p.SetRefData(new wxMacCoreGraphicsBrushData( this, brush ));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
|
// sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
|
||||||
wxGraphicsBrush* wxMacCoreGraphicsRenderer::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
wxGraphicsBrush wxMacCoreGraphicsRenderer::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
|
||||||
const wxColour&c1, const wxColour&c2)
|
const wxColour&c1, const wxColour&c2)
|
||||||
{
|
{
|
||||||
wxMacCoreGraphicsBrush* brush = new wxMacCoreGraphicsBrush(this);
|
wxGraphicsBrush p;
|
||||||
brush->CreateLinearGradientBrush(x1, y1, x2, y2, c1, c2);
|
wxMacCoreGraphicsBrushData* d = new wxMacCoreGraphicsBrushData( this );
|
||||||
return brush;
|
d->CreateLinearGradientBrush(x1, y1, x2, y2, c1, c2);
|
||||||
|
p.SetRefData(d);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
|
// sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
|
||||||
// with radius r and color cColor
|
// with radius r and color cColor
|
||||||
wxGraphicsBrush* wxMacCoreGraphicsRenderer::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
wxGraphicsBrush wxMacCoreGraphicsRenderer::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
|
||||||
const wxColour &oColor, const wxColour &cColor)
|
const wxColour &oColor, const wxColour &cColor)
|
||||||
{
|
{
|
||||||
wxMacCoreGraphicsBrush* brush = new wxMacCoreGraphicsBrush(this);
|
wxGraphicsBrush p;
|
||||||
brush->CreateRadialGradientBrush(xo,yo,xc,yc,radius,oColor,cColor);
|
wxMacCoreGraphicsBrushData* d = new wxMacCoreGraphicsBrushData( this );
|
||||||
return brush;
|
d->CreateRadialGradientBrush(xo,yo,xc,yc,radius,oColor,cColor);
|
||||||
|
p.SetRefData(d);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets the font
|
// sets the font
|
||||||
wxGraphicsFont* wxMacCoreGraphicsRenderer::CreateFont( const wxFont &font , const wxColour &col )
|
wxGraphicsFont wxMacCoreGraphicsRenderer::CreateFont( const wxFont &font , const wxColour &col )
|
||||||
{
|
{
|
||||||
if ( font.Ok() )
|
if ( font.Ok() )
|
||||||
return new wxMacCoreGraphicsFont( this , font, col );
|
{
|
||||||
|
wxGraphicsFont p;
|
||||||
|
p.SetRefData(new wxMacCoreGraphicsFontData( this , font, col ));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return wxNullGraphicsFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user