X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0dba08dd3987303ff116bf77d5fb877b6d8f32d0..d8812c6e0e780fb2dae99bc352c5061f58793e14:/src/msw/statusbar.cpp diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index 69826207de..8b7092efe0 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -125,7 +125,11 @@ bool wxStatusBar::Create(wxWindow *parent, // 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; } @@ -135,7 +139,7 @@ wxStatusBar::~wxStatusBar() // 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) @@ -157,7 +161,7 @@ void wxStatusBar::SetStatusWidths(int n, const int widths[]) void wxStatusBar::SetFieldsWidth() { - if ( !m_nFields ) + if ( m_panes.IsEmpty() ) return; int aBorders[3]; @@ -166,17 +170,17 @@ void wxStatusBar::SetFieldsWidth() 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")); } @@ -185,7 +189,7 @@ void wxStatusBar::SetFieldsWidth() 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) ) @@ -196,24 +200,20 @@ void wxStatusBar::SetStatusText(const wxString& strText, int 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' @@ -225,7 +225,7 @@ void wxStatusBar::SetStatusText(const wxString& strText, int nField) 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; @@ -264,7 +264,7 @@ void wxStatusBar::SetMinHeight(int height) 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; @@ -305,10 +305,10 @@ wxSize wxStatusBar::DoGetBestSize() const // 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; @@ -380,7 +380,7 @@ void wxStatusBar::SetStatusStyles(int n, const int styles[]) { wxStatusBarBase::SetStatusStyles(n, styles); - if (n != m_nFields) + if (n != (int)m_panes.GetCount()) return; for (int i = 0; i < n; i++)