void wxStatusBar95::SetFieldsWidth() { if ( !m_nFields ) return; int aBorders[3]; SendMessage(GetHwnd(), SB_GETBORDERS, 0, (LPARAM)aBorders); int extraWidth = aBorders[2]; // space between fields wxArrayInt widthsAbs = CalculateAbsWidths(GetClientSize().x - extraWidth*(m_nFields - 1)); int *pWidths = new int[m_nFields]; int nCurPos = 0; for ( int i = 0; i < m_nFields; i++ ) { nCurPos += widthsAbs[i] + extraWidth; pWidths[i] = nCurPos; } if ( !StatusBar_SetParts(GetHwnd(), m_nFields, pWidths) ) { wxLogLastError(wxT("StatusBar_SetParts")); } delete [] pWidths; }
void wxStatusBar::MSWUpdateFieldsWidths() { if ( m_panes.IsEmpty() ) return; const int count = m_panes.GetCount(); const int extraWidth = MSWGetBorderWidth() + MSWGetMetrics().textMargin; // compute the effectively available amount of space: int widthAvailable = GetClientSize().x; // start with the entire width widthAvailable -= extraWidth*(count - 1); // extra space between fields widthAvailable -= MSWGetMetrics().textMargin; // and for the last field // Deal with the grip: we shouldn't overflow onto the space occupied by it // so the effectively available space is smaller. const int gripWidth = HasFlag(wxSTB_SIZEGRIP) ? MSWGetMetrics().gripWidth : 0; widthAvailable -= gripWidth; // distribute the available space (client width) among the various fields: wxArrayInt widthsAbs = CalculateAbsWidths(widthAvailable); // update the field widths in the native control: int *pWidths = new int[count]; int nCurPos = 0; int i; for ( i = 0; i < count; i++ ) { nCurPos += widthsAbs[i] + extraWidth; pWidths[i] = nCurPos; } // The total width of the panes passed to Windows must be equal to the // total width available, including the grip. Otherwise we get an extra // separator line just before it. pWidths[count - 1] += gripWidth; if ( !StatusBar_SetParts(GetHwnd(), count, pWidths) ) { wxLogLastError("StatusBar_SetParts"); } // Now that all parts have been created, set their text. for ( i = 0; i < count; i++ ) { DoUpdateStatusText(i); } delete [] pWidths; }