From: Vadim Zeitlin Date: Fri, 17 Sep 2004 19:12:41 +0000 (+0000) Subject: fixed rounding errors in variable status bar panes widths computation (patch 1030021) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1a83b9bd10b7d92520c202e6ed6cff2015f13315 fixed rounding errors in variable status bar panes widths computation (patch 1030021) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29179 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/statbar.cpp b/src/common/statbar.cpp index 1ebaf0e3df..76278969ea 100644 --- a/src/common/statbar.cpp +++ b/src/common/statbar.cpp @@ -243,16 +243,7 @@ wxArrayInt wxStatusBarBase::CalculateAbsWidths(wxCoord widthTotal) const } // the amount of extra width we have per each var width field - int nVarWidth; - if ( nVarCount ) - { - int widthExtra = widthTotal - nTotalWidth; - nVarWidth = widthExtra > 0 ? widthExtra / nVarCount : 0; - } - else // no var width fields at all - { - nVarWidth = 0; - } + int widthExtra = widthTotal - nTotalWidth; // do fill the array for ( i = 0; i < m_nFields; i++ ) @@ -263,7 +254,10 @@ wxArrayInt wxStatusBarBase::CalculateAbsWidths(wxCoord widthTotal) const } else { - widths.Add(-m_statusWidths[i]*nVarWidth); + int nVarWidth = widthExtra > 0 ? (widthExtra * -m_statusWidths[i]) / nVarCount : 0; + nVarCount += m_statusWidths[i]; + widthExtra -= nVarWidth; + widths.Add(nVarWidth); } } }