#include "wx/pen.h"
#include "wx/arrstr.h"
+
+// ----------------------------------------------------------------------------
+// wxStatusBarGeneric
+// ----------------------------------------------------------------------------
+
class WXDLLIMPEXP_CORE wxStatusBarGeneric : public wxStatusBarBase
{
public:
// common part of all ctors
void Init();
+ // the array of the currently displayed strings
wxArrayString m_statusStrings;
// the last known width of the client rect (used to rebuild cache)
int m_lastClientWidth;
- // the widths of the status bar panes in pixels
+
+ // the absolute widths of the status bar panes in pixels
wxArrayInt m_widthsAbs;
int m_borderX;
protected:
void CopyFieldsWidth(const int widths[]);
void SetFieldsWidth();
-
+/*
// store the text in the status bar
wxListString **StatusTextBuffer;
void SetStatusBufferText(const wxString& text, int number);
wxListString *GetStatusBufferStack(int i) const;
void DeleteStatusBuffer();
+ TODO: reuse wxStatusBarBase's stack routines instead of reimplementing them here
+*/
+
// override base class virtual
void DoMoveWindow(int x, int y, int width, int height);
extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr[];
-WX_DECLARE_LIST(wxString, wxListString);
-
// ----------------------------------------------------------------------------
// wxStatusBar constants
// ----------------------------------------------------------------------------
#define wxSB_FLAT 0x0001
#define wxSB_RAISED 0x0002
+// ----------------------------------------------------------------------------
+// wxStatusBarPane: an helper for wxStatusBar
+// ----------------------------------------------------------------------------
+
+class wxStatusBarPane
+{
+public:
+ wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0)
+ : nStyle(style), nWidth(width) {}
+
+ int nStyle;
+ int nWidth; // the width maybe negative, indicating a variable-width field
+
+ // this is the array of the stacked strings of this pane; note that this
+ // stack does not include the string currently displayed in this pane
+ // as it's stored in the native status bar control
+ wxArrayString arrStack;
+};
+
+WX_DECLARE_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray);
+
// ----------------------------------------------------------------------------
// wxStatusBar: a window near the bottom of the frame used for status info
// ----------------------------------------------------------------------------
// set the number of fields and call SetStatusWidths(widths) if widths are
// given
virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
- int GetFieldsCount() const { return m_nFields; }
+ int GetFieldsCount() const { return m_panes.GetCount(); }
// field text
// ----------
protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
- // set the widths array to NULL
- void InitWidths();
-
- // free the status widths arrays
- void FreeWidths();
-
- // reset the widths
- void ReinitWidths() { FreeWidths(); InitWidths(); }
-
- // same, for field styles
- void InitStyles();
- void FreeStyles();
- void ReinitStyles() { FreeStyles(); InitStyles(); }
-
- // same, for text stacks
- void InitStacks();
- void FreeStacks();
- void ReinitStacks() { FreeStacks(); InitStacks(); }
-
// calculate the real field widths for the given total available size
wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const;
- // use these functions to access the stacks of field strings
- wxListString *GetStatusStack(int i) const;
- wxListString *GetOrCreateStatusStack(int i);
-
- // the current number of fields
- int m_nFields;
-
- // the widths of the fields in pixels if !NULL, all fields have the same
- // width otherwise
- int *m_statusWidths;
+ // the array with the pane infos:
+ wxStatusBarPaneArray m_panes;
- // the styles of the fields
- int *m_statusStyles;
-
- // stacks of previous values for PushStatusText/PopStatusText
- // this is created on demand, use GetStatusStack/GetOrCreateStatusStack
- wxListString **m_statusTextStacks;
+ // if true overrides the width info of the wxStatusBarPanes
+ bool m_bSameWidthForAllPanes;
DECLARE_NO_COPY_CLASS(wxStatusBarBase)
};
#if defined(__WXUNIVERSAL__)
#define wxStatusBarUniv wxStatusBar
-
#include "wx/univ/statusbr.h"
#elif defined(__WXPALMOS__)
#define wxStatusBarPalm wxStatusBar
-
#include "wx/palmos/statusbr.h"
#elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
#include "wx/msw/statusbar.h"
#elif defined(__WXMAC__)
#define wxStatusBarMac wxStatusBar
-
#include "wx/generic/statusbr.h"
#include "wx/osx/statusbr.h"
#else
#define wxStatusBarGeneric wxStatusBar
-
#include "wx/generic/statusbr.h"
#endif
#include "wx/arrstr.h"
// ----------------------------------------------------------------------------
-// wxStatusBar: a window near the bottom of the frame used for status info
+// wxStatusBarUniv: a window near the bottom of the frame used for status info
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxStatusBarUniv : public wxStatusBarBase,
void Init();
private:
- // the status fields strings
+ // the current status fields strings
wxArrayString m_statusText;
// the absolute status fields widths
// Name: src/common/statbar.cpp
// Purpose: wxStatusBarBase implementation
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by: Francesco Montorsi
// Created: 14.10.01
// RCS-ID: $Id$
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
#include "wx/frame.h"
#endif //WX_PRECOMP
-#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxListString)
-
const char wxStatusBarNameStr[] = "statusBar";
+
// ============================================================================
// wxStatusBarBase implementation
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxWindow)
+#include <wx/arrimpl.cpp> // This is a magic incantation which must be done!
+WX_DEFINE_OBJARRAY(wxStatusBarPaneArray);
+
+
// ----------------------------------------------------------------------------
// ctor/dtor
// ----------------------------------------------------------------------------
wxStatusBarBase::wxStatusBarBase()
{
- m_nFields = 0;
-
- InitWidths();
- InitStacks();
- InitStyles();
+ m_bSameWidthForAllPanes = true;
}
wxStatusBarBase::~wxStatusBarBase()
{
- FreeWidths();
- FreeStacks();
- FreeStyles();
-
// notify the frame that it doesn't have a status bar any longer to avoid
// dangling pointers
- wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
+ wxFrame *frame = dynamic_cast<wxFrame*>(GetParent());
if ( frame && frame->GetStatusBar() == this )
- {
frame->SetStatusBar(NULL);
- }
-}
-
-// ----------------------------------------------------------------------------
-// widths array handling
-// ----------------------------------------------------------------------------
-
-void wxStatusBarBase::InitWidths()
-{
- m_statusWidths = NULL;
-}
-
-void wxStatusBarBase::FreeWidths()
-{
- delete [] m_statusWidths;
-}
-
-// ----------------------------------------------------------------------------
-// styles array handling
-// ----------------------------------------------------------------------------
-
-void wxStatusBarBase::InitStyles()
-{
- m_statusStyles = NULL;
-}
-
-void wxStatusBarBase::FreeStyles()
-{
- delete [] m_statusStyles;
}
// ----------------------------------------------------------------------------
bool refresh = false;
- if ( number != m_nFields )
+ if ( (size_t)number > m_panes.GetCount() )
{
- // copy stacks if present
- if(m_statusTextStacks)
- {
- wxListString **newStacks = new wxListString*[number];
- size_t i, j, max = wxMin(number, m_nFields);
-
- // copy old stacks
- for(i = 0; i < max; ++i)
- newStacks[i] = m_statusTextStacks[i];
- // free old stacks in excess
- for(j = i; j < (size_t)m_nFields; ++j)
- {
- if(m_statusTextStacks[j])
- {
- m_statusTextStacks[j]->Clear();
- delete m_statusTextStacks[j];
- }
- }
- // initialize new stacks to NULL
- for(j = i; j < (size_t)number; ++j)
- newStacks[j] = 0;
-
- m_statusTextStacks = newStacks;
- }
-
- // Resize styles array
- if (m_statusStyles)
- {
- int *oldStyles = m_statusStyles;
- m_statusStyles = new int[number];
- int i, max = wxMin(number, m_nFields);
-
- // copy old styles
- for (i = 0; i < max; ++i)
- m_statusStyles[i] = oldStyles[i];
-
- // initialize new styles to wxSB_NORMAL
- for (i = max; i < number; ++i)
- m_statusStyles[i] = wxSB_NORMAL;
+ wxStatusBarPane newPane;
- // free old styles
- delete [] oldStyles;
- }
-
-
- m_nFields = number;
-
- ReinitWidths();
-
- refresh = true;
+ // add more entries with the default style and zero width
+ // (this will be set later)
+ for (size_t i = m_panes.GetCount(); i < (size_t)number; ++i)
+ m_panes.Add(newPane);
}
- //else: keep the old m_statusWidths if we had them
+ else if ( (size_t)number < m_panes.GetCount() )
+ {
+ // remove entries in excess
+ m_panes.RemoveAt(number, m_panes.GetCount()-number);
+ }
+
+ refresh = true;
if ( widths )
{
{
wxCHECK_RET( widths, _T("NULL pointer in SetStatusWidths") );
- wxASSERT_MSG( n == m_nFields, _T("field number mismatch") );
+ wxASSERT_MSG( (size_t)n == m_panes.GetCount(), _T("field number mismatch") );
- if ( !m_statusWidths )
- m_statusWidths = new int[m_nFields];
+ for ( size_t i = 0; i < m_panes.GetCount(); i++ )
+ m_panes[i].nWidth = widths[i];
- for ( int i = 0; i < m_nFields; i++ )
- {
- m_statusWidths[i] = widths[i];
- }
+ m_bSameWidthForAllPanes = false;
// update the display after the widths changed
Refresh();
{
wxCHECK_RET( styles, _T("NULL pointer in SetStatusStyles") );
- wxASSERT_MSG( n == m_nFields, _T("field number mismatch") );
+ wxASSERT_MSG( (size_t)n == m_panes.GetCount(), _T("field number mismatch") );
- if ( !m_statusStyles )
- m_statusStyles = new int[m_nFields];
-
- for ( int i = 0; i < m_nFields; i++ )
- {
- m_statusStyles[i] = styles[i];
- }
+ for ( size_t i = 0; i < m_panes.GetCount(); i++ )
+ m_panes[i].nStyle = styles[i];
// update the display after the widths changed
Refresh();
{
wxArrayInt widths;
- if ( m_statusWidths == NULL )
+ if ( m_bSameWidthForAllPanes )
{
- if ( m_nFields )
- {
- // Default: all fields have the same width. This is not always
- // possible to do exactly (if widthTotal is not divisible by
- // m_nFields) - if that happens, we distribute the extra pixels
- // among all fields:
- int widthToUse = widthTotal;
-
- for ( int i = m_nFields; i > 0; i-- )
- {
- // divide the unassigned width evently between the
- // not yet processed fields:
- int w = widthToUse / i;
- widths.Add(w);
- widthToUse -= w;
- }
+ // Default: all fields have the same width. This is not always
+ // possible to do exactly (if widthTotal is not divisible by
+ // m_panes.GetCount()) - if that happens, we distribute the extra
+ // pixels among all fields:
+ int widthToUse = widthTotal;
+ for ( size_t i = m_panes.GetCount(); i > 0; i-- )
+ {
+ // divide the unassigned width evently between the
+ // not yet processed fields:
+ int w = widthToUse / i;
+ widths.Add(w);
+ widthToUse -= w;
}
- //else: we're empty anyhow
}
- else // have explicit status widths
+ else // do not override explicit pane widths
{
// calculate the total width of all the fixed width fields and the
// total number of var field widths counting with multiplicity
- int nTotalWidth = 0,
- nVarCount = 0,
- i;
- for ( i = 0; i < m_nFields; i++ )
+ size_t nTotalWidth = 0,
+ nVarCount = 0,
+ i;
+
+ for ( i = 0; i < m_panes.GetCount(); i++ )
{
- if ( m_statusWidths[i] >= 0 )
- {
- nTotalWidth += m_statusWidths[i];
- }
+ if ( m_panes[i].nWidth >= 0 )
+ nTotalWidth += m_panes[i].nWidth;
else
- {
- nVarCount += -m_statusWidths[i];
- }
+ nVarCount += -m_panes[i].nWidth;
}
// the amount of extra width we have per each var width field
int widthExtra = widthTotal - nTotalWidth;
// do fill the array
- for ( i = 0; i < m_nFields; i++ )
+ for ( i = 0; i < m_panes.GetCount(); i++ )
{
- if ( m_statusWidths[i] >= 0 )
- {
- widths.Add(m_statusWidths[i]);
- }
+ if ( m_panes[i].nWidth >= 0 )
+ widths.Add(m_panes[i].nWidth);
else
{
- int nVarWidth = widthExtra > 0 ? (widthExtra * -m_statusWidths[i]) / nVarCount : 0;
- nVarCount += m_statusWidths[i];
+ int nVarWidth = widthExtra > 0 ? (widthExtra * (-m_panes[i].nWidth)) / nVarCount : 0;
+ nVarCount += m_panes[i].nWidth;
widthExtra -= nVarWidth;
widths.Add(nVarWidth);
}
}
// ----------------------------------------------------------------------------
-// text stacks handling
-// ----------------------------------------------------------------------------
-
-void wxStatusBarBase::InitStacks()
-{
- m_statusTextStacks = NULL;
-}
-
-void wxStatusBarBase::FreeStacks()
-{
- if ( !m_statusTextStacks )
- return;
-
- for ( size_t i = 0; i < (size_t)m_nFields; ++i )
- {
- if ( m_statusTextStacks[i] )
- {
- wxListString& t = *m_statusTextStacks[i];
- WX_CLEAR_LIST(wxListString, t);
- delete m_statusTextStacks[i];
- }
- }
-
- delete[] m_statusTextStacks;
-}
-
-// ----------------------------------------------------------------------------
-// text stacks
+// status text stacks
// ----------------------------------------------------------------------------
void wxStatusBarBase::PushStatusText(const wxString& text, int number)
{
- wxListString* st = GetOrCreateStatusStack(number);
- // This long-winded way around avoids an internal compiler error
- // in VC++ 6 with RTTI enabled
- wxString tmp1(GetStatusText(number));
- wxString* tmp = new wxString(tmp1);
- st->Insert(tmp);
+ // save current status text in the stack
+ m_panes[number].arrStack.push_back(GetStatusText(number));
+
+ // update current status text
SetStatusText(text, number);
}
void wxStatusBarBase::PopStatusText(int number)
{
- wxListString *st = GetStatusStack(number);
- wxCHECK_RET( st, _T("Unbalanced PushStatusText/PopStatusText") );
- wxListString::compatibility_iterator top = st->GetFirst();
-
- SetStatusText(*top->GetData(), number);
- delete top->GetData();
- st->Erase(top);
- if(st->GetCount() == 0)
- {
- delete st;
- m_statusTextStacks[number] = 0;
- }
-}
-
-wxListString *wxStatusBarBase::GetStatusStack(int i) const
-{
- if(!m_statusTextStacks)
- return 0;
- return m_statusTextStacks[i];
-}
-
-wxListString *wxStatusBarBase::GetOrCreateStatusStack(int i)
-{
- if(!m_statusTextStacks)
- {
- m_statusTextStacks = new wxListString*[m_nFields];
+ wxString text = m_panes[number].arrStack.back();
+ m_panes[number].arrStack.pop_back(); // also remove it from the stack
- size_t j;
- for(j = 0; j < (size_t)m_nFields; ++j) m_statusTextStacks[j] = 0;
- }
-
- if(!m_statusTextStacks[i])
- {
- m_statusTextStacks[i] = new wxListString();
- }
-
- return m_statusTextStacks[i];
+ // restore the popped status text in the pane
+ SetStatusText(text, number);
}
#endif // wxUSE_STATUSBAR
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarGeneric, wxWindow)
#endif // wxUSE_NATIVE_STATUSBAR
+// Default status border dimensions
+#define wxTHICK_LINE_BORDER 2
+
+
+// ----------------------------------------------------------------------------
+// wxStatusBarGeneric
+// ----------------------------------------------------------------------------
+
BEGIN_EVENT_TABLE(wxStatusBarGeneric, wxWindow)
EVT_PAINT(wxStatusBarGeneric::OnPaint)
EVT_LEFT_DOWN(wxStatusBarGeneric::OnLeftDown)
EVT_SYS_COLOUR_CHANGED(wxStatusBarGeneric::OnSysColourChanged)
END_EVENT_TABLE()
-// Default status border dimensions
-#define wxTHICK_LINE_BORDER 2
-
void wxStatusBarGeneric::Init()
{
m_borderX = wxTHICK_LINE_BORDER;
return true;
}
-
wxSize wxStatusBarGeneric::DoGetBestSize() const
{
int width, height;
{
wxASSERT_MSG( number >= 0, _T("negative number of fields in wxStatusBar?") );
- int i;
- for(i = m_nFields; i < number; ++i)
+ // enlarge the m_statusStrings array if needed:
+ for (size_t i = m_panes.GetCount(); i < (size_t)number; ++i)
m_statusStrings.Add( wxEmptyString );
- for (i = m_nFields - 1; i >= number; --i)
- m_statusStrings.RemoveAt(i);
+ // shrink the m_statusStrings array if needed:
+ for (int j = (int)m_panes.GetCount() - 1; j >= number; --j)
+ m_statusStrings.RemoveAt(j);
// forget the old cached pixel widths
m_widthsAbs.Empty();
wxStatusBarBase::SetFieldsCount(number, widths);
- wxASSERT_MSG( m_nFields == (int)m_statusStrings.GetCount(),
- _T("This really should never happen, can we do away with m_nFields here?") );
+ wxASSERT_MSG( m_panes.GetCount() == m_statusStrings.GetCount(),
+ _T("This really should never happen, can we do away with m_panes.GetCount() here?") );
}
void wxStatusBarGeneric::SetStatusText(const wxString& text, int number)
{
- wxCHECK_RET( (number >= 0) && (number < m_nFields),
+ wxCHECK_RET( (number >= 0) && ((size_t)number < m_panes.GetCount()),
_T("invalid status bar field index") );
wxString oldText = m_statusStrings[number];
wxString wxStatusBarGeneric::GetStatusText(int n) const
{
- wxCHECK_MSG( (n >= 0) && (n < m_nFields), wxEmptyString,
+ wxCHECK_MSG( (n >= 0) && ((size_t)n < m_panes.GetCount()), wxEmptyString,
_T("invalid status bar field index") );
return m_statusStrings[n];
void wxStatusBarGeneric::SetStatusWidths(int n, const int widths_field[])
{
- // only set status widths, when n == number of statuswindows
- wxCHECK_RET( n == m_nFields, _T("status bar field count mismatch") );
+ // only set status widths when n == number of statuswindows
+ wxCHECK_RET( (size_t)n == m_panes.GetCount(), _T("status bar field count mismatch") );
// delete the old widths in any case - this function may be used to reset
// the widths to the default (all equal)
// MBN: this is incompatible with at least wxMSW and wxMAC and not
// documented, but let's keep it for now
- ReinitWidths();
+ m_bSameWidthForAllPanes = true;
+ // FM: what MBN's comment is saying is that allowing widths_field = NULL
+ // only for wxStatusBarGeneric is not documented...
// forget the old cached pixel widths
m_widthsAbs.Empty();
dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
- for (int i = 0; i < m_nFields; i ++)
+ for (size_t i = 0; i < m_panes.GetCount(); i ++)
DrawField(dc, i);
}
wxRect rect;
GetFieldRect(i, rect);
- int style = wxSB_NORMAL;
- if (m_statusStyles)
- style = m_statusStyles[i];
-
+ int style = m_panes[i].nStyle;
if (style != wxSB_FLAT)
{
// Draw border
// Get the position and size of the field's internal bounding rectangle
bool wxStatusBarGeneric::GetFieldRect(int n, wxRect& rect) const
{
- wxCHECK_MSG( (n >= 0) && (n < m_nFields), false,
+ wxCHECK_MSG( (n >= 0) && ((size_t)n < m_panes.GetCount()), false,
_T("invalid status bar field index") );
// FIXME: workarounds for OS/2 bugs have nothing to do here (VZ)
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 ( int 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"));
}
// 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) && (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) && (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 ( int 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 != m_panes.GetCount())
return;
for (int i = 0; i < n; i++)
void wxStatusBarMac::SetStatusText(const wxString& text, int number)
{
- wxCHECK_RET( (number >= 0) && (number < m_nFields),
+ wxCHECK_RET( (number >= 0) && ((size_t)number < m_panes.GetCount()),
wxT("invalid status bar field index") );
if ( m_statusStrings[number] == text )
dc.DrawLine(0, 0, w, 0);
}
- int i;
if ( GetFont().Ok() )
dc.SetFont(GetFont());
dc.SetBackgroundMode(wxTRANSPARENT);
- for ( i = 0; i < m_nFields; i ++ )
+ for ( size_t i = 0; i < m_panes.GetCount(); i ++ )
DrawField(dc, i);
}
// the total width for the fields doesn't include the borders between
// them
m_widthsAbs = CalculateAbsWidths(rect.width -
- *borderBetweenFields*(m_nFields - 1));
+ *borderBetweenFields*(m_panes.GetCount() - 1));
}
return rect;
// do draw the fields
int flags = IsEnabled() ? 0 : (int)wxCONTROL_DISABLED;
- for ( int n = 0; n < m_nFields; n++ )
+ for ( int n = 0; n < (int)m_panes.GetCount(); n++ )
{
rect.width = m_widthsAbs[n];
// the size grip may be drawn only on the last field and only if we
// have the corresponding style and even then only if we really can
// resize this frame
- if ( n == m_nFields - 1 &&
+ if ( n == (int)m_panes.GetCount() - 1 &&
HasFlag(wxST_SIZEGRIP) &&
GetParent()->HasFlag(wxRESIZE_BORDER) &&
parentTLW && !parentTLW->IsMaximized() )
flags |= wxCONTROL_SIZEGRIP;
}
- int style;
- if (m_statusStyles)
- style = m_statusStyles[n];
- else
- style = wxSB_NORMAL;
- m_renderer->DrawStatusField(dc, rect, m_statusText[n], flags, style);
+ m_renderer->DrawStatusField(dc, rect, m_statusText[n], flags, m_panes[n].nStyle);
}
rect.x += rect.width + borderBetweenFields;
void wxStatusBarUniv::SetStatusText(const wxString& text, int number)
{
- wxCHECK_RET( number >= 0 && number < m_nFields,
+ wxCHECK_RET( number >= 0 && (size_t)number < m_panes.GetCount(),
_T("invalid status bar field index in SetStatusText()") );
if ( text == m_statusText[number] )
wxString wxStatusBarUniv::GetStatusText(int number) const
{
- wxCHECK_MSG( number >= 0 && number < m_nFields, wxEmptyString,
+ wxCHECK_MSG( number >= 0 && (size_t)number < m_panes.GetCount(), wxEmptyString,
_T("invalid status bar field index") );
return m_statusText[number];
{
m_statusText.SetCount(number);
wxStatusBarBase::SetFieldsCount(number, widths);
+
m_widthsAbs.Empty();
}
{
// we don't need to refresh the fields whose width didn't change, so find
// the first field whose width did change and refresh starting from it
- int field;
- if ( m_statusWidths )
+ size_t field;
+ if ( m_bSameWidthForAllPanes )
+ {
+ // hence all fields widths have changed
+ field = 0;
+ }
+ else
{
- for ( field = 0; field < m_nFields; field++ )
+ for ( field = 0; field < m_panes.GetCount(); field++ )
{
- if ( m_statusWidths[field] < 0 )
+ if ( m_panes[field].nWidth < 0 )
{
// var width field
break;
}
}
}
- else // all fields have the same width
- {
- // hence all fields widths have changed
- field = 0;
- }
- if ( field < m_nFields )
+ if ( field < m_panes.GetCount() )
{
// call this before invalidating the old widths as we want to use them,
// not the new ones
bool wxStatusBarUniv::GetFieldRect(int n, wxRect& rect) const
{
- wxCHECK_MSG( n >= 0 && n < m_nFields, false,
+ wxCHECK_MSG( n >= 0 && (size_t)n < m_panes.GetCount(), false,
_T("invalid field index in GetFieldRect()") );
// this is a fix for a bug exhibited by the statbar sample: if