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