]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/statusbr.h
Remove wrong const from wxMenu::GetMenuItems() documentation.
[wxWidgets.git] / interface / wx / statusbr.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: statusbr.h
e54c96f1 3// Purpose: interface of wxStatusBar
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
6db0bd92
RD
9// wxStatusBar styles
10#define wxSTB_SIZEGRIP 0x0010
11#define wxSTB_SHOW_TIPS 0x0020
12
13#define wxSTB_ELLIPSIZE_START 0x0040
14#define wxSTB_ELLIPSIZE_MIDDLE 0x0080
15#define wxSTB_ELLIPSIZE_END 0x0100
16
17#define wxSTB_DEFAULT_STYLE (wxSTB_SIZEGRIP|wxSTB_ELLIPSIZE_END|wxSTB_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
18
19// style flags for wxStatusBar fields
20#define wxSB_NORMAL 0x0000
21#define wxSB_FLAT 0x0001
22#define wxSB_RAISED 0x0002
23
24
b31eaa5c
FM
25/**
26 @class wxStatusBarPane
41d6e8b6 27
b31eaa5c 28 A status bar pane data container used by wxStatusBar.
7235c54d
FM
29
30 @library{wxcore}
50b75fe3 31 @category{data}
7235c54d
FM
32
33 @see wxStatusBar
b31eaa5c
FM
34*/
35class wxStatusBarPane
36{
37public:
38 /**
39 Constructs the pane with the given @a style and @a width.
40 */
41 wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0);
c94bdf2a 42
b31eaa5c
FM
43 /**
44 Returns the pane width; it maybe negative, indicating a variable-width field.
45 */
46 int GetWidth() const;
c94bdf2a 47
b31eaa5c
FM
48 /**
49 Returns the pane style.
50 */
51 int GetStyle() const;
41d6e8b6 52
b31eaa5c 53 /**
6cf68971
VZ
54 Returns the text currently shown in this pane.
55 */
56 wxString GetText() const;
b31eaa5c
FM
57};
58
23324ae1
FM
59/**
60 @class wxStatusBar
7c913512 61
23324ae1 62 A status bar is a narrow window that can be placed along the bottom of a frame
4701dc09
FM
63 to give small amounts of status information. It can contain one or more fields,
64 one or more of which can be variable length according to the size of the window.
41d6e8b6 65
30800ba5
FM
66 wxStatusBar also maintains an independent stack of status texts for each field
67 (see PushStatusText() and PopStatusText()).
68
c94bdf2a 69 Note that in wxStatusBar context, the terms @e pane and @e field are synonyms.
7c913512 70
23324ae1 71 @beginStyleTable
c4c178c1 72 @style{wxSTB_SIZEGRIP}
c94bdf2a
FM
73 Displays a gripper at the right-hand side of the status bar which can be used
74 to resize the parent window.
c4c178c1
FM
75 @style{wxSTB_SHOW_TIPS}
76 Displays tooltips for those panes whose status text has been ellipsized/truncated
77 because the status text doesn't fit the pane width.
c94bdf2a 78 Note that this style has effect only on wxGTK (with GTK+ >= 2.12) currently.
c4c178c1
FM
79 @style{wxSTB_ELLIPSIZE_START}
80 Replace the beginning of the status texts with an ellipsis when the status text
81 widths exceed the status bar pane's widths (uses wxControl::Ellipsize).
82 @style{wxSTB_ELLIPSIZE_MIDDLE}
83 Replace the middle of the status texts with an ellipsis when the status text
84 widths exceed the status bar pane's widths (uses wxControl::Ellipsize).
85 @style{wxSTB_ELLIPSIZE_END}
86 Replace the end of the status texts with an ellipsis when the status text
87 widths exceed the status bar pane's widths (uses wxControl::Ellipsize).
88 @style{wxSTB_DEFAULT_STYLE}
41d6e8b6
VZ
89 The default style: includes
90 @c wxSTB_SIZEGRIP|wxSTB_SHOW_TIPS|wxSTB_ELLIPSIZE_END|wxFULL_REPAINT_ON_RESIZE.
23324ae1 91 @endStyleTable
7c913512 92
4701dc09
FM
93 @remarks
94 It is possible to create controls and other windows on the status bar.
bb69632a 95 Position these windows from an OnSize() event handler.
4701dc09 96
2521c1ba
VZ
97 @remarks
98 Notice that only the first 127 characters of a string will be shown in
99 status bar fields under pre-XP MSW systems (or even under later systems if
100 a proper manifest indicating that the program uses version 6 of common
101 controls library is not used). This is a limitation of the native control
102 on these platforms.
103
23324ae1
FM
104 @library{wxcore}
105 @category{miscwnd}
7c913512 106
b31eaa5c 107 @see wxStatusBarPane, wxFrame, @ref page_samples_statbar
23324ae1 108*/
f771bae3 109class wxStatusBar : public wxControl
23324ae1
FM
110{
111public:
4701dc09
FM
112 /**
113 Default ctor.
114 */
115 wxStatusBar();
116
23324ae1
FM
117 /**
118 Constructor, creating the window.
3c4f71cc 119
7c913512 120 @param parent
4cc4bfaf 121 The window parent, usually a frame.
7c913512 122 @param id
4701dc09
FM
123 The window identifier.
124 It may take a value of -1 to indicate a default value.
7c913512 125 @param style
4cc4bfaf 126 The window style. See wxStatusBar.
7c913512 127 @param name
4cc4bfaf 128 The name of the window. This parameter is used to associate a name with the
4701dc09 129 item, allowing the application user to set Motif resource values for
4cc4bfaf 130 individual windows.
3c4f71cc 131
4cc4bfaf 132 @see Create()
23324ae1 133 */
7c913512 134 wxStatusBar(wxWindow* parent, wxWindowID id = wxID_ANY,
c4c178c1 135 long style = wxSTB_DEFAULT_STYLE,
11e3af6e 136 const wxString& name = wxStatusBarNameStr);
23324ae1
FM
137
138 /**
139 Destructor.
140 */
adaaa686 141 virtual ~wxStatusBar();
23324ae1
FM
142
143 /**
144 Creates the window, for two-step construction.
23324ae1
FM
145 See wxStatusBar() for details.
146 */
147 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
c4c178c1 148 long style = wxSTB_DEFAULT_STYLE,
43c48e1e 149 const wxString& name = wxStatusBarNameStr);
23324ae1
FM
150
151 /**
152 Returns the size and position of a field's internal bounding rectangle.
3c4f71cc 153
7c913512 154 @param i
4cc4bfaf 155 The field in question.
7c913512 156 @param rect
4cc4bfaf 157 The rectangle values are placed in this variable.
3c4f71cc 158
d29a9a8a 159 @return @true if the field index is valid, @false otherwise.
3c4f71cc 160
1058f652
MB
161 @beginWxPerlOnly
162 In wxPerl this function returns a @c Wx::Rect if the field
163 index is valid, @c undef otherwise.
164 @endWxPerlOnly
165
4cc4bfaf 166 @see wxRect
23324ae1 167 */
328f5751 168 virtual bool GetFieldRect(int i, wxRect& rect) const;
41d6e8b6 169
4df02e42 170 /**
41d6e8b6 171 Returns the number of fields in the status bar.
4df02e42
FM
172 */
173 int GetFieldsCount() const;
41d6e8b6 174
23324ae1 175 /**
b31eaa5c 176 Returns the wxStatusBarPane representing the @a n-th field.
23324ae1 177 */
f18e1cf1 178 const wxStatusBarPane& GetField(int n) const;
41d6e8b6 179
c94bdf2a
FM
180 /**
181 Returns the horizontal and vertical borders used when rendering the field
182 text inside the field area.
41d6e8b6 183
c94bdf2a
FM
184 Note that the rect returned by GetFieldRect() already accounts for the
185 presence of horizontal and vertical border returned by this function.
186 */
187 wxSize GetBorders() const;
41d6e8b6 188
23324ae1
FM
189 /**
190 Returns the string associated with a status bar field.
3c4f71cc 191
7c913512 192 @param i
4cc4bfaf 193 The number of the status field to retrieve, starting from zero.
3c4f71cc 194
d29a9a8a 195 @return The status field string if the field is valid, otherwise the
4701dc09 196 empty string.
3c4f71cc 197
4cc4bfaf 198 @see SetStatusText()
23324ae1 199 */
328f5751 200 virtual wxString GetStatusText(int i = 0) const;
23324ae1 201
b31eaa5c
FM
202 /**
203 Returns the width of the @a n-th field.
41d6e8b6 204
b31eaa5c
FM
205 See wxStatusBarPane::GetWidth() for more info.
206 */
f18e1cf1 207 int GetStatusWidth(int n) const;
b31eaa5c
FM
208
209 /**
210 Returns the style of the @a n-th field.
41d6e8b6 211
b31eaa5c
FM
212 See wxStatusBarPane::GetStyle() for more info.
213 */
f18e1cf1 214 int GetStatusStyle(int n) const;
41d6e8b6 215
23324ae1 216 /**
6cf68971
VZ
217 Restores the text to the value it had before the last call to
218 PushStatusText().
219
220 Notice that if SetStatusText() had been called in the meanwhile,
221 PopStatusText() will not change the text, i.e. it does not override
222 explicit changes to status text but only restores the saved text if it
223 hadn't been changed since.
3c4f71cc 224
4cc4bfaf 225 @see PushStatusText()
23324ae1
FM
226 */
227 void PopStatusText(int field = 0);
228
229 /**
6cf68971
VZ
230 Saves the current field text in a per-field stack, and sets the field
231 text to the string passed as argument.
fd3ece57
FM
232
233 @see PopStatusText()
23324ae1
FM
234 */
235 void PushStatusText(const wxString& string, int field = 0);
236
237 /**
238 Sets the number of fields, and optionally the field widths.
3c4f71cc 239
7c913512 240 @param number
0cd15959
FM
241 The number of fields. If this is greater than the previous number,
242 then new fields with empty strings will be added to the status bar.
7c913512 243 @param widths
4cc4bfaf 244 An array of n integers interpreted in the same way as
4701dc09 245 in SetStatusWidths().
1058f652
MB
246
247 @beginWxPerlOnly
248 In wxPerl this function accepts only the @a number parameter.
249 Use SetStatusWidths to set the field widths.
250 @endWxPerlOnly
23324ae1 251 */
43c48e1e 252 virtual void SetFieldsCount(int number = 1, const int* widths = NULL);
23324ae1
FM
253
254 /**
4701dc09
FM
255 Sets the minimal possible height for the status bar.
256
257 The real height may be bigger than the height specified here depending
258 on the size of the font used by the status bar.
23324ae1 259 */
adaaa686 260 virtual void SetMinHeight(int height);
23324ae1
FM
261
262 /**
263 Sets the styles of the fields in the status line which can make fields appear
4701dc09 264 flat or raised instead of the standard sunken 3D border.
3c4f71cc 265
7c913512 266 @param n
4cc4bfaf 267 The number of fields in the status bar. Must be equal to the
4701dc09 268 number passed to SetFieldsCount() the last time it was called.
7c913512 269 @param styles
41d6e8b6 270 Contains an array of @a n integers with the styles for each field.
c4c178c1
FM
271 There are three possible styles:
272 - @c wxSB_NORMAL (default): The field appears sunken with a standard 3D border.
273 - @c wxSB_FLAT: No border is painted around the field so that it appears flat.
274 - @c wxSB_RAISED: A raised 3D border is painted around the field.
23324ae1 275 */
43c48e1e 276 virtual void SetStatusStyles(int n, const int* styles);
23324ae1
FM
277
278 /**
30800ba5 279 Sets the status text for the @a i-th field.
41d6e8b6 280
6cf68971
VZ
281 The given text will replace the current text.
282
283 Note that if PushStatusText() had been called before the new text will
284 also replace the last saved value to make sure that the next call to
285 PopStatusText() doesn't restore the old value, which was overwritten by
286 the call to this function.
3c4f71cc 287
7c913512 288 @param text
4cc4bfaf 289 The text to be set. Use an empty string ("") to clear the field.
7c913512 290 @param i
4cc4bfaf 291 The field to set, starting from zero.
3c4f71cc 292
4cc4bfaf 293 @see GetStatusText(), wxFrame::SetStatusText
23324ae1
FM
294 */
295 virtual void SetStatusText(const wxString& text, int i = 0);
296
297 /**
298 Sets the widths of the fields in the status line. There are two types of
54e18afc 299 fields: @b fixed widths and @b variable width fields. For the fixed width fields
23324ae1
FM
300 you should specify their (constant) width in pixels. For the variable width
301 fields, specify a negative number which indicates how the field should expand:
302 the space left for all variable width fields is divided between them according
303 to the absolute value of this number. A variable width field with width of -2
304 gets twice as much of it as a field with width -1 and so on.
4701dc09 305
23324ae1
FM
306 For example, to create one fixed width field of width 100 in the right part of
307 the status bar and two more fields which get 66% and 33% of the remaining
308 space correspondingly, you should use an array containing -2, -1 and 100.
3c4f71cc 309
7c913512 310 @param n
4cc4bfaf 311 The number of fields in the status bar. Must be equal to the
4701dc09 312 number passed to SetFieldsCount() the last time it was called.
f21dd16b 313 @param widths_field
4701dc09
FM
314 Contains an array of n integers, each of which is either an
315 absolute status field width in pixels if positive or indicates a
4cc4bfaf 316 variable width field if negative.
fd3ece57 317 The special value @NULL means that all fields should get the same width.
3c4f71cc 318
23324ae1 319 @remarks The widths of the variable fields are calculated from the total
4cc4bfaf 320 width of all fields, minus the sum of widths of the
4701dc09 321 non-variable fields, divided by the number of variable fields.
3c4f71cc 322
1058f652
MB
323 @beginWxPerlOnly
324 In wxPerl this method takes as parameters the field widths.
325 @endWxPerlOnly
326
4701dc09 327 @see SetFieldsCount(), wxFrame::SetStatusWidths()
23324ae1 328 */
43c48e1e 329 virtual void SetStatusWidths(int n, const int* widths_field);
23324ae1 330};
e54c96f1 331