From 992671d2a76b18a53addf99350c04ee56f4dbaba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 9 Aug 2014 14:21:01 +0000 Subject: [PATCH] Fix wxDC::DrawRectangle() when using RTL in wxMSW. Extend the correct edge of the rectangle (always the physical right, not the logical right) to fix off by one errors in RTL mode, affecting notably wxGrid. See #16250. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77028 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/dc.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 7b58ee93fa..c9f8f35770 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1034,7 +1034,9 @@ void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h wxCoord x2 = x + width; wxCoord y2 = y + height; - wxCoord x2dev = XLOG2DEV(x2), + wxCoord x1dev = XLOG2DEV(x), + y1dev = YLOG2DEV(y), + x2dev = XLOG2DEV(x2), y2dev = YLOG2DEV(y2); // Windows (but not Windows CE) draws the filled rectangles without outline @@ -1043,12 +1045,18 @@ void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h #ifndef __WXWINCE__ if ( m_pen.IsTransparent() ) { - x2dev++; + // Right edge to be extended is "displayed right edge" + // and hence its device coordinates depend + // on layout direction and can be either x1 or x2. + if ( GetLayoutDirection() == wxLayout_RightToLeft ) + x1dev--; + else + x2dev++; y2dev++; } #endif // !__WXWINCE__ - (void)Rectangle(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), x2dev, y2dev); + (void)Rectangle(GetHdc(), x1dev, y1dev, x2dev, y2dev); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2);