// draws a rounded rectangle
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_ABSTRACT_CLASS(wxGraphicsContext)
};
void SetNativeContext( CGContextRef cg );
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_DYNAMIC_CLASS(wxMacCoreGraphicsContext)
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
{
- EnsureIsValid();
-
- int width = m_pen.GetWidth();
- if ( width == 0 )
- width = 1 ;
- if ( m_pen.GetStyle() == wxTRANSPARENT )
- width = 0 ;
-
- bool offset = ( width % 2 ) == 1 ;
+ EnsureIsValid();
+
+ bool offset = ShouldOffset();
if ( offset )
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );
else if ( mode == kCGPathFillStroke )
mode = kCGPathEOFillStroke;
}
-
- int width = m_pen.GetWidth();
- if ( width == 0 )
- width = 1 ;
- if ( m_pen.GetStyle() == wxTRANSPARENT )
- width = 0 ;
-
- bool offset = ( width % 2 ) == 1 ;
+
+ bool offset = ShouldOffset();
if ( offset )
CGContextTranslateCTM( m_cgContext, 0.5, 0.5 );