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
This commit is contained in:
Gilles Depeyrot
2002-11-21 21:30:28 +00:00
parent af68a70285
commit 9814147718
2 changed files with 10 additions and 3 deletions

View File

@@ -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;

View File

@@ -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();
}