class wxStatusBarPane
{
+ // only wxStatusBarBase can access our internal members and modify them:
+ friend class WXDLLIMPEXP_FWD_CORE wxStatusBarBase;
+
public:
wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0)
- : nStyle(style), nWidth(width) { arrStack.Add(wxEmptyString); }
+ : m_nStyle(style), m_nWidth(width) { m_arrStack.Add(wxEmptyString); }
+
+ int GetWidth() const
+ { return m_nWidth; }
+ int GetStyle() const
+ { return m_nStyle; }
+
+ const wxArrayString& GetStack() const
+ { return m_arrStack; }
+
+ // use wxStatusBar setter functions to modify a wxStatusBarPane
- int nStyle;
- int nWidth; // the width maybe negative, indicating a variable-width field
+protected:
+ int m_nStyle;
+ int m_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 include also the string currently displayed in this pane
// as the version stored in the native status bar control is possibly
// ellipsized; note that arrStack.Last() is the top of the stack
// (i.e. the string shown in the status bar)
- wxArrayString arrStack;
+ wxArrayString m_arrStack;
};
WX_DECLARE_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray);
// ----------
virtual void SetStatusText(const wxString& text, int number = 0)
- { m_panes[number].arrStack.Last() = text; }
+ { m_panes[number].GetStack().Last() = text; }
virtual wxString GetStatusText(int number = 0) const
- { return m_panes[number].arrStack.Last(); }
+ { return m_panes[number].GetStack().Last(); }
+ const wxArrayString& GetStatusStack(int n) const
+ { return m_panes[n].GetStack(); }
void PushStatusText(const wxString& text, int number = 0);
void PopStatusText(int number = 0);
// negative width according to the abs value of the width (field with width
// -2 grows twice as much as one with width -1 &c)
virtual void SetStatusWidths(int n, const int widths[]);
+
+ int GetStatusWidth(int n) const
+ { return m_panes[n].GetWidth(); }
// field styles
// ------------
// appears flat or wxSB_POPOUT to make the field appear raised.
// Setting field styles only works on wxMSW
virtual void SetStatusStyles(int n, const int styles[]);
+
+ int GetStatusStyle(int n) const
+ { return m_panes[n].GetStyle(); }
// geometry
// --------
virtual int GetBorderX() const = 0;
virtual int GetBorderY() const = 0;
+ // miscellaneous
+ // -------------
+
+ const wxStatusBarPane& GetField(int n) const
+ { return m_panes[n]; }
+
+ // wxWindow overrides:
+
// don't want status bars to accept the focus at all
virtual bool AcceptsFocus() const { return false; }
+ // the client size of a toplevel window doesn't include the status bar
virtual bool CanBeOutsideClientArea() const { return true; }
protected:
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+/**
+ @class wxStatusBarPane
+
+ A status bar pane data container used by wxStatusBar.
+*/
+class wxStatusBarPane
+{
+public:
+ /**
+ Constructs the pane with the given @a style and @a width.
+ */
+ wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0);
+
+ /**
+ Returns the pane width; it maybe negative, indicating a variable-width field.
+ */
+ int GetWidth() const;
+
+ /**
+ Returns the pane style.
+ */
+ int GetStyle() const;
+
+ /**
+ Returns the stack of strings pushed on this pane.
+
+ Note that this stack does include also the string currently displayed in this pane
+ as the version stored in the native status bar control is possibly ellipsized.
+
+ Also note that GetStack().Last() is the top of the stack (i.e. the string shown
+ in the status bar).
+ */
+ const wxArrayString& GetStack() const
+ { return m_arrStack; }
+};
+
/**
@class wxStatusBar
@library{wxcore}
@category{miscwnd}
- @see wxFrame, @ref page_samples_statbar
+ @see wxStatusBarPane, wxFrame, @ref page_samples_statbar
*/
class wxStatusBar : public wxWindow
{
virtual bool GetFieldRect(int i, wxRect& rect) const;
/**
- Returns the number of fields in the status bar.
+ Returns the wxStatusBarPane representing the @a n-th field.
*/
- int GetFieldsCount() const;
-
+ const wxStatusBarPane& GetField(int n) const
+ { return m_panes[n]; }
+
/**
Returns the string associated with a status bar field.
*/
virtual wxString GetStatusText(int i = 0) const;
+ /**
+ Returns the stack of strings pushed (see PushStatusText()) on the
+ @a n-th field.
+
+ See wxStatusBarPane::GetStack() for more info.
+ */
+ const wxArrayString& GetStatusStack(int n) const
+ { return m_panes[n].GetStack(); }
+
+ /**
+ Returns the width of the @a n-th field.
+
+ See wxStatusBarPane::GetWidth() for more info.
+ */
+ int GetStatusWidth(int n) const
+ { return m_panes[n].GetWidth(); }
+
+ /**
+ Returns the style of the @a n-th field.
+
+ See wxStatusBarPane::GetStyle() for more info.
+ */
+ int GetStatusStyle(int n) const
+ { return m_panes[n].GetStyle(); }
+
/**
Sets the field text to the top of the stack, and pops the stack of saved
strings.
else
{
for ( size_t i = 0; i < m_panes.GetCount(); i++ )
- m_panes[i].nWidth = widths[i];
+ m_panes[i].m_nWidth = widths[i];
m_bSameWidthForAllPanes = false;
}
wxASSERT_MSG( (size_t)n == m_panes.GetCount(), _T("field number mismatch") );
for ( size_t i = 0; i < m_panes.GetCount(); i++ )
- m_panes[i].nStyle = styles[i];
+ m_panes[i].m_nStyle = styles[i];
// update the display after the widths changed
Refresh();
for ( i = 0; i < m_panes.GetCount(); i++ )
{
- if ( m_panes[i].nWidth >= 0 )
- nTotalWidth += m_panes[i].nWidth;
+ if ( m_panes[i].GetWidth() >= 0 )
+ nTotalWidth += m_panes[i].GetWidth();
else
- nVarCount += -m_panes[i].nWidth;
+ nVarCount += -m_panes[i].GetWidth();
}
// the amount of extra width we have per each var width field
// do fill the array
for ( i = 0; i < m_panes.GetCount(); i++ )
{
- if ( m_panes[i].nWidth >= 0 )
- widths.Add(m_panes[i].nWidth);
+ if ( m_panes[i].GetWidth() >= 0 )
+ widths.Add(m_panes[i].GetWidth());
else
{
- int nVarWidth = widthExtra > 0 ? (widthExtra * (-m_panes[i].nWidth)) / nVarCount : 0;
- nVarCount += m_panes[i].nWidth;
+ int nVarWidth = widthExtra > 0 ? (widthExtra * (-m_panes[i].GetWidth())) / nVarCount : 0;
+ nVarCount += m_panes[i].GetWidth();
widthExtra -= nVarWidth;
widths.Add(nVarWidth);
}
void wxStatusBarBase::PushStatusText(const wxString& text, int number)
{
// save current status text in the stack
- m_panes[number].arrStack.push_back(GetStatusText(number));
+ m_panes[number].m_arrStack.push_back(GetStatusText(number));
SetStatusText(text, number);
// update current status text (eventually also in the native control)
void wxStatusBarBase::PopStatusText(int number)
{
- wxASSERT_MSG(m_panes[number].arrStack.GetCount() == 1,
+ wxASSERT_MSG(m_panes[number].m_arrStack.GetCount() == 1,
"can't pop any further string");
- wxString text = m_panes[number].arrStack.back();
- m_panes[number].arrStack.pop_back(); // also remove it from the stack
+ wxString text = m_panes[number].m_arrStack.back();
+ m_panes[number].m_arrStack.pop_back(); // also remove it from the stack
// restore the popped status text in the pane
SetStatusText(text, number);
if (rect.GetWidth() <= 0)
return; // happens when the status bar is shrinked in a very small area!
- int style = m_panes[i].nStyle;
+ int style = m_panes[i].GetStyle();
if (style != wxSB_FLAT)
{
// Draw border
// Get field style, if any
int style;
- switch(m_panes[nField].nStyle)
+ switch(m_panes[nField].GetStyle())
{
case wxSB_RAISED:
style = SBT_POPOUT;
for ( size_t i = 0; i < m_panes.GetCount(); ++i )
{
int widthField =
- m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].nWidth;
+ m_bSameWidthForAllPanes ? DEFAULT_FIELD_WIDTH : m_panes[i].GetWidth();
if ( widthField >= 0 )
{
width += widthField;
flags |= wxCONTROL_SIZEGRIP;
}
- m_renderer->DrawStatusField(dc, rect, GetStatusText(n), flags, m_panes[n].nStyle);
+ m_renderer->DrawStatusField(dc, rect, GetStatusText(n), flags, m_panes[n].GetStyle());
}
rect.x += rect.width + borderBetweenFields;
{
for ( field = 0; field < m_panes.GetCount(); field++ )
{
- if ( m_panes[field].nWidth < 0 )
+ if ( m_panes[field].GetWidth() < 0 )
{
// var width field
break;