Refactor the code that decides if the 0.5 offset chousl be applied
into its own method git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42388 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
eb3e358db8
commit
de3cb39f85
@ -265,6 +265,10 @@ public:
|
|||||||
|
|
||||||
// wrappers using wxPoint2DDouble TODO
|
// wrappers using wxPoint2DDouble TODO
|
||||||
|
|
||||||
|
|
||||||
|
// helper to determine if a 0.5 offset should be applied for the drawing operation
|
||||||
|
virtual bool ShouldOffset() const { return false; }
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(wxGraphicsContext)
|
DECLARE_NO_COPY_CLASS(wxGraphicsContext)
|
||||||
DECLARE_ABSTRACT_CLASS(wxGraphicsContext)
|
DECLARE_ABSTRACT_CLASS(wxGraphicsContext)
|
||||||
};
|
};
|
||||||
|
@ -291,6 +291,18 @@ public:
|
|||||||
void SetNativeContext( CGContextRef cg );
|
void SetNativeContext( CGContextRef cg );
|
||||||
CGPathDrawingMode GetDrawingMode() const { return m_mode; }
|
CGPathDrawingMode GetDrawingMode() const { return m_mode; }
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool ShouldOffset() const
|
||||||
|
{
|
||||||
|
int penwidth = m_pen.GetWidth();
|
||||||
|
if ( penwidth == 0 )
|
||||||
|
penwidth = 1;
|
||||||
|
if ( m_pen.GetStyle() == wxTRANSPARENT )
|
||||||
|
penwidth = 0;
|
||||||
|
return ( penwidth % 2 ) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(wxMacCoreGraphicsContext)
|
DECLARE_NO_COPY_CLASS(wxMacCoreGraphicsContext)
|
||||||
DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsContext)
|
DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsContext)
|
||||||
|
|
||||||
@ -448,13 +460,7 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
|||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
int width = m_pen.GetWidth();
|
bool offset = ShouldOffset();
|
||||||
if ( width == 0 )
|
|
||||||
width = 1 ;
|
|
||||||
if ( m_pen.GetStyle() == wxTRANSPARENT )
|
|
||||||
width = 0 ;
|
|
||||||
|
|
||||||
bool offset = ( width % 2 ) == 1 ;
|
|
||||||
|
|
||||||
if ( offset )
|
if ( offset )
|
||||||
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
|
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
|
||||||
@ -480,13 +486,7 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillSt
|
|||||||
mode = kCGPathEOFillStroke;
|
mode = kCGPathEOFillStroke;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width = m_pen.GetWidth();
|
bool offset = ShouldOffset();
|
||||||
if ( width == 0 )
|
|
||||||
width = 1 ;
|
|
||||||
if ( m_pen.GetStyle() == wxTRANSPARENT )
|
|
||||||
width = 0 ;
|
|
||||||
|
|
||||||
bool offset = ( width % 2 ) == 1 ;
|
|
||||||
|
|
||||||
if ( offset )
|
if ( offset )
|
||||||
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
|
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
|
||||||
|
Loading…
Reference in New Issue
Block a user