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/window.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
55 // only wxStatusBarBase can access our internal members and modify them:
56 friend class WXDLLIMPEXP_FWD_CORE wxStatusBarBase
;
59 wxStatusBarPane(int style
= wxSB_NORMAL
, size_t width
= 0)
60 : m_nStyle(style
), m_nWidth(width
)
61 { m_arrStack
.Add(wxEmptyString
); m_bEllipsized
=false; }
68 const wxArrayString
& GetStack() const
69 { return m_arrStack
; }
71 // implementation-only getter:
72 bool IsEllipsized() const
73 { return m_bEllipsized
; }
75 // NOTE: there are no setters in wxStatusBarPane;
76 // use wxStatusBar functions to modify a wxStatusBarPane
80 int m_nWidth
; // the width maybe negative, indicating a variable-width field
82 // this is the array of the stacked strings of this pane; note that this
83 // stack does include also the string currently displayed in this pane
84 // as the version stored in the native status bar control is possibly
85 // ellipsized; note that m_arrStack.Last() is the top of the stack
86 // (i.e. the string shown in the status bar)
87 wxArrayString m_arrStack
;
89 // was the m_arrStack.Last() string shown in the status bar control ellipsized?
93 WX_DECLARE_OBJARRAY(wxStatusBarPane
, wxStatusBarPaneArray
);
95 // ----------------------------------------------------------------------------
96 // wxStatusBar: a window near the bottom of the frame used for status info
97 // ----------------------------------------------------------------------------
99 class WXDLLIMPEXP_CORE wxStatusBarBase
: public wxWindow
104 virtual ~wxStatusBarBase();
109 // set the number of fields and call SetStatusWidths(widths) if widths are
111 virtual void SetFieldsCount(int number
= 1, const int *widths
= NULL
);
112 int GetFieldsCount() const { return m_panes
.GetCount(); }
117 // NOTE: even if it is not pure virtual, SetStatusText() must be overloaded by
118 // the derived classes to update the given text in the native control
119 virtual void SetStatusText(const wxString
& text
, int number
= 0)
120 { m_panes
[number
].GetStack().Last() = text
; }
121 virtual wxString
GetStatusText(int number
= 0) const
122 { return m_panes
[number
].GetStack().Last(); }
123 const wxArrayString
& GetStatusStack(int n
) const
124 { return m_panes
[n
].GetStack(); }
126 void PushStatusText(const wxString
& text
, int number
= 0);
127 void PopStatusText(int number
= 0);
132 // set status field widths as absolute numbers: positive widths mean that
133 // the field has the specified absolute width, negative widths are
134 // interpreted as the sizer options, i.e. the extra space (total space
135 // minus the sum of fixed width fields) is divided between the fields with
136 // negative width according to the abs value of the width (field with width
137 // -2 grows twice as much as one with width -1 &c)
138 virtual void SetStatusWidths(int n
, const int widths
[]);
140 int GetStatusWidth(int n
) const
141 { return m_panes
[n
].GetWidth(); }
146 // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
147 // border around a field, wxSB_FLAT for no border around a field, so that it
148 // appears flat or wxSB_POPOUT to make the field appear raised.
149 // Setting field styles only works on wxMSW
150 virtual void SetStatusStyles(int n
, const int styles
[]);
152 int GetStatusStyle(int n
) const
153 { return m_panes
[n
].GetStyle(); }
158 // Get the position and size of the field's internal bounding rectangle
159 virtual bool GetFieldRect(int i
, wxRect
& rect
) const = 0;
161 // sets the minimal vertical size of the status bar
162 virtual void SetMinHeight(int height
) = 0;
164 // get the dimensions of the horizontal and vertical borders
165 virtual int GetBorderX() const = 0;
166 virtual int GetBorderY() const = 0;
168 wxSize
GetBorders() const
169 { return wxSize(GetBorderX(), GetBorderY()); }
174 const wxStatusBarPane
& GetField(int n
) const
175 { return m_panes
[n
]; }
177 // wxWindow overrides:
179 // don't want status bars to accept the focus at all
180 virtual bool AcceptsFocus() const { return false; }
182 // the client size of a toplevel window doesn't include the status bar
183 virtual bool CanBeOutsideClientArea() const { return true; }
186 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
188 // calculate the real field widths for the given total available size
189 wxArrayInt
CalculateAbsWidths(wxCoord widthTotal
) const;
191 // an internal utility used to keep track of which panes have labels
192 // which were last rendered as ellipsized...
193 void SetEllipsizedFlag(int n
, bool ellipsized
)
194 { m_panes
[n
].m_bEllipsized
= ellipsized
; }
196 // the array with the pane infos:
197 wxStatusBarPaneArray m_panes
;
199 // if true overrides the width info of the wxStatusBarPanes
200 bool m_bSameWidthForAllPanes
;
202 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase
);
205 // ----------------------------------------------------------------------------
206 // include the actual wxStatusBar class declaration
207 // ----------------------------------------------------------------------------
209 #if defined(__WXUNIVERSAL__)
210 #define wxStatusBarUniv wxStatusBar
211 #include "wx/univ/statusbr.h"
212 #elif defined(__WXPALMOS__)
213 #define wxStatusBarPalm wxStatusBar
214 #include "wx/palmos/statusbr.h"
215 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
216 #include "wx/msw/statusbar.h"
217 #elif defined(__WXMAC__)
218 #define wxStatusBarMac wxStatusBar
219 #include "wx/generic/statusbr.h"
220 #include "wx/osx/statusbr.h"
222 #define wxStatusBarGeneric wxStatusBar
223 #include "wx/generic/statusbr.h"
226 #endif // wxUSE_STATUSBAR
229 // _WX_STATUSBR_H_BASE_