From c85cfb1bc05016e7970b5255b0e122740024f85c Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Tue, 15 Jul 2014 16:30:10 +0000 Subject: [PATCH] Fix for drawing check box in the wxPG edit mode when RTL layout direction is set under wxMSW. Check box isn't drawn correctly in the edit mode under wxMSW due to the problems with RTL handling in wxAutoBufferedPaintDC and wxPaintDC (see #16254). We need to only draw the image, no text, so we can work around the problem by overriding layout direction to LTR. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/editors.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index e781bb9173..fe91c88fe5 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1551,11 +1551,23 @@ wxBitmap* wxSimpleCheckBox::ms_doubleBuffer = NULL; void wxSimpleCheckBox::OnPaint( wxPaintEvent& WXUNUSED(event) ) { - wxSize clientSize = GetClientSize(); + wxRect rect(GetClientSize()); +#ifdef __WXMSW__ + wxPaintDC dc(this); + // Under MSW, wxAutoBufferedPaintDC, wxPaintDC don't work fine with RTL, + // so we need to bypass this problem by setting LTR direction for this DC. + // Fortunately, we have only check box image to draw, no texts. + if ( dc.GetLayoutDirection() == wxLayout_RightToLeft ) + { + dc.SetLayoutDirection(wxLayout_LeftToRight); + // Some hack to prevent shifting the ouput image. + rect.x -= 2; + } +#else wxAutoBufferedPaintDC dc(this); - +#endif dc.Clear(); - wxRect rect(0,0,clientSize.x,clientSize.y); + rect.y += 1; rect.width += 1;