fix push/pop mechanism after r58786; add a few notes about the stack mechanism both...
[wxWidgets.git] / interface / wx / statusbr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statusbr.h
3 // Purpose: interface of wxStatusBar
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxStatusBarPane
11
12 A status bar pane data container used by wxStatusBar.
13
14 @library{wxcore}
15 @category{data}
16
17 @see wxStatusBar
18 */
19 class wxStatusBarPane
20 {
21 public:
22 /**
23 Constructs the pane with the given @a style and @a width.
24 */
25 wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0);
26
27 /**
28 Returns the pane width; it maybe negative, indicating a variable-width field.
29 */
30 int GetWidth() const;
31
32 /**
33 Returns the pane style.
34 */
35 int GetStyle() const;
36
37 /**
38 Returns the stack of strings pushed on this pane.
39
40 Note that this stack does include also the string currently displayed in this pane
41 as the version stored in the native status bar control is possibly ellipsized.
42
43 Also note that GetStack().Last() is the top of the stack (i.e. the string shown
44 in the status bar).
45 */
46 const wxArrayString& GetStack() const;
47 };
48
49 /**
50 @class wxStatusBar
51
52 A status bar is a narrow window that can be placed along the bottom of a frame
53 to give small amounts of status information. It can contain one or more fields,
54 one or more of which can be variable length according to the size of the window.
55
56 wxStatusBar also maintains an independent stack of status texts for each field
57 (see PushStatusText() and PopStatusText()).
58
59 Note that in wxStatusBar context, the terms @e pane and @e field are synonyms.
60
61 @beginStyleTable
62 @style{wxST_SIZEGRIP}
63 Displays a gripper at the right-hand side of the status bar which can be used
64 to resize the parent window.
65 @style{wxST_SHOW_TIPS}
66 Displays tooltips for those panes whose status text has been ellipsized because
67 the status text doesn't fit the pane width.
68 Note that this style has effect only on wxGTK (with GTK+ >= 2.12) currently.
69 @style{wxST_DEFAULT_STYLE}
70 The default style: includes @c wxST_SIZEGRIP|wxST_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE.
71 @endStyleTable
72
73 @remarks
74 It is possible to create controls and other windows on the status bar.
75 Position these windows from an OnSize() event handler.
76
77 @library{wxcore}
78 @category{miscwnd}
79
80 @see wxStatusBarPane, wxFrame, @ref page_samples_statbar
81 */
82 class wxStatusBar : public wxWindow
83 {
84 public:
85 /**
86 Default ctor.
87 */
88 wxStatusBar();
89
90 /**
91 Constructor, creating the window.
92
93 @param parent
94 The window parent, usually a frame.
95 @param id
96 The window identifier.
97 It may take a value of -1 to indicate a default value.
98 @param style
99 The window style. See wxStatusBar.
100 @param name
101 The name of the window. This parameter is used to associate a name with the
102 item, allowing the application user to set Motif resource values for
103 individual windows.
104
105 @see Create()
106 */
107 wxStatusBar(wxWindow* parent, wxWindowID id = wxID_ANY,
108 long style = wxST_DEFAULT_STYLE,
109 const wxString& name = wxStatusBarNameStr);
110
111 /**
112 Destructor.
113 */
114 virtual ~wxStatusBar();
115
116 /**
117 Creates the window, for two-step construction.
118 See wxStatusBar() for details.
119 */
120 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
121 long style = wxST_DEFAULT_STYLE,
122 const wxString& name = wxStatusBarNameStr);
123
124 /**
125 Returns the size and position of a field's internal bounding rectangle.
126
127 @param i
128 The field in question.
129 @param rect
130 The rectangle values are placed in this variable.
131
132 @return @true if the field index is valid, @false otherwise.
133
134 @see wxRect
135 */
136 virtual bool GetFieldRect(int i, wxRect& rect) const;
137
138 /**
139 Returns the number of fields in the status bar.
140 */
141 int GetFieldsCount() const;
142
143 /**
144 Returns the wxStatusBarPane representing the @a n-th field.
145 */
146 const wxStatusBarPane& GetField(int n) const;
147
148 /**
149 Returns the horizontal and vertical borders used when rendering the field
150 text inside the field area.
151
152 Note that the rect returned by GetFieldRect() already accounts for the
153 presence of horizontal and vertical border returned by this function.
154 */
155 wxSize GetBorders() const;
156
157 /**
158 Returns the string associated with a status bar field.
159
160 @param i
161 The number of the status field to retrieve, starting from zero.
162
163 @return The status field string if the field is valid, otherwise the
164 empty string.
165
166 @see SetStatusText()
167 */
168 virtual wxString GetStatusText(int i = 0) const;
169
170 /**
171 Returns the stack of strings pushed (see PushStatusText()) on the
172 @a n-th field.
173
174 See wxStatusBarPane::GetStack() for more info.
175 */
176 const wxArrayString& GetStatusStack(int n) const;
177
178 /**
179 Returns the width of the @a n-th field.
180
181 See wxStatusBarPane::GetWidth() for more info.
182 */
183 int GetStatusWidth(int n) const;
184
185 /**
186 Returns the style of the @a n-th field.
187
188 See wxStatusBarPane::GetStyle() for more info.
189 */
190 int GetStatusStyle(int n) const;
191
192 /**
193 Sets the field text to the top of the stack, and pops the stack of saved
194 strings.
195
196 @see PushStatusText()
197 */
198 void PopStatusText(int field = 0);
199
200 /**
201 Saves the current field text in a per-field stack, and sets the field text
202 to the string passed as argument.
203
204 @see PopStatusText()
205 */
206 void PushStatusText(const wxString& string, int field = 0);
207
208 /**
209 Sets the number of fields, and optionally the field widths.
210
211 @param number
212 The number of fields. If this is greater than the previous number,
213 then new fields with empty strings will be added to the status bar.
214 @param widths
215 An array of n integers interpreted in the same way as
216 in SetStatusWidths().
217 */
218 virtual void SetFieldsCount(int number = 1, const int* widths = NULL);
219
220 /**
221 Sets the minimal possible height for the status bar.
222
223 The real height may be bigger than the height specified here depending
224 on the size of the font used by the status bar.
225 */
226 virtual void SetMinHeight(int height);
227
228 /**
229 Sets the styles of the fields in the status line which can make fields appear
230 flat or raised instead of the standard sunken 3D border.
231
232 @param n
233 The number of fields in the status bar. Must be equal to the
234 number passed to SetFieldsCount() the last time it was called.
235 @param styles
236 Contains an array of n integers with the styles for each field. There
237 are three possible styles:
238 - wxSB_NORMAL (default): The field appears sunken with a standard 3D border.
239 - wxSB_FLAT: No border is painted around the field so that it appears flat.
240 - wxSB_RAISED: A raised 3D border is painted around the field.
241 */
242 virtual void SetStatusStyles(int n, const int* styles);
243
244 /**
245 Sets the status text for the @a i-th field.
246
247 The given text will replace the current text. Note that unlike PushStatusText()
248 this function won't save the current text (and calling PopStatusText() won't
249 restore it!).
250
251 @param text
252 The text to be set. Use an empty string ("") to clear the field.
253 @param i
254 The field to set, starting from zero.
255
256 @see GetStatusText(), wxFrame::SetStatusText
257 */
258 virtual void SetStatusText(const wxString& text, int i = 0);
259
260 /**
261 Sets the widths of the fields in the status line. There are two types of
262 fields: @b fixed widths and @b variable width fields. For the fixed width fields
263 you should specify their (constant) width in pixels. For the variable width
264 fields, specify a negative number which indicates how the field should expand:
265 the space left for all variable width fields is divided between them according
266 to the absolute value of this number. A variable width field with width of -2
267 gets twice as much of it as a field with width -1 and so on.
268
269 For example, to create one fixed width field of width 100 in the right part of
270 the status bar and two more fields which get 66% and 33% of the remaining
271 space correspondingly, you should use an array containing -2, -1 and 100.
272
273 @param n
274 The number of fields in the status bar. Must be equal to the
275 number passed to SetFieldsCount() the last time it was called.
276 @param widths_field
277 Contains an array of n integers, each of which is either an
278 absolute status field width in pixels if positive or indicates a
279 variable width field if negative.
280 The special value @NULL means that all fields should get the same width.
281
282 @remarks The widths of the variable fields are calculated from the total
283 width of all fields, minus the sum of widths of the
284 non-variable fields, divided by the number of variable fields.
285
286 @see SetFieldsCount(), wxFrame::SetStatusWidths()
287 */
288 virtual void SetStatusWidths(int n, const int* widths_field);
289 };
290