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