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