From: Vadim Zeitlin Date: Mon, 22 Nov 2010 12:48:47 +0000 (+0000) Subject: Set the width of the last status bar pane correctly in wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8e76e931990cdfdce8bc32990e17896cf14d47cd Set the width of the last status bar pane correctly in wxMSW. The total width of status bar panes must add up to the size of the status bar as otherwise an extra unwanted border is drawn after the last pane and we did have this border for status bar with a size grip. So while we still use the width without the size grip for calculating the fields widths, pass the width with the size grip to Windows to prevent this from happening. Also, don't pretend that the last field stretches up to the status bar edge when it should end before the size grip and Windows even already helpfully does it for us. Closes #12655. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66236 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index 9df8eb782a..3e374ca695 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -213,8 +213,11 @@ void wxStatusBar::MSWUpdateFieldsWidths() widthAvailable -= extraWidth*(count - 1); // extra space between fields widthAvailable -= MSWGetMetrics().textMargin; // and for the last field - if ( HasFlag(wxSTB_SIZEGRIP) ) - widthAvailable -= MSWGetMetrics().gripWidth; + // Deal with the grip: we shouldn't overflow onto the space occupied by it + // so the effectively available space is smaller. + const int gripWidth = HasFlag(wxSTB_SIZEGRIP) ? MSWGetMetrics().gripWidth + : 0; + widthAvailable -= gripWidth; // distribute the available space (client width) among the various fields: @@ -232,6 +235,11 @@ void wxStatusBar::MSWUpdateFieldsWidths() pWidths[i] = nCurPos; } + // The total width of the panes passed to Windows must be equal to the + // total width available, including the grip. Otherwise we get an extra + // separator line just before it. + pWidths[count - 1] += gripWidth; + if ( !StatusBar_SetParts(GetHwnd(), count, pWidths) ) { wxLogLastError("StatusBar_SetParts"); @@ -429,14 +437,6 @@ bool wxStatusBar::GetFieldRect(int i, wxRect& rect) const wxCopyRECTToRect(r, rect); - // Windows seems to under-report the size of the last field rectangle, - // presumably in order to prevent the buggy applications from overflowing - // onto the size grip but we want to return the real size to wx users - if ( HasFlag(wxSTB_SIZEGRIP) && i == (int)m_panes.GetCount() - 1 ) - { - rect.width += MSWGetMetrics().gripWidth - MSWGetBorderWidth(); - } - return true; }