Introduce wxGraphicsPenInfo class
This commit is contained in:
committed by
Vadim Zeitlin
parent
bc562289c6
commit
2305604565
@@ -305,9 +305,11 @@ class wxMacCoreGraphicsPenData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public:
|
||||
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
||||
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info );
|
||||
~wxMacCoreGraphicsPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info );
|
||||
virtual void Apply( wxGraphicsContext* context );
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
|
||||
@@ -331,17 +333,40 @@ protected :
|
||||
|
||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) :
|
||||
wxGraphicsObjectRefData( renderer )
|
||||
{
|
||||
wxDash *dashes;
|
||||
int nb_dashes = pen.GetDashes(&dashes);
|
||||
InitFromPenInfo(renderer, wxGraphicsPenInfo()
|
||||
.Colour(pen.GetColour())
|
||||
.Width(pen.GetWidth())
|
||||
.Style(pen.GetStyle())
|
||||
.Stipple(*pen.GetStipple())
|
||||
.Dashes(nb_dashes, dashes)
|
||||
.Join(pen.GetJoin())
|
||||
.Cap(pen.GetCap())
|
||||
);
|
||||
}
|
||||
|
||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info ) :
|
||||
wxGraphicsObjectRefData( renderer )
|
||||
{
|
||||
InitFromPenInfo(renderer, info);
|
||||
}
|
||||
|
||||
void wxMacCoreGraphicsPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info )
|
||||
{
|
||||
Init();
|
||||
|
||||
m_color.reset( wxMacCreateCGColor( pen.GetColour() ) ) ;
|
||||
m_color.reset( wxMacCreateCGColor( info.GetColour() ) ) ;
|
||||
|
||||
// TODO: * m_dc->m_scaleX
|
||||
m_width = pen.GetWidth();
|
||||
m_width = info.GetWidthF();
|
||||
if (m_width < 0.0)
|
||||
m_width = info.GetWidth();
|
||||
if (m_width <= 0.0)
|
||||
m_width = (CGFloat) 0.1;
|
||||
|
||||
switch ( pen.GetCap() )
|
||||
switch ( info.GetCap() )
|
||||
{
|
||||
case wxCAP_ROUND :
|
||||
m_cap = kCGLineCapRound;
|
||||
@@ -360,7 +385,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( pen.GetJoin() )
|
||||
switch ( info.GetJoin() )
|
||||
{
|
||||
case wxJOIN_BEVEL :
|
||||
m_join = kCGLineJoinBevel;
|
||||
@@ -386,7 +411,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
||||
static const CGFloat dashed[] = { (CGFloat) 19.0 , (CGFloat) 9.0 };
|
||||
static const CGFloat dotted_dashed[] = { (CGFloat) 9.0 , (CGFloat) 6.0 , (CGFloat) 3.0 , (CGFloat) 3.0 };
|
||||
|
||||
switch ( pen.GetStyle() )
|
||||
switch ( info.GetStyle() )
|
||||
{
|
||||
case wxPENSTYLE_SOLID:
|
||||
break;
|
||||
@@ -415,7 +440,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
||||
|
||||
case wxPENSTYLE_USER_DASH:
|
||||
wxDash *dashes;
|
||||
m_count = pen.GetDashes( &dashes );
|
||||
m_count = info.GetDashes( &dashes );
|
||||
if ((dashes != NULL) && (m_count > 0))
|
||||
{
|
||||
m_userLengths = new CGFloat[m_count];
|
||||
@@ -434,7 +459,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
||||
|
||||
case wxPENSTYLE_STIPPLE:
|
||||
{
|
||||
wxBitmap* bmp = pen.GetStipple();
|
||||
wxBitmap* bmp = info.GetStipple();
|
||||
if ( bmp && bmp->IsOk() )
|
||||
{
|
||||
m_colorSpace.reset( CGColorSpaceCreatePattern( NULL ) );
|
||||
@@ -450,12 +475,12 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
||||
{
|
||||
m_isPattern = true;
|
||||
m_colorSpace.reset( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
|
||||
m_pattern.reset( (CGPatternRef) *( new HatchPattern( pen.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
||||
m_pattern.reset( (CGPatternRef) *( new HatchPattern( info.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
||||
m_patternColorComponents = new CGFloat[4] ;
|
||||
m_patternColorComponents[0] = (CGFloat) (pen.GetColour().Red() / 255.0);
|
||||
m_patternColorComponents[1] = (CGFloat) (pen.GetColour().Green() / 255.0);
|
||||
m_patternColorComponents[2] = (CGFloat) (pen.GetColour().Blue() / 255.0);
|
||||
m_patternColorComponents[3] = (CGFloat) (pen.GetColour().Alpha() / 255.0);
|
||||
m_patternColorComponents[0] = (CGFloat) (info.GetColour().Red() / 255.0);
|
||||
m_patternColorComponents[1] = (CGFloat) (info.GetColour().Green() / 255.0);
|
||||
m_patternColorComponents[2] = (CGFloat) (info.GetColour().Blue() / 255.0);
|
||||
m_patternColorComponents[3] = (CGFloat) (info.GetColour().Alpha() / 255.0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2538,6 +2563,8 @@ public :
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE ;
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE ;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
||||
|
||||
virtual wxGraphicsBrush
|
||||
@@ -2717,6 +2744,18 @@ wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
return wxNullGraphicsPen;
|
||||
else
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
p.SetRefData(new wxMacCoreGraphicsPenData( this, info ));
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsBrush wxMacCoreGraphicsRenderer::CreateBrush(const wxBrush& brush )
|
||||
{
|
||||
if ( !brush.IsOk() || brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT )
|
||||
|
Reference in New Issue
Block a user