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; }
187 // wxWindow overrides:
190 virtual void DoSetToolTip( wxToolTip
*tip
)
192 wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS
),
193 "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!");
194 wxWindow::DoSetToolTip(tip
);
198 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
201 // internal helpers & data:
203 // calculate the real field widths for the given total available size
204 wxArrayInt
CalculateAbsWidths(wxCoord widthTotal
) const;
206 // an internal utility used to keep track of which panes have labels
207 // which were last rendered as ellipsized...
208 void SetEllipsizedFlag(int n
, bool ellipsized
)
209 { m_panes
[n
].m_bEllipsized
= ellipsized
; }
211 // the array with the pane infos:
212 wxStatusBarPaneArray m_panes
;
214 // if true overrides the width info of the wxStatusBarPanes
215 bool m_bSameWidthForAllPanes
;
217 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase
);
220 // ----------------------------------------------------------------------------
221 // include the actual wxStatusBar class declaration
222 // ----------------------------------------------------------------------------
224 #if defined(__WXUNIVERSAL__)
225 #define wxStatusBarUniv wxStatusBar
226 #include "wx/univ/statusbr.h"
227 #elif defined(__WXPALMOS__)
228 #define wxStatusBarPalm wxStatusBar
229 #include "wx/palmos/statusbr.h"
230 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
231 #include "wx/msw/statusbar.h"
232 #elif defined(__WXMAC__)
233 #define wxStatusBarMac wxStatusBar
234 #include "wx/generic/statusbr.h"
235 #include "wx/osx/statusbr.h"
237 #define wxStatusBarGeneric wxStatusBar
238 #include "wx/generic/statusbr.h"
241 #endif // wxUSE_STATUSBAR
244 // _WX_STATUSBR_H_BASE_