// we must refresh the frame size when the statusbar is created, because
// its client area might change
- SendSizeEventToParent();
+ //
+ // notice that we must post the event, not send it, as the frame doesn't
+ // know that we're its status bar yet so laying it out right now wouldn't
+ // work correctly, we need to wait until we return to the main loop
+ PostSizeEventToParent();
return true;
}
// we must refresh the frame size when the statusbar is deleted but the
// frame is not - otherwise statusbar leaves a hole in the place it used to
// occupy
- SendSizeEventToParent();
+ PostSizeEventToParent();
}
void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
void wxStatusBar::SetFieldsWidth()
{
- if ( !m_nFields )
+ if ( m_panes.IsEmpty() )
return;
int aBorders[3];
int extraWidth = aBorders[2]; // space between fields
wxArrayInt widthsAbs =
- CalculateAbsWidths(GetClientSize().x - extraWidth*(m_nFields - 1));
+ CalculateAbsWidths(GetClientSize().x - extraWidth*(m_panes.GetCount() - 1));
- int *pWidths = new int[m_nFields];
+ int *pWidths = new int[m_panes.GetCount()];
int nCurPos = 0;
- for ( int i = 0; i < m_nFields; i++ ) {
+ for ( size_t i = 0; i < m_panes.GetCount(); i++ ) {
nCurPos += widthsAbs[i] + extraWidth;
pWidths[i] = nCurPos;
}
- if ( !StatusBar_SetParts(GetHwnd(), m_nFields, pWidths) ) {
+ if ( !StatusBar_SetParts(GetHwnd(), m_panes.GetCount(), pWidths) ) {
wxLogLastError(wxT("StatusBar_SetParts"));
}
void wxStatusBar::SetStatusText(const wxString& strText, int nField)
{
- wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
+ wxCHECK_RET( (nField >= 0) && ((size_t)nField < m_panes.GetCount()),
_T("invalid statusbar field index") );
if ( strText == GetStatusText(nField) )
// Get field style, if any
int style;
- if (m_statusStyles)
+ switch(m_panes[nField].nStyle)
{
- switch(m_statusStyles[nField])
- {
- case wxSB_RAISED:
- style = SBT_POPOUT;
- break;
- case wxSB_FLAT:
- style = SBT_NOBORDERS;
- break;
- case wxSB_NORMAL:
- default:
- style = 0;
- break;
- }
- }
- else
+ case wxSB_RAISED:
+ style = SBT_POPOUT;
+ break;
+ case wxSB_FLAT:
+ style = SBT_NOBORDERS;
+ break;
+
+ case wxSB_NORMAL:
+ default:
style = 0;
+ break;
+ }
// Pass both field number and style. MSDN library doesn't mention
// that nField and style have to be 'ORed'
wxString wxStatusBar::GetStatusText(int nField) const
{
- wxCHECK_MSG( (nField >= 0) && (nField < m_nFields), wxEmptyString,
+ wxCHECK_MSG( (nField >= 0) && ((size_t)nField < m_panes.GetCount()), wxEmptyString,
_T("invalid statusbar field index") );
wxString str;
bool wxStatusBar::GetFieldRect(int i, wxRect& rect) const
{
- wxCHECK_MSG( (i >= 0) && (i < m_nFields), false,
+ wxCHECK_MSG( (i >= 0) && ((size_t)i < m_panes.GetCount()), false,
_T("invalid statusbar field index") );
RECT r;
// calculate width
int width = 0;
- for ( int i = 0; i < m_nFields; ++i )
+ for ( size_t i = 0; i < m_panes.GetCount(); ++i )
{
- int widthField = m_statusWidths ? m_statusWidths[i]
- : DEFAULT_FIELD_WIDTH;
+ int widthField =
+ m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].nWidth;
if ( widthField >= 0 )
{
width += widthField;
{
wxStatusBarBase::SetStatusStyles(n, styles);
- if (n != m_nFields)
+ if (n != (int)m_panes.GetCount())
return;
for (int i = 0; i < n; i++)