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