From bddab017c6c78f1dab68745a532996bab37f3ee8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Sep 2013 23:49:15 +0000 Subject: [PATCH] Improve drawing of the tree item buttons in the generic renderer. Draw the "-" and "+" signs always properly centered. Closes #15526. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/renderg.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/generic/renderg.cpp b/src/generic/renderg.cpp index 93354ab404..4d411dd12d 100644 --- a/src/generic/renderg.cpp +++ b/src/generic/renderg.cpp @@ -467,12 +467,20 @@ wxRendererGeneric::DrawTreeItemButton(wxWindow * WXUNUSED(win), dc.DrawRectangle(rect); + // Make sure that the sign is properly centered by always using an + // odd-sized rectangle for it. + wxRect signRect(rect); + if ( !(signRect.x % 2) ) + signRect.x--; + if ( !(signRect.y % 2) ) + signRect.y--; + // black lines - const wxCoord xMiddle = rect.x + rect.width/2; - const wxCoord yMiddle = rect.y + rect.height/2; + const wxCoord xMiddle = signRect.x + signRect.width/2; + const wxCoord yMiddle = signRect.y + signRect.height/2; // half of the length of the horz lines in "-" and "+" - const wxCoord halfWidth = rect.width/2 - 2; + const wxCoord halfWidth = signRect.width/2 - 2; dc.SetPen(*wxBLACK_PEN); dc.DrawLine(xMiddle - halfWidth, yMiddle, xMiddle + halfWidth + 1, yMiddle); @@ -480,7 +488,7 @@ wxRendererGeneric::DrawTreeItemButton(wxWindow * WXUNUSED(win), if ( !(flags & wxCONTROL_EXPANDED) ) { // turn "-" into "+" - const wxCoord halfHeight = rect.height/2 - 2; + const wxCoord halfHeight = signRect.height/2 - 2; dc.DrawLine(xMiddle, yMiddle - halfHeight, xMiddle, yMiddle + halfHeight + 1); } -- 2.45.2