]> git.saurik.com Git - wxWidgets.git/blob - include/wx/statusbr.h
Add functor-taking overload of CallAfter().
[wxWidgets.git] / include / wx / statusbr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/statusbr.h
3 // Purpose: wxStatusBar class interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 05.02.00
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_STATUSBR_H_BASE_
13 #define _WX_STATUSBR_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_STATUSBAR
18
19 #include "wx/control.h"
20 #include "wx/list.h"
21 #include "wx/dynarray.h"
22
23 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr[];
24
25 // ----------------------------------------------------------------------------
26 // wxStatusBar constants
27 // ----------------------------------------------------------------------------
28
29 // wxStatusBar styles
30 #define wxSTB_SIZEGRIP 0x0010
31 #define wxSTB_SHOW_TIPS 0x0020
32
33 #define wxSTB_ELLIPSIZE_START 0x0040
34 #define wxSTB_ELLIPSIZE_MIDDLE 0x0080
35 #define wxSTB_ELLIPSIZE_END 0x0100
36
37 #define wxSTB_DEFAULT_STYLE (wxSTB_SIZEGRIP|wxSTB_ELLIPSIZE_END|wxSTB_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
38
39
40 // old compat style name:
41 #define wxST_SIZEGRIP wxSTB_SIZEGRIP
42
43
44 // style flags for wxStatusBar fields
45 #define wxSB_NORMAL 0x0000
46 #define wxSB_FLAT 0x0001
47 #define wxSB_RAISED 0x0002
48 #define wxSB_SUNKEN 0x0003
49
50 // ----------------------------------------------------------------------------
51 // wxStatusBarPane: an helper for wxStatusBar
52 // ----------------------------------------------------------------------------
53
54 class WXDLLIMPEXP_CORE wxStatusBarPane
55 {
56 public:
57 wxStatusBarPane(int style = wxSB_NORMAL, int width = 0)
58 : m_nStyle(style), m_nWidth(width)
59 { m_bEllipsized = false; }
60
61 int GetWidth() const { return m_nWidth; }
62 int GetStyle() const { return m_nStyle; }
63 wxString GetText() const { return m_text; }
64
65
66 // implementation-only from now on
67 // -------------------------------
68
69 bool IsEllipsized() const
70 { return m_bEllipsized; }
71 void SetIsEllipsized(bool isEllipsized) { m_bEllipsized = isEllipsized; }
72
73 void SetWidth(int width) { m_nWidth = width; }
74 void SetStyle(int style) { m_nStyle = style; }
75
76 // set text, return true if it changed or false if it was already set to
77 // this value
78 bool SetText(const wxString& text);
79
80 // save the existing text on top of our stack and make the new text
81 // current; return true if the text really changed
82 bool PushText(const wxString& text);
83
84 // restore the message saved by the last call to Push() (unless it was
85 // changed by an intervening call to SetText()) and return true if we
86 // really restored anything
87 bool PopText();
88
89 private:
90 int m_nStyle;
91 int m_nWidth; // may be negative, indicating a variable-width field
92 wxString m_text;
93
94 // the array used to keep the previous values of this pane after a
95 // PushStatusText() call, its top element is the value to restore after the
96 // next PopStatusText() call while the currently shown value is always in
97 // m_text
98 wxArrayString m_arrStack;
99
100 // is the currently shown value shown with ellipsis in the status bar?
101 bool m_bEllipsized;
102 };
103
104 WX_DECLARE_EXPORTED_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray);
105
106 // ----------------------------------------------------------------------------
107 // wxStatusBar: a window near the bottom of the frame used for status info
108 // ----------------------------------------------------------------------------
109
110 class WXDLLIMPEXP_CORE wxStatusBarBase : public wxControl
111 {
112 public:
113 wxStatusBarBase();
114
115 virtual ~wxStatusBarBase();
116
117 // field count
118 // -----------
119
120 // set the number of fields and call SetStatusWidths(widths) if widths are
121 // given
122 virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
123 int GetFieldsCount() const { return (int)m_panes.GetCount(); }
124
125 // field text
126 // ----------
127
128 // just change or get the currently shown text
129 void SetStatusText(const wxString& text, int number = 0);
130 wxString GetStatusText(int number = 0) const;
131
132 // change the currently shown text to the new one and save the current
133 // value to be restored by the next call to PopStatusText()
134 void PushStatusText(const wxString& text, int number = 0);
135 void PopStatusText(int number = 0);
136
137 // fields widths
138 // -------------
139
140 // set status field widths as absolute numbers: positive widths mean that
141 // the field has the specified absolute width, negative widths are
142 // interpreted as the sizer options, i.e. the extra space (total space
143 // minus the sum of fixed width fields) is divided between the fields with
144 // negative width according to the abs value of the width (field with width
145 // -2 grows twice as much as one with width -1 &c)
146 virtual void SetStatusWidths(int n, const int widths[]);
147
148 int GetStatusWidth(int n) const
149 { return m_panes[n].GetWidth(); }
150
151 // field styles
152 // ------------
153
154 // Set the field border style to one of wxSB_XXX values.
155 virtual void SetStatusStyles(int n, const int styles[]);
156
157 int GetStatusStyle(int n) const
158 { return m_panes[n].GetStyle(); }
159
160 // geometry
161 // --------
162
163 // Get the position and size of the field's internal bounding rectangle
164 virtual bool GetFieldRect(int i, wxRect& rect) const = 0;
165
166 // sets the minimal vertical size of the status bar
167 virtual void SetMinHeight(int height) = 0;
168
169 // get the dimensions of the horizontal and vertical borders
170 virtual int GetBorderX() const = 0;
171 virtual int GetBorderY() const = 0;
172
173 wxSize GetBorders() const
174 { return wxSize(GetBorderX(), GetBorderY()); }
175
176 // miscellaneous
177 // -------------
178
179 const wxStatusBarPane& GetField(int n) const
180 { return m_panes[n]; }
181
182 // wxWindow overrides:
183
184 // don't want status bars to accept the focus at all
185 virtual bool AcceptsFocus() const { return false; }
186
187 // the client size of a toplevel window doesn't include the status bar
188 virtual bool CanBeOutsideClientArea() const { return true; }
189
190 protected:
191 // called after the status bar pane text changed and should update its
192 // display
193 virtual void DoUpdateStatusText(int number) = 0;
194
195
196 // wxWindow overrides:
197
198 #if wxUSE_TOOLTIPS
199 virtual void DoSetToolTip( wxToolTip *tip )
200 {
201 wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS),
202 "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!");
203 wxWindow::DoSetToolTip(tip);
204 }
205 #endif // wxUSE_TOOLTIPS
206 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
207
208
209 // internal helpers & data:
210
211 // calculate the real field widths for the given total available size
212 wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const;
213
214 // should be called to remember if the pane text is currently being show
215 // ellipsized or not
216 void SetEllipsizedFlag(int n, bool isEllipsized);
217
218
219 // the array with the pane infos:
220 wxStatusBarPaneArray m_panes;
221
222 // if true overrides the width info of the wxStatusBarPanes
223 bool m_bSameWidthForAllPanes;
224
225 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase);
226 };
227
228 // ----------------------------------------------------------------------------
229 // include the actual wxStatusBar class declaration
230 // ----------------------------------------------------------------------------
231
232 #if defined(__WXUNIVERSAL__)
233 #define wxStatusBarUniv wxStatusBar
234 #include "wx/univ/statusbr.h"
235 #elif defined(__WXMSW__) && wxUSE_NATIVE_STATUSBAR
236 #include "wx/msw/statusbar.h"
237 #elif defined(__WXMAC__)
238 #define wxStatusBarMac wxStatusBar
239 #include "wx/generic/statusbr.h"
240 #include "wx/osx/statusbr.h"
241 #else
242 #define wxStatusBarGeneric wxStatusBar
243 #include "wx/generic/statusbr.h"
244 #endif
245
246 #endif // wxUSE_STATUSBAR
247
248 #endif
249 // _WX_STATUSBR_H_BASE_