From 89db201aba30d137d56fd3b51dd42cf8631e0423 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 8 Apr 2011 16:31:12 +0000 Subject: [PATCH] see #9715 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67417 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/graphics.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 7b02234574..05a385d90b 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -325,6 +325,8 @@ public: virtual void StrokePath( const wxGraphicsPath& p ); virtual void FillPath( const wxGraphicsPath& p , wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); + virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + // stroke lines connecting each of the points virtual void StrokeLines( size_t n, const wxPoint2DDouble *points); @@ -1362,6 +1364,31 @@ void wxGDIPlusContext::ResetClip() m_context->ResetClip(); } +void wxGDIPlusContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) +{ + if (m_composition == wxCOMPOSITION_DEST) + return; + + wxGDIPlusOffsetHelper helper( m_context , ShouldOffset() ); + Brush *brush = m_brush.IsNull() ? NULL : ((wxGDIPlusBrushData*)m_brush.GetRefData())->GetGDIPlusBrush(); + Pen *pen = m_pen.IsNull() ? NULL : ((wxGDIPlusPenData*)m_pen.GetGraphicsData())->GetGDIPlusPen(); + + if ( brush ) + { + // the offset is used to fill only the inside of the rectangle and not paint underneath + // its border which may influence a transparent Pen + REAL offset = 0; + if ( pen ) + offset = pen->GetWidth(); + m_context->FillRectangle( brush, (REAL)x + offset/2, (REAL)y + offset/2, (REAL)w - offset, (REAL)h - offset); + } + + if ( pen ) + { + m_context->DrawRectangle( pen, (REAL)x, (REAL)y, (REAL)w, (REAL)h ); + } +} + void wxGDIPlusContext::StrokeLines( size_t n, const wxPoint2DDouble *points) { if (m_composition == wxCOMPOSITION_DEST) -- 2.45.2