]> git.saurik.com Git - wxWidgets.git/commitdiff
Set the width of the last status bar pane correctly in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 22 Nov 2010 12:48:47 +0000 (12:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 22 Nov 2010 12:48:47 +0000 (12:48 +0000)
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

src/msw/statusbar.cpp

index 9df8eb782a8bd11509769fb8fe5166eac790d46d..3e374ca695bea798ee182036d70ff6a6f6ea9730 100644 (file)
@@ -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;
 }