]> git.saurik.com Git - wxWidgets.git/blob - include/wx/statusbr.h
VC6 compilation fixes
[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
187 // wxWindow overrides:
188
189 #if wxUSE_TOOLTIPS
190 virtual void DoSetToolTip( wxToolTip *tip )
191 {
192 wxASSERT_MSG(!HasFlag(wxSTB_SHOW_TIPS),
193 "Do not set tooltip(s) manually when using wxSTB_SHOW_TIPS!");
194 wxWindow::DoSetToolTip(tip);
195 }
196 #endif
197
198 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
199
200
201 // internal helpers & data:
202
203 // calculate the real field widths for the given total available size
204 wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const;
205
206 // an internal utility used to keep track of which panes have labels
207 // which were last rendered as ellipsized...
208 void SetEllipsizedFlag(int n, bool ellipsized)
209 { m_panes[n].m_bEllipsized = ellipsized; }
210
211 // the array with the pane infos:
212 wxStatusBarPaneArray m_panes;
213
214 // if true overrides the width info of the wxStatusBarPanes
215 bool m_bSameWidthForAllPanes;
216
217 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase);
218 };
219
220 // ----------------------------------------------------------------------------
221 // include the actual wxStatusBar class declaration
222 // ----------------------------------------------------------------------------
223
224 #if defined(__WXUNIVERSAL__)
225 #define wxStatusBarUniv wxStatusBar
226 #include "wx/univ/statusbr.h"
227 #elif defined(__WXPALMOS__)
228 #define wxStatusBarPalm wxStatusBar
229 #include "wx/palmos/statusbr.h"
230 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
231 #include "wx/msw/statusbar.h"
232 #elif defined(__WXMAC__)
233 #define wxStatusBarMac wxStatusBar
234 #include "wx/generic/statusbr.h"
235 #include "wx/osx/statusbr.h"
236 #else
237 #define wxStatusBarGeneric wxStatusBar
238 #include "wx/generic/statusbr.h"
239 #endif
240
241 #endif // wxUSE_STATUSBAR
242
243 #endif
244 // _WX_STATUSBR_H_BASE_