fix push/pop mechanism after r58786; add a few notes about the stack mechanism both...
[wxWidgets.git] / include / wx / statusbr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/statusbr.h
3 // Purpose: wxStatusBar class interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 05.02.00
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_STATUSBR_H_BASE_
13 #define _WX_STATUSBR_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_STATUSBAR
18
19 #include "wx/window.h"
20 #include "wx/list.h"
21 #include "wx/dynarray.h"
22
23 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr[];
24
25 // ----------------------------------------------------------------------------
26 // wxStatusBar constants
27 // ----------------------------------------------------------------------------
28
29 // wxStatusBar styles
30 #define wxST_SIZEGRIP 0x0010
31 #define wxST_SHOW_TIPS 0x0020
32
33 #define wxST_DEFAULT_STYLE (wxST_SIZEGRIP|wxST_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
34
35 // style flags for fields
36 #define wxSB_NORMAL 0x0000
37 #define wxSB_FLAT 0x0001
38 #define wxSB_RAISED 0x0002
39
40 // ----------------------------------------------------------------------------
41 // wxStatusBarPane: an helper for wxStatusBar
42 // ----------------------------------------------------------------------------
43
44 class WXDLLIMPEXP_CORE wxStatusBarPane
45 {
46 // only wxStatusBarBase can access our internal members and modify them:
47 friend class WXDLLIMPEXP_FWD_CORE wxStatusBarBase;
48
49 public:
50 wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0)
51 : m_nStyle(style), m_nWidth(width)
52 { m_arrStack.Add(wxEmptyString); m_bEllipsized=false; }
53
54 int GetWidth() const
55 { return m_nWidth; }
56 int GetStyle() const
57 { return m_nStyle; }
58
59 const wxArrayString& GetStack() const
60 { return m_arrStack; }
61
62 // implementation-only getter:
63 bool IsEllipsized() const
64 { return m_bEllipsized; }
65
66 // NOTE: there are no setters in wxStatusBarPane;
67 // use wxStatusBar functions to modify a wxStatusBarPane
68
69 protected:
70 int m_nStyle;
71 int m_nWidth; // the width maybe negative, indicating a variable-width field
72
73 // this is the array of the stacked strings of this pane; note that this
74 // stack does include also the string currently displayed in this pane
75 // as the version stored in the native status bar control is possibly
76 // ellipsized; note that m_arrStack.Last() is the top of the stack
77 // (i.e. the string shown in the status bar)
78 wxArrayString m_arrStack;
79
80 // was the m_arrStack.Last() string shown in the status bar control ellipsized?
81 bool m_bEllipsized;
82 };
83
84 WX_DECLARE_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray);
85
86 // ----------------------------------------------------------------------------
87 // wxStatusBar: a window near the bottom of the frame used for status info
88 // ----------------------------------------------------------------------------
89
90 class WXDLLIMPEXP_CORE wxStatusBarBase : public wxWindow
91 {
92 public:
93 wxStatusBarBase();
94
95 virtual ~wxStatusBarBase();
96
97 // field count
98 // -----------
99
100 // set the number of fields and call SetStatusWidths(widths) if widths are
101 // given
102 virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
103 int GetFieldsCount() const { return m_panes.GetCount(); }
104
105 // field text
106 // ----------
107
108 // NOTE: even if it is not pure virtual, SetStatusText() must be overloaded by
109 // the derived classes to update the given text in the native control
110 virtual void SetStatusText(const wxString& text, int number = 0)
111 { m_panes[number].GetStack().Last() = text; }
112 virtual wxString GetStatusText(int number = 0) const
113 { return m_panes[number].GetStack().Last(); }
114 const wxArrayString& GetStatusStack(int n) const
115 { return m_panes[n].GetStack(); }
116
117 void PushStatusText(const wxString& text, int number = 0);
118 void PopStatusText(int number = 0);
119
120 // fields widths
121 // -------------
122
123 // set status field widths as absolute numbers: positive widths mean that
124 // the field has the specified absolute width, negative widths are
125 // interpreted as the sizer options, i.e. the extra space (total space
126 // minus the sum of fixed width fields) is divided between the fields with
127 // negative width according to the abs value of the width (field with width
128 // -2 grows twice as much as one with width -1 &c)
129 virtual void SetStatusWidths(int n, const int widths[]);
130
131 int GetStatusWidth(int n) const
132 { return m_panes[n].GetWidth(); }
133
134 // field styles
135 // ------------
136
137 // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
138 // border around a field, wxSB_FLAT for no border around a field, so that it
139 // appears flat or wxSB_POPOUT to make the field appear raised.
140 // Setting field styles only works on wxMSW
141 virtual void SetStatusStyles(int n, const int styles[]);
142
143 int GetStatusStyle(int n) const
144 { return m_panes[n].GetStyle(); }
145
146 // geometry
147 // --------
148
149 // Get the position and size of the field's internal bounding rectangle
150 virtual bool GetFieldRect(int i, wxRect& rect) const = 0;
151
152 // sets the minimal vertical size of the status bar
153 virtual void SetMinHeight(int height) = 0;
154
155 // get the dimensions of the horizontal and vertical borders
156 virtual int GetBorderX() const = 0;
157 virtual int GetBorderY() const = 0;
158
159 wxSize GetBorders() const
160 { return wxSize(GetBorderX(), GetBorderY()); }
161
162 // miscellaneous
163 // -------------
164
165 const wxStatusBarPane& GetField(int n) const
166 { return m_panes[n]; }
167
168 // wxWindow overrides:
169
170 // don't want status bars to accept the focus at all
171 virtual bool AcceptsFocus() const { return false; }
172
173 // the client size of a toplevel window doesn't include the status bar
174 virtual bool CanBeOutsideClientArea() const { return true; }
175
176 protected:
177 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
178
179 // calculate the real field widths for the given total available size
180 wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const;
181
182 // an internal utility used to keep track of which panes have labels
183 // which were last rendered as ellipsized...
184 void SetEllipsizedFlag(int n, bool ellipsized)
185 { m_panes[n].m_bEllipsized = ellipsized; }
186
187 // the array with the pane infos:
188 wxStatusBarPaneArray m_panes;
189
190 // if true overrides the width info of the wxStatusBarPanes
191 bool m_bSameWidthForAllPanes;
192
193 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase);
194 };
195
196 // ----------------------------------------------------------------------------
197 // include the actual wxStatusBar class declaration
198 // ----------------------------------------------------------------------------
199
200 #if defined(__WXUNIVERSAL__)
201 #define wxStatusBarUniv wxStatusBar
202 #include "wx/univ/statusbr.h"
203 #elif defined(__WXPALMOS__)
204 #define wxStatusBarPalm wxStatusBar
205 #include "wx/palmos/statusbr.h"
206 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
207 #include "wx/msw/statusbar.h"
208 #elif defined(__WXMAC__)
209 #define wxStatusBarMac wxStatusBar
210 #include "wx/generic/statusbr.h"
211 #include "wx/osx/statusbr.h"
212 #else
213 #define wxStatusBarGeneric wxStatusBar
214 #include "wx/generic/statusbr.h"
215 #endif
216
217 #endif // wxUSE_STATUSBAR
218
219 #endif
220 // _WX_STATUSBR_H_BASE_