More 0.5 pixel offset fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44675 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2007-03-08 00:25:37 +00:00
parent 7d28058dd8
commit 5ab99c0f69
2 changed files with 27 additions and 0 deletions

View File

@@ -693,6 +693,13 @@ void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
if (w == 0 || h == 0) if (w == 0 || h == 0)
return; return;
if ( m_graphicContext->ShouldOffset() )
{
// if we are offsetting the entire rectangle is moved 0.5, so the
// border line gets off by 1
w -= 1;
h -= 1;
}
m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius); m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius);
} }
@@ -703,6 +710,13 @@ void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
if ( !m_logicalFunctionSupported ) if ( !m_logicalFunctionSupported )
return; return;
if ( m_graphicContext->ShouldOffset() )
{
// if we are offsetting the entire rectangle is moved 0.5, so the
// border line gets off by 1
w -= 1;
h -= 1;
}
m_graphicContext->DrawEllipse(x,y,w,h); m_graphicContext->DrawEllipse(x,y,w,h);
} }

View File

@@ -315,6 +315,7 @@ public:
virtual void GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height, virtual void GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height,
wxDouble *descent, wxDouble *externalLeading ) const; wxDouble *descent, wxDouble *externalLeading ) const;
virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const; virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const;
virtual bool ShouldOffset() const;
private: private:
void Init(); void Init();
@@ -1196,6 +1197,18 @@ void wxGDIPlusContext::GetPartialTextExtents(const wxString& text, wxArrayDouble
} }
} }
bool wxGDIPlusContext::ShouldOffset() const
{
int penwidth = 0 ;
if ( !m_pen.IsNull() )
{
penwidth = (int)((wxGDIPlusPenData*)m_pen.GetRefData())->GetWidth();
if ( penwidth == 0 )
penwidth = 1;
}
return ( penwidth % 2 ) == 1;
}
void* wxGDIPlusContext::GetNativeContext() void* wxGDIPlusContext::GetNativeContext()
{ {
return m_context; return m_context;