Preserve prior StatusBar contents when adding removing fields

(consistant with MSW behaviour).

Made m_statusSring a wxArrayString, furthur simplification may
be possible if someone is interested and has the time.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15988 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee
2002-06-30 23:53:58 +00:00
parent 7e55544629
commit 76880b8757
2 changed files with 28 additions and 15 deletions

View File

@@ -96,7 +96,7 @@ public:
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
protected: protected:
wxString * m_statusStrings; wxArrayString m_statusStrings;
int m_borderX; int m_borderX;
int m_borderY; int m_borderY;
wxFont m_defaultStatusBarFont; wxFont m_defaultStatusBarFont;
@@ -110,3 +110,5 @@ private:
#endif #endif
// _WX_GENERIC_STATUSBR_H_ // _WX_GENERIC_STATUSBR_H_
// vi:sts=4:sw=4:et

View File

@@ -53,7 +53,6 @@ END_EVENT_TABLE()
wxStatusBarGeneric::wxStatusBarGeneric() wxStatusBarGeneric::wxStatusBarGeneric()
{ {
m_statusStrings = (wxString *) NULL;
m_borderX = wxTHICK_LINE_BORDER; m_borderX = wxTHICK_LINE_BORDER;
m_borderY = wxTHICK_LINE_BORDER; m_borderY = wxTHICK_LINE_BORDER;
} }
@@ -63,17 +62,17 @@ wxStatusBarGeneric::~wxStatusBarGeneric()
# ifdef __WXMSW__ # ifdef __WXMSW__
SetFont(wxNullFont); SetFont(wxNullFont);
# endif // MSW # endif // MSW
if ( m_statusStrings )
delete[] m_statusStrings;
} }
bool wxStatusBarGeneric::Create(wxWindow *parent, bool wxStatusBarGeneric::Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_statusStrings = (wxString *) NULL; // If create is ever meant to be re-entrant over the life of
// an object we should:
// m_statusStrings.Empty();
m_borderX = wxTHICK_LINE_BORDER; m_borderX = wxTHICK_LINE_BORDER;
m_borderY = wxTHICK_LINE_BORDER; m_borderY = wxTHICK_LINE_BORDER;
@@ -108,13 +107,23 @@ bool wxStatusBarGeneric::Create(wxWindow *parent,
void wxStatusBarGeneric::SetFieldsCount(int number, const int *widths) void wxStatusBarGeneric::SetFieldsCount(int number, const int *widths)
{ {
if ( number != m_nFields ) wxASSERT_MSG( number >= 0,
{ _T("Yes, number should be a size_t and less than no fields is silly.") );
m_nFields = number;
delete[] m_statusStrings; // if( number > m_nFields )
m_statusStrings = new wxString[number];
} for( int i = m_nFields; i < number; ++i )
m_statusStrings.Add( wxEmptyString );
// if( number < m_nFields )
for (int i = m_nFields - 1; i >= number; --i)
m_statusStrings.Remove(i);
m_nFields = number;
wxASSERT_MSG( m_nFields == (int)m_statusStrings.GetCount(),
_T("This really should never happen, can we do away with m_nFields here?") );
SetStatusWidths(number, widths); SetStatusWidths(number, widths);
} }
@@ -396,3 +405,5 @@ void wxStatusBarGeneric::SetMinHeight(int height)
} }
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
// vi:sts=4:sw=4:et