From 9814147718f1a227050b3cfc582cae5f03f076b3 Mon Sep 17 00:00:00 2001 From: Gilles Depeyrot Date: Thu, 21 Nov 2002 21:30:28 +0000 Subject: [PATCH] recompute width cache if client width has changed to take into account the fact that derived OnSize is run before cache has been cleared in own OnSize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/statusbr.h | 2 ++ src/generic/statusbr.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/wx/generic/statusbr.h b/include/wx/generic/statusbr.h index e685acacf1..4452f353ad 100644 --- a/include/wx/generic/statusbr.h +++ b/include/wx/generic/statusbr.h @@ -108,6 +108,8 @@ protected: wxArrayString m_statusStrings; + // the last known width of the client rect (used to rebuild cache) + int m_lastClientWidth; // the widths of the status bar panes in pixels wxArrayInt m_widthsAbs; diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index 1160f0a797..6926a245ae 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -300,11 +300,16 @@ bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const #endif // we cache m_widthsAbs between calls normally but it's cleared when the - // status widths change so recompute it if needed - if ( m_widthsAbs.IsEmpty() ) + // status widths change so recompute it if needed and also if client width + // has changed to take into account the fact that derived OnSize is run + // before cache has been cleared in own OnSize + if ( m_widthsAbs.IsEmpty() || (m_lastClientWidth != width) ) { wxConstCast(this, wxStatusBarGeneric)-> m_widthsAbs = CalculateAbsWidths(width); + // remember last width for which we have recomputed the widths in pixels + wxConstCast(this, wxStatusBarGeneric)-> + m_lastClientWidth = width; } rect.x = 0; @@ -382,7 +387,7 @@ void wxStatusBarGeneric::OnSize(wxSizeEvent& event) { // have to recompute the widths in pixels m_widthsAbs.Empty(); - + event.Skip(); }