]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/statusbr.h
put both versions of wxGetMousePosition in one place so they can use one implementation
[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 licence
7 /////////////////////////////////////////////////////////////////////////////
8
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
25 /**
26 @class wxStatusBarPane
27
28 A status bar pane data container used by wxStatusBar.
29
30 @library{wxcore}
31 @category{data}
32
33 @see wxStatusBar
34 */
35 class wxStatusBarPane
36 {
37 public:
38 /**
39 Constructs the pane with the given @a style and @a width.
40 */
41 wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0);
42
43 /**
44 Returns the pane width; it maybe negative, indicating a variable-width field.
45 */
46 int GetWidth() const;
47
48 /**
49 Returns the pane style.
50 */
51 int GetStyle() const;
52
53 /**
54 Returns the text currently shown in this pane.
55 */
56 wxString GetText() const;
57 };
58
59 /**
60 @class wxStatusBar
61
62 A status bar is a narrow window that can be placed along the bottom of a frame
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.
65
66 wxStatusBar also maintains an independent stack of status texts for each field
67 (see PushStatusText() and PopStatusText()).
68
69 Note that in wxStatusBar context, the terms @e pane and @e field are synonyms.
70
71 @beginStyleTable
72 @style{wxSTB_SIZEGRIP}
73 Displays a gripper at the right-hand side of the status bar which can be used
74 to resize the parent window.
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.
78 Note that this style has effect only on wxGTK (with GTK+ >= 2.12) currently.
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}
89 The default style: includes
90 @c wxSTB_SIZEGRIP|wxSTB_SHOW_TIPS|wxSTB_ELLIPSIZE_END|wxFULL_REPAINT_ON_RESIZE.
91 @endStyleTable
92
93 @remarks
94 It is possible to create controls and other windows on the status bar.
95 Position these windows from an OnSize() event handler.
96
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
104 @library{wxcore}
105 @category{miscwnd}
106
107 @see wxStatusBarPane, wxFrame, @ref page_samples_statbar
108 */
109 class wxStatusBar : public wxControl
110 {
111 public:
112 /**
113 Default ctor.
114 */
115 wxStatusBar();
116
117 /**
118 Constructor, creating the window.
119
120 @param parent
121 The window parent, usually a frame.
122 @param id
123 The window identifier.
124 It may take a value of -1 to indicate a default value.
125 @param style
126 The window style. See wxStatusBar.
127 @param name
128 The name of the window. This parameter is used to associate a name with the
129 item, allowing the application user to set Motif resource values for
130 individual windows.
131
132 @see Create()
133 */
134 wxStatusBar(wxWindow* parent, wxWindowID id = wxID_ANY,
135 long style = wxSTB_DEFAULT_STYLE,
136 const wxString& name = wxStatusBarNameStr);
137
138 /**
139 Destructor.
140 */
141 virtual ~wxStatusBar();
142
143 /**
144 Creates the window, for two-step construction.
145 See wxStatusBar() for details.
146 */
147 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
148 long style = wxSTB_DEFAULT_STYLE,
149 const wxString& name = wxStatusBarNameStr);
150
151 /**
152 Returns the size and position of a field's internal bounding rectangle.
153
154 @param i
155 The field in question.
156 @param rect
157 The rectangle values are placed in this variable.
158
159 @return @true if the field index is valid, @false otherwise.
160
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
166 @see wxRect
167 */
168 virtual bool GetFieldRect(int i, wxRect& rect) const;
169
170 /**
171 Returns the number of fields in the status bar.
172 */
173 int GetFieldsCount() const;
174
175 /**
176 Returns the wxStatusBarPane representing the @a n-th field.
177 */
178 const wxStatusBarPane& GetField(int n) const;
179
180 /**
181 Returns the horizontal and vertical borders used when rendering the field
182 text inside the field area.
183
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;
188
189 /**
190 Returns the string associated with a status bar field.
191
192 @param i
193 The number of the status field to retrieve, starting from zero.
194
195 @return The status field string if the field is valid, otherwise the
196 empty string.
197
198 @see SetStatusText()
199 */
200 virtual wxString GetStatusText(int i = 0) const;
201
202 /**
203 Returns the width of the @a n-th field.
204
205 See wxStatusBarPane::GetWidth() for more info.
206 */
207 int GetStatusWidth(int n) const;
208
209 /**
210 Returns the style of the @a n-th field.
211
212 See wxStatusBarPane::GetStyle() for more info.
213 */
214 int GetStatusStyle(int n) const;
215
216 /**
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.
224
225 @see PushStatusText()
226 */
227 void PopStatusText(int field = 0);
228
229 /**
230 Saves the current field text in a per-field stack, and sets the field
231 text to the string passed as argument.
232
233 @see PopStatusText()
234 */
235 void PushStatusText(const wxString& string, int field = 0);
236
237 /**
238 Sets the number of fields, and optionally the field widths.
239
240 @param number
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.
243 @param widths
244 An array of n integers interpreted in the same way as
245 in SetStatusWidths().
246
247 @beginWxPerlOnly
248 In wxPerl this function accepts only the @a number parameter.
249 Use SetStatusWidths to set the field widths.
250 @endWxPerlOnly
251 */
252 virtual void SetFieldsCount(int number = 1, const int* widths = NULL);
253
254 /**
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.
259 */
260 virtual void SetMinHeight(int height);
261
262 /**
263 Sets the styles of the fields in the status line which can make fields appear
264 flat or raised instead of the standard sunken 3D border.
265
266 @param n
267 The number of fields in the status bar. Must be equal to the
268 number passed to SetFieldsCount() the last time it was called.
269 @param styles
270 Contains an array of @a n integers with the styles for each field.
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.
275 */
276 virtual void SetStatusStyles(int n, const int* styles);
277
278 /**
279 Sets the status text for the @a i-th field.
280
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.
287
288 @param text
289 The text to be set. Use an empty string ("") to clear the field.
290 @param i
291 The field to set, starting from zero.
292
293 @see GetStatusText(), wxFrame::SetStatusText
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
299 fields: @b fixed widths and @b variable width fields. For the fixed width fields
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.
305
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.
309
310 @param n
311 The number of fields in the status bar. Must be equal to the
312 number passed to SetFieldsCount() the last time it was called.
313 @param widths_field
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
316 variable width field if negative.
317 The special value @NULL means that all fields should get the same width.
318
319 @remarks The widths of the variable fields are calculated from the total
320 width of all fields, minus the sum of widths of the
321 non-variable fields, divided by the number of variable fields.
322
323 @beginWxPerlOnly
324 In wxPerl this method takes as parameters the field widths.
325 @endWxPerlOnly
326
327 @see SetFieldsCount(), wxFrame::SetStatusWidths()
328 */
329 virtual void SetStatusWidths(int n, const int* widths_field);
330 };
331