1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStatusBar class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STATUSBR_H_BASE_
13 #define _WX_STATUSBR_H_BASE_
19 #include "wx/control.h"
21 #include "wx/dynarray.h"
23 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr
[];
25 // ----------------------------------------------------------------------------
26 // wxStatusBar constants
27 // ----------------------------------------------------------------------------
30 #define wxSTB_SIZEGRIP 0x0010
31 #define wxSTB_SHOW_TIPS 0x0020
33 #define wxSTB_ELLIPSIZE_START 0x0040
34 #define wxSTB_ELLIPSIZE_MIDDLE 0x0080
35 #define wxSTB_ELLIPSIZE_END 0x0100
37 #define wxSTB_DEFAULT_STYLE (wxSTB_SIZEGRIP|wxSTB_ELLIPSIZE_END|wxSTB_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
40 // old compat style name:
41 #define wxST_SIZEGRIP wxSTB_SIZEGRIP
44 // style flags for wxStatusBar fields
45 #define wxSB_NORMAL 0x0000
46 #define wxSB_FLAT 0x0001
47 #define wxSB_RAISED 0x0002
48 #define wxSB_SUNKEN 0x0003
50 // ----------------------------------------------------------------------------
51 // wxStatusBarPane: an helper for wxStatusBar
52 // ----------------------------------------------------------------------------
54 class WXDLLIMPEXP_CORE wxStatusBarPane
57 wxStatusBarPane(int style
= wxSB_NORMAL
, size_t width
= 0)
58 : m_nStyle(style
), m_nWidth(width
)
59 { m_bEllipsized
= false; }
61 int GetWidth() const { return m_nWidth
; }
62 int GetStyle() const { return m_nStyle
; }
63 wxString
GetText() const { return m_text
; }
66 // implementation-only from now on
67 // -------------------------------
69 bool IsEllipsized() const
70 { return m_bEllipsized
; }
71 void SetIsEllipsized(bool isEllipsized
) { m_bEllipsized
= isEllipsized
; }
73 void SetWidth(int width
) { m_nWidth
= width
; }
74 void SetStyle(int style
) { m_nStyle
= style
; }
76 // set text, return true if it changed or false if it was already set to
78 bool SetText(const wxString
& text
);
80 // save the existing text on top of our stack and make the new text
81 // current; return true if the text really changed
82 bool PushText(const wxString
& text
);
84 // restore the message saved by the last call to Push() (unless it was
85 // changed by an intervening call to SetText()) and return true if we
86 // really restored anything
91 int m_nWidth
; // may be negative, indicating a variable-width field
94 // the array used to keep the previous values of this pane after a
95 // PushStatusText() call, its top element is the value to restore after the
96 // next PopStatusText() call while the currently shown value is always in
98 wxArrayString m_arrStack
;
100 // is the currently shown value shown with ellipsis in the status bar?
104 WX_DECLARE_EXPORTED_OBJARRAY(wxStatusBarPane
, wxStatusBarPaneArray
);
106 // ----------------------------------------------------------------------------
107 // wxStatusBar: a window near the bottom of the frame used for status info
108 // ----------------------------------------------------------------------------
110 class WXDLLIMPEXP_CORE wxStatusBarBase
: public wxControl
115 virtual ~wxStatusBarBase();
120 // set the number of fields and call SetStatusWidths(widths) if widths are
122 virtual void SetFieldsCount(int number
= 1, const int *widths
= NULL
);
123 int GetFieldsCount() const { return m_panes
.GetCount(); }
128 // just change or get the currently shown text
129 void SetStatusText(const wxString
& text
, int number
= 0);
130 wxString
GetStatusText(int number
= 0) const;
132 // change the currently shown text to the new one and save the current
133 // value to be restored by the next call to PopStatusText()
134 void PushStatusText(const wxString
& text
, int number
= 0);
135 void PopStatusText(int number
= 0);
140 // set status field widths as absolute numbers: positive widths mean that
141 // the field has the specified absolute width, negative widths are
142 // interpreted as the sizer options, i.e. the extra space (total space
143 // minus the sum of fixed width fields) is divided between the fields with
144 // negative width according to the abs value of the width (field with width
145 // -2 grows twice as much as one with width -1 &c)
146 virtual void SetStatusWidths(int n
, const int widths
[]);
148 int GetStatusWidth(int n
) const
149 { return m_panes
[n
].GetWidth(); }
154 // Set the field border style to one of wxSB_XXX values.
155 virtual void SetStatusStyles(int n
, const int styles
[]);
157 int GetStatusStyle(int n
) const
158 { return m_panes
[n
].GetStyle(); }
163 // Get the position and size of the field's internal bounding rectangle
164 virtual bool GetFieldRect(int i
, wxRect
& rect
) const = 0;
166 // sets the minimal vertical size of the status bar
167 virtual void SetMinHeight(int height
) = 0;
169 // get the dimensions of the horizontal and vertical borders
170 virtual int GetBorderX() const = 0;
171 virtual int GetBorderY() const = 0;
173 wxSize
GetBorders() const
174 { return wxSize(GetBorderX(), GetBorderY()); }
179 const wxStatusBarPane
& GetField(int n
) const
180 { return m_panes
[n
]; }
182 // wxWindow overrides:
184 // don't want status bars to accept the focus at all
185 virtual bool AcceptsFocus() const { return false; }
187 // the client size of a toplevel window doesn't include the status bar
188 virtual bool CanBeOutsideClientArea() const { return true; }
191 // called after the status bar pane text changed and should update its
193 virtual void DoUpdateStatusText(int number
) = 0;
196 // wxWindow overrides:
199 virtual void DoSetToolTip( wxToolTip
*tip
)
201 wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS
),
202 "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!");
203 wxWindow::DoSetToolTip(tip
);
205 #endif // wxUSE_TOOLTIPS
206 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
209 // internal helpers & data:
211 // calculate the real field widths for the given total available size
212 wxArrayInt
CalculateAbsWidths(wxCoord widthTotal
) const;
214 // should be called to remember if the pane text is currently being show
216 void SetEllipsizedFlag(int n
, bool isEllipsized
);
219 // the array with the pane infos:
220 wxStatusBarPaneArray m_panes
;
222 // if true overrides the width info of the wxStatusBarPanes
223 bool m_bSameWidthForAllPanes
;
225 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase
);
228 // ----------------------------------------------------------------------------
229 // include the actual wxStatusBar class declaration
230 // ----------------------------------------------------------------------------
232 #if defined(__WXUNIVERSAL__)
233 #define wxStatusBarUniv wxStatusBar
234 #include "wx/univ/statusbr.h"
235 #elif defined(__WXMSW__) && wxUSE_NATIVE_STATUSBAR
236 #include "wx/msw/statusbar.h"
237 #elif defined(__WXMAC__)
238 #define wxStatusBarMac wxStatusBar
239 #include "wx/generic/statusbr.h"
240 #include "wx/osx/statusbr.h"
242 #define wxStatusBarGeneric wxStatusBar
243 #include "wx/generic/statusbr.h"
246 #endif // wxUSE_STATUSBAR
249 // _WX_STATUSBR_H_BASE_