From ebbb5cb2666272ef839506f101f9f914df2312c2 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 11 Oct 2006 12:29:57 +0000 Subject: [PATCH] adding the 0.5 offset for odd pen widths git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41937 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dccg.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp index 150d697cce..f90a2864dc 100755 --- a/src/mac/carbon/dccg.cpp +++ b/src/mac/carbon/dccg.cpp @@ -266,8 +266,23 @@ void wxMacCGContext::Clip( const wxRegion ®ion ) void wxMacCGContext::StrokePath( const wxGraphicPath *p ) { const wxMacCGPath* path = dynamic_cast< const wxMacCGPath*>( p ) ; + + int width = m_pen.GetWidth(); + if ( width == 0 ) + width = 1 ; + if ( m_pen.GetStyle() == wxTRANSPARENT ) + width = 0 ; + + bool offset = ( width % 2 ) == 1 ; + + if ( offset ) + CGContextTranslateCTM( m_cgContext, 0.5, 0.5 ); + CGContextAddPath( m_cgContext , path->GetPath() ) ; CGContextStrokePath( m_cgContext ) ; + + if ( offset ) + CGContextTranslateCTM( m_cgContext, -0.5, -0.5 ); } void wxMacCGContext::DrawPath( const wxGraphicPath *p , int fillStyle ) @@ -283,8 +298,22 @@ void wxMacCGContext::DrawPath( const wxGraphicPath *p , int fillStyle ) mode = kCGPathEOFillStroke ; } + int width = m_pen.GetWidth(); + if ( width == 0 ) + width = 1 ; + if ( m_pen.GetStyle() == wxTRANSPARENT ) + width = 0 ; + + bool offset = ( width % 2 ) == 1 ; + + if ( offset ) + CGContextTranslateCTM( m_cgContext, 0.5, 0.5 ); + CGContextAddPath( m_cgContext , path->GetPath() ) ; CGContextDrawPath( m_cgContext , mode ) ; + + if ( offset ) + CGContextTranslateCTM( m_cgContext, -0.5, -0.5 ); } void wxMacCGContext::FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle ) @@ -1453,7 +1482,7 @@ void wxDC::SetPen( const wxPen &pen ) { if ( m_pen == pen ) return ; - + m_pen = pen; if ( m_graphicContext ) { -- 2.45.2