Don't pop explicitly changed status messages.

Calls to SetStatusText() in between Push/PopStatusText() were simply lost
before, now the text explicitly changed by SetStatusText() is preserved by the
next call to PopStatusText().

This required adding a new virtual method, called DoUpdateStatusText(), which
is now implemented in all the derived classes instead of overriding
SetStatusText() (on the bright side, it doesn't need to do any checks already
done in the base class any more).

Also fix PushStatusText() to actually show the text being pushed at all under
wxMSW as a side effect.

And further reduce code duplication between wxStatusBarBase and the derived
classes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61624 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-08-06 00:01:43 +00:00
parent 0751510c21
commit 6cf6897100
13 changed files with 210 additions and 243 deletions

View File

@@ -126,7 +126,7 @@ bool wxStatusBar::Create(wxWindow *parent,
SetFieldsCount(1);
SubclassWin(m_hWnd);
// cache the DC instance used by UpdateFieldText:
// cache the DC instance used by DoUpdateStatusText:
// NOTE: create the DC before calling InheritAttributes() since
// it may result in a call to our SetFont()
m_pDC = new wxClientDC(this);
@@ -182,7 +182,7 @@ void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
wxStatusBarBase::SetFieldsCount(nFields, widths);
SetFieldsWidth();
MSWUpdateFieldsWidths();
// keep in synch also our m_tooltips array
@@ -204,10 +204,10 @@ void wxStatusBar::SetStatusWidths(int n, const int widths[])
{
wxStatusBarBase::SetStatusWidths(n, widths);
SetFieldsWidth();
MSWUpdateFieldsWidths();
}
void wxStatusBar::SetFieldsWidth()
void wxStatusBar::MSWUpdateFieldsWidths()
{
if ( m_panes.IsEmpty() )
return;
@@ -243,26 +243,10 @@ void wxStatusBar::SetFieldsWidth()
delete [] pWidths;
// FIXME: we may want to call UpdateFieldText() here since we may need to (de)ellipsize status texts
// FIXME: we may want to call DoUpdateStatusText() here since we may need to (de)ellipsize status texts
}
void wxStatusBar::SetStatusText(const wxString& strText, int nField)
{
wxCHECK_RET( (nField >= 0) && ((size_t)nField < m_panes.GetCount()),
"invalid statusbar field index" );
if ( strText == GetStatusText(nField) )
{
// don't call StatusBar_SetText() to avoid flicker
return;
}
wxStatusBarBase::SetStatusText(strText, nField);
UpdateFieldText(nField);
}
void wxStatusBar::UpdateFieldText(int nField)
void wxStatusBar::DoUpdateStatusText(int nField)
{
if (!m_pDC)
return;
@@ -482,7 +466,7 @@ void wxStatusBar::DoMoveWindow(int x, int y, int width, int height)
}
// adjust fields widths to the new size
SetFieldsWidth();
MSWUpdateFieldsWidths();
// we have to trigger wxSizeEvent if there are children window in status
// bar because GetFieldRect returned incorrect (not updated) values up to
@@ -580,7 +564,7 @@ wxStatusBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
if ( nMsg == WM_SIZE && needsEllipsization )
{
for (int i=0; i<GetFieldsCount(); i++)
UpdateFieldText(i);
DoUpdateStatusText(i);
// re-set the field text, in case we need to ellipsize
// (or de-ellipsize) some parts of it
}