use wxSTB_ as prefix for wxStatusBar styles; add support for wxSTB_ELLIPSIZE_* flags...
[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/window.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
49 // ----------------------------------------------------------------------------
50 // wxStatusBarPane: an helper for wxStatusBar
51 // ----------------------------------------------------------------------------
52
53 class WXDLLIMPEXP_CORE wxStatusBarPane
54 {
55 // only wxStatusBarBase can access our internal members and modify them:
56 friend class WXDLLIMPEXP_FWD_CORE wxStatusBarBase;
57
58 public:
59 wxStatusBarPane(int style = wxSB_NORMAL, size_t width = 0)
60 : m_nStyle(style), m_nWidth(width)
61 { m_arrStack.Add(wxEmptyString); m_bEllipsized=false; }
62
63 int GetWidth() const
64 { return m_nWidth; }
65 int GetStyle() const
66 { return m_nStyle; }
67
68 const wxArrayString& GetStack() const
69 { return m_arrStack; }
70
71 // implementation-only getter:
72 bool IsEllipsized() const
73 { return m_bEllipsized; }
74
75 // NOTE: there are no setters in wxStatusBarPane;
76 // use wxStatusBar functions to modify a wxStatusBarPane
77
78 protected:
79 int m_nStyle;
80 int m_nWidth; // the width maybe negative, indicating a variable-width field
81
82 // this is the array of the stacked strings of this pane; note that this
83 // stack does include also the string currently displayed in this pane
84 // as the version stored in the native status bar control is possibly
85 // ellipsized; note that m_arrStack.Last() is the top of the stack
86 // (i.e. the string shown in the status bar)
87 wxArrayString m_arrStack;
88
89 // was the m_arrStack.Last() string shown in the status bar control ellipsized?
90 bool m_bEllipsized;
91 };
92
93 WX_DECLARE_OBJARRAY(wxStatusBarPane, wxStatusBarPaneArray);
94
95 // ----------------------------------------------------------------------------
96 // wxStatusBar: a window near the bottom of the frame used for status info
97 // ----------------------------------------------------------------------------
98
99 class WXDLLIMPEXP_CORE wxStatusBarBase : public wxWindow
100 {
101 public:
102 wxStatusBarBase();
103
104 virtual ~wxStatusBarBase();
105
106 // field count
107 // -----------
108
109 // set the number of fields and call SetStatusWidths(widths) if widths are
110 // given
111 virtual void SetFieldsCount(int number = 1, const int *widths = NULL);
112 int GetFieldsCount() const { return m_panes.GetCount(); }
113
114 // field text
115 // ----------
116
117 // NOTE: even if it is not pure virtual, SetStatusText() must be overloaded by
118 // the derived classes to update the given text in the native control
119 virtual void SetStatusText(const wxString& text, int number = 0)
120 { m_panes[number].GetStack().Last() = text; }
121 virtual wxString GetStatusText(int number = 0) const
122 { return m_panes[number].GetStack().Last(); }
123 const wxArrayString& GetStatusStack(int n) const
124 { return m_panes[n].GetStack(); }
125
126 void PushStatusText(const wxString& text, int number = 0);
127 void PopStatusText(int number = 0);
128
129 // fields widths
130 // -------------
131
132 // set status field widths as absolute numbers: positive widths mean that
133 // the field has the specified absolute width, negative widths are
134 // interpreted as the sizer options, i.e. the extra space (total space
135 // minus the sum of fixed width fields) is divided between the fields with
136 // negative width according to the abs value of the width (field with width
137 // -2 grows twice as much as one with width -1 &c)
138 virtual void SetStatusWidths(int n, const int widths[]);
139
140 int GetStatusWidth(int n) const
141 { return m_panes[n].GetWidth(); }
142
143 // field styles
144 // ------------
145
146 // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
147 // border around a field, wxSB_FLAT for no border around a field, so that it
148 // appears flat or wxSB_POPOUT to make the field appear raised.
149 // Setting field styles only works on wxMSW
150 virtual void SetStatusStyles(int n, const int styles[]);
151
152 int GetStatusStyle(int n) const
153 { return m_panes[n].GetStyle(); }
154
155 // geometry
156 // --------
157
158 // Get the position and size of the field's internal bounding rectangle
159 virtual bool GetFieldRect(int i, wxRect& rect) const = 0;
160
161 // sets the minimal vertical size of the status bar
162 virtual void SetMinHeight(int height) = 0;
163
164 // get the dimensions of the horizontal and vertical borders
165 virtual int GetBorderX() const = 0;
166 virtual int GetBorderY() const = 0;
167
168 wxSize GetBorders() const
169 { return wxSize(GetBorderX(), GetBorderY()); }
170
171 // miscellaneous
172 // -------------
173
174 const wxStatusBarPane& GetField(int n) const
175 { return m_panes[n]; }
176
177 // wxWindow overrides:
178
179 // don't want status bars to accept the focus at all
180 virtual bool AcceptsFocus() const { return false; }
181
182 // the client size of a toplevel window doesn't include the status bar
183 virtual bool CanBeOutsideClientArea() const { return true; }
184
185 protected:
186 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
187
188 // calculate the real field widths for the given total available size
189 wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const;
190
191 // an internal utility used to keep track of which panes have labels
192 // which were last rendered as ellipsized...
193 void SetEllipsizedFlag(int n, bool ellipsized)
194 { m_panes[n].m_bEllipsized = ellipsized; }
195
196 // the array with the pane infos:
197 wxStatusBarPaneArray m_panes;
198
199 // if true overrides the width info of the wxStatusBarPanes
200 bool m_bSameWidthForAllPanes;
201
202 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase);
203 };
204
205 // ----------------------------------------------------------------------------
206 // include the actual wxStatusBar class declaration
207 // ----------------------------------------------------------------------------
208
209 #if defined(__WXUNIVERSAL__)
210 #define wxStatusBarUniv wxStatusBar
211 #include "wx/univ/statusbr.h"
212 #elif defined(__WXPALMOS__)
213 #define wxStatusBarPalm wxStatusBar
214 #include "wx/palmos/statusbr.h"
215 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
216 #include "wx/msw/statusbar.h"
217 #elif defined(__WXMAC__)
218 #define wxStatusBarMac wxStatusBar
219 #include "wx/generic/statusbr.h"
220 #include "wx/osx/statusbr.h"
221 #else
222 #define wxStatusBarGeneric wxStatusBar
223 #include "wx/generic/statusbr.h"
224 #endif
225
226 #endif // wxUSE_STATUSBAR
227
228 #endif
229 // _WX_STATUSBR_H_BASE_