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
49 // ----------------------------------------------------------------------------
50 // wxStatusBarPane: an helper for wxStatusBar
51 // ----------------------------------------------------------------------------
53 class WXDLLIMPEXP_CORE wxStatusBarPane
56 wxStatusBarPane(int style
= wxSB_NORMAL
, size_t width
= 0)
57 : m_nStyle(style
), m_nWidth(width
)
58 { m_bEllipsized
= false; }
60 int GetWidth() const { return m_nWidth
; }
61 int GetStyle() const { return m_nStyle
; }
62 wxString
GetText() const { return m_text
; }
65 // implementation-only from now on
66 // -------------------------------
68 bool IsEllipsized() const
69 { return m_bEllipsized
; }
70 void SetIsEllipsized(bool isEllipsized
) { m_bEllipsized
= isEllipsized
; }
72 void SetWidth(int width
) { m_nWidth
= width
; }
73 void SetStyle(int style
) { m_nStyle
= style
; }
75 // set text, return true if it changed or false if it was already set to
77 bool SetText(const wxString
& text
);
79 // save the existing text on top of our stack and make the new text
80 // current; return true if the text really changed
81 bool PushText(const wxString
& text
);
83 // restore the message saved by the last call to Push() (unless it was
84 // changed by an intervening call to SetText()) and return true if we
85 // really restored anything
90 int m_nWidth
; // may be negative, indicating a variable-width field
93 // the array used to keep the previous values of this pane after a
94 // PushStatusText() call, its top element is the value to restore after the
95 // next PopStatusText() call while the currently shown value is always in
97 wxArrayString m_arrStack
;
99 // is the currently shown value shown with ellipsis in the status bar?
103 WX_DECLARE_EXPORTED_OBJARRAY(wxStatusBarPane
, wxStatusBarPaneArray
);
105 // ----------------------------------------------------------------------------
106 // wxStatusBar: a window near the bottom of the frame used for status info
107 // ----------------------------------------------------------------------------
109 class WXDLLIMPEXP_CORE wxStatusBarBase
: public wxControl
114 virtual ~wxStatusBarBase();
119 // set the number of fields and call SetStatusWidths(widths) if widths are
121 virtual void SetFieldsCount(int number
= 1, const int *widths
= NULL
);
122 int GetFieldsCount() const { return m_panes
.GetCount(); }
127 // just change or get the currently shown text
128 void SetStatusText(const wxString
& text
, int number
= 0);
129 wxString
GetStatusText(int number
= 0) const;
131 // change the currently shown text to the new one and save the current
132 // value to be restored by the next call to PopStatusText()
133 void PushStatusText(const wxString
& text
, int number
= 0);
134 void PopStatusText(int number
= 0);
139 // set status field widths as absolute numbers: positive widths mean that
140 // the field has the specified absolute width, negative widths are
141 // interpreted as the sizer options, i.e. the extra space (total space
142 // minus the sum of fixed width fields) is divided between the fields with
143 // negative width according to the abs value of the width (field with width
144 // -2 grows twice as much as one with width -1 &c)
145 virtual void SetStatusWidths(int n
, const int widths
[]);
147 int GetStatusWidth(int n
) const
148 { return m_panes
[n
].GetWidth(); }
153 // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
154 // border around a field, wxSB_FLAT for no border around a field, so that it
155 // appears flat or wxSB_POPOUT to make the field appear raised.
156 // Setting field styles only works on wxMSW
157 virtual void SetStatusStyles(int n
, const int styles
[]);
159 int GetStatusStyle(int n
) const
160 { return m_panes
[n
].GetStyle(); }
165 // Get the position and size of the field's internal bounding rectangle
166 virtual bool GetFieldRect(int i
, wxRect
& rect
) const = 0;
168 // sets the minimal vertical size of the status bar
169 virtual void SetMinHeight(int height
) = 0;
171 // get the dimensions of the horizontal and vertical borders
172 virtual int GetBorderX() const = 0;
173 virtual int GetBorderY() const = 0;
175 wxSize
GetBorders() const
176 { return wxSize(GetBorderX(), GetBorderY()); }
181 const wxStatusBarPane
& GetField(int n
) const
182 { return m_panes
[n
]; }
184 // wxWindow overrides:
186 // don't want status bars to accept the focus at all
187 virtual bool AcceptsFocus() const { return false; }
189 // the client size of a toplevel window doesn't include the status bar
190 virtual bool CanBeOutsideClientArea() const { return true; }
193 // called after the status bar pane text changed and should update its
195 virtual void DoUpdateStatusText(int number
) = 0;
198 // wxWindow overrides:
201 virtual void DoSetToolTip( wxToolTip
*tip
)
203 wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS
),
204 "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!");
205 wxWindow::DoSetToolTip(tip
);
207 #endif // wxUSE_TOOLTIPS
208 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
211 // internal helpers & data:
213 // calculate the real field widths for the given total available size
214 wxArrayInt
CalculateAbsWidths(wxCoord widthTotal
) const;
216 // should be called to remember if the pane text is currently being show
218 void SetEllipsizedFlag(int n
, bool isEllipsized
);
221 // the array with the pane infos:
222 wxStatusBarPaneArray m_panes
;
224 // if true overrides the width info of the wxStatusBarPanes
225 bool m_bSameWidthForAllPanes
;
227 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase
);
230 // ----------------------------------------------------------------------------
231 // include the actual wxStatusBar class declaration
232 // ----------------------------------------------------------------------------
234 #if defined(__WXUNIVERSAL__)
235 #define wxStatusBarUniv wxStatusBar
236 #include "wx/univ/statusbr.h"
237 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
238 #include "wx/msw/statusbar.h"
239 #elif defined(__WXMAC__)
240 #define wxStatusBarMac wxStatusBar
241 #include "wx/generic/statusbr.h"
242 #include "wx/osx/statusbr.h"
244 #define wxStatusBarGeneric wxStatusBar
245 #include "wx/generic/statusbr.h"
248 #endif // wxUSE_STATUSBAR
251 // _WX_STATUSBR_H_BASE_