]>
Commit | Line | Data |
---|---|---|
ed791986 VZ |
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$ | |
99d80019 | 8 | // Copyright: (c) Vadim Zeitlin |
65571936 | 9 | // Licence: wxWindows licence |
ed791986 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_STATUSBR_H_BASE_ |
13 | #define _WX_STATUSBR_H_BASE_ | |
c801d85f | 14 | |
3304646d | 15 | #include "wx/defs.h" |
ed791986 | 16 | |
1e6feb95 VZ |
17 | #if wxUSE_STATUSBAR |
18 | ||
f771bae3 | 19 | #include "wx/control.h" |
1f361cdd | 20 | #include "wx/list.h" |
ed39ff57 | 21 | #include "wx/dynarray.h" |
1f361cdd | 22 | |
23318a53 | 23 | extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr[]; |
53b6d7a2 | 24 | |
c2919ab3 VZ |
25 | // ---------------------------------------------------------------------------- |
26 | // wxStatusBar constants | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
c94bdf2a | 29 | // wxStatusBar styles |
c4c178c1 FM |
30 | #define wxSTB_SIZEGRIP 0x0010 |
31 | #define wxSTB_SHOW_TIPS 0x0020 | |
c94bdf2a | 32 | |
c4c178c1 FM |
33 | #define wxSTB_ELLIPSIZE_START 0x0040 |
34 | #define wxSTB_ELLIPSIZE_MIDDLE 0x0080 | |
35 | #define wxSTB_ELLIPSIZE_END 0x0100 | |
c94bdf2a | 36 | |
c4c178c1 FM |
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 | |
c2919ab3 VZ |
45 | #define wxSB_NORMAL 0x0000 |
46 | #define wxSB_FLAT 0x0001 | |
47 | #define wxSB_RAISED 0x0002 | |
98eb2e84 | 48 | #define wxSB_SUNKEN 0x0003 |
c2919ab3 | 49 | |
7b6fefbe FM |
50 | // ---------------------------------------------------------------------------- |
51 | // wxStatusBarPane: an helper for wxStatusBar | |
52 | // ---------------------------------------------------------------------------- | |
53 | ||
7235c54d | 54 | class WXDLLIMPEXP_CORE wxStatusBarPane |
7b6fefbe FM |
55 | { |
56 | public: | |
57 | wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0) | |
41d6e8b6 | 58 | : m_nStyle(style), m_nWidth(width) |
6cf68971 VZ |
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; } | |
41d6e8b6 | 64 | |
41d6e8b6 | 65 | |
6cf68971 VZ |
66 | // implementation-only from now on |
67 | // ------------------------------- | |
b31eaa5c | 68 | |
c94bdf2a FM |
69 | bool IsEllipsized() const |
70 | { return m_bEllipsized; } | |
6cf68971 | 71 | void SetIsEllipsized(bool isEllipsized) { m_bEllipsized = isEllipsized; } |
c94bdf2a | 72 | |
6cf68971 VZ |
73 | void SetWidth(int width) { m_nWidth = width; } |
74 | void SetStyle(int style) { m_nStyle = style; } | |
7b6fefbe | 75 | |
6cf68971 VZ |
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: | |
b31eaa5c | 90 | int m_nStyle; |
6cf68971 VZ |
91 | int m_nWidth; // may be negative, indicating a variable-width field |
92 | wxString m_text; | |
7b6fefbe | 93 | |
6cf68971 VZ |
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 | |
b31eaa5c | 98 | wxArrayString m_arrStack; |
c94bdf2a | 99 | |
6cf68971 | 100 | // is the currently shown value shown with ellipsis in the status bar? |
c94bdf2a | 101 | bool m_bEllipsized; |
7b6fefbe FM |
102 | }; |
103 | ||
b2d76621 | 104 | WX_DECLARE_EXPORTED_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray); |
7b6fefbe | 105 | |
ed791986 VZ |
106 | // ---------------------------------------------------------------------------- |
107 | // wxStatusBar: a window near the bottom of the frame used for status info | |
108 | // ---------------------------------------------------------------------------- | |
109 | ||
f771bae3 | 110 | class WXDLLIMPEXP_CORE wxStatusBarBase : public wxControl |
ed791986 VZ |
111 | { |
112 | public: | |
71e03035 VZ |
113 | wxStatusBarBase(); |
114 | ||
115 | virtual ~wxStatusBarBase(); | |
116 | ||
117 | // field count | |
118 | // ----------- | |
ed791986 | 119 | |
71e03035 VZ |
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); | |
7b6fefbe | 123 | int GetFieldsCount() const { return m_panes.GetCount(); } |
ed791986 | 124 | |
71e03035 VZ |
125 | // field text |
126 | // ---------- | |
127 | ||
6cf68971 VZ |
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; | |
ed791986 | 131 | |
6cf68971 VZ |
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() | |
1f361cdd MB |
134 | void PushStatusText(const wxString& text, int number = 0); |
135 | void PopStatusText(int number = 0); | |
136 | ||
71e03035 VZ |
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[]); | |
41d6e8b6 | 147 | |
b31eaa5c FM |
148 | int GetStatusWidth(int n) const |
149 | { return m_panes[n].GetWidth(); } | |
71e03035 | 150 | |
c2919ab3 VZ |
151 | // field styles |
152 | // ------------ | |
153 | ||
98eb2e84 | 154 | // Set the field border style to one of wxSB_XXX values. |
c2919ab3 | 155 | virtual void SetStatusStyles(int n, const int styles[]); |
41d6e8b6 | 156 | |
b31eaa5c FM |
157 | int GetStatusStyle(int n) const |
158 | { return m_panes[n].GetStyle(); } | |
c2919ab3 | 159 | |
71e03035 VZ |
160 | // geometry |
161 | // -------- | |
ed791986 VZ |
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; | |
41d6e8b6 | 172 | |
c94bdf2a FM |
173 | wxSize GetBorders() const |
174 | { return wxSize(GetBorderX(), GetBorderY()); } | |
ed791986 | 175 | |
b31eaa5c FM |
176 | // miscellaneous |
177 | // ------------- | |
41d6e8b6 | 178 | |
b31eaa5c FM |
179 | const wxStatusBarPane& GetField(int n) const |
180 | { return m_panes[n]; } | |
41d6e8b6 | 181 | |
b31eaa5c | 182 | // wxWindow overrides: |
41d6e8b6 | 183 | |
1e6feb95 | 184 | // don't want status bars to accept the focus at all |
d775fa82 | 185 | virtual bool AcceptsFocus() const { return false; } |
1e6feb95 | 186 | |
b31eaa5c | 187 | // the client size of a toplevel window doesn't include the status bar |
c04c7a3d VS |
188 | virtual bool CanBeOutsideClientArea() const { return true; } |
189 | ||
ed791986 | 190 | protected: |
6cf68971 VZ |
191 | // called after the status bar pane text changed and should update its |
192 | // display | |
193 | virtual void DoUpdateStatusText(int number) = 0; | |
194 | ||
6418ad5e FM |
195 | |
196 | // wxWindow overrides: | |
197 | ||
c437b3f4 JJ |
198 | #if wxUSE_TOOLTIPS |
199 | virtual void DoSetToolTip( wxToolTip *tip ) | |
8f99e9c3 | 200 | { |
6418ad5e FM |
201 | wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS), |
202 | "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!"); | |
8f99e9c3 | 203 | wxWindow::DoSetToolTip(tip); |
6418ad5e | 204 | } |
6cf68971 | 205 | #endif // wxUSE_TOOLTIPS |
3c75d8ba PC |
206 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } |
207 | ||
6418ad5e FM |
208 | |
209 | // internal helpers & data: | |
210 | ||
71e03035 VZ |
211 | // calculate the real field widths for the given total available size |
212 | wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const; | |
41d6e8b6 | 213 | |
6cf68971 VZ |
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 | ||
71e03035 | 218 | |
7b6fefbe FM |
219 | // the array with the pane infos: |
220 | wxStatusBarPaneArray m_panes; | |
1f361cdd | 221 | |
7b6fefbe FM |
222 | // if true overrides the width info of the wxStatusBarPanes |
223 | bool m_bSameWidthForAllPanes; | |
22f3361e | 224 | |
c0c133e1 | 225 | wxDECLARE_NO_COPY_CLASS(wxStatusBarBase); |
ed791986 VZ |
226 | }; |
227 | ||
71e03035 VZ |
228 | // ---------------------------------------------------------------------------- |
229 | // include the actual wxStatusBar class declaration | |
230 | // ---------------------------------------------------------------------------- | |
231 | ||
232 | #if defined(__WXUNIVERSAL__) | |
233 | #define wxStatusBarUniv wxStatusBar | |
71e03035 | 234 | #include "wx/univ/statusbr.h" |
bb5a9514 | 235 | #elif defined(__WXMSW__) && wxUSE_NATIVE_STATUSBAR |
936f6353 | 236 | #include "wx/msw/statusbar.h" |
656fc51c | 237 | #elif defined(__WXMAC__) |
71e03035 | 238 | #define wxStatusBarMac wxStatusBar |
5fde6fcc | 239 | #include "wx/generic/statusbr.h" |
ef0e9220 | 240 | #include "wx/osx/statusbr.h" |
ed791986 | 241 | #else |
71e03035 | 242 | #define wxStatusBarGeneric wxStatusBar |
71e03035 | 243 | #include "wx/generic/statusbr.h" |
ed791986 VZ |
244 | #endif |
245 | ||
71e03035 | 246 | #endif // wxUSE_STATUSBAR |
1e6feb95 | 247 | |
c801d85f | 248 | #endif |
34138703 | 249 | // _WX_STATUSBR_H_BASE_ |