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
@ -263,8 +263,12 @@ public:
|
|||||||
// draws a rounded rectangle
|
// draws a rounded rectangle
|
||||||
virtual void DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
|
virtual void DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
|
||||||
|
|
||||||
// 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)
|
||||||
};
|
};
|
||||||
|
@ -290,6 +290,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)
|
||||||
@ -446,15 +458,9 @@ void wxMacCoreGraphicsContext::ResetClip()
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
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 );
|
||||||
@ -479,14 +485,8 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillSt
|
|||||||
else if ( mode == kCGPathFillStroke )
|
else if ( mode == kCGPathFillStroke )
|
||||||
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