]>
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/window.h" | |
16 | ||
17 | #if wxUSE_STATUSBAR | |
18 | ||
19 | #include "wx/list.h" | |
20 | #include "wx/dynarray.h" | |
21 | ||
22 | WX_DECLARE_LIST(wxString, wxListString); | |
23 | ||
24 | // ---------------------------------------------------------------------------- | |
25 | // wxStatusBar constants | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | // style flags for fields | |
29 | #define wxSB_NORMAL 0x0000 | |
30 | #define wxSB_FLAT 0x0001 | |
31 | #define wxSB_RAISED 0x0002 | |
32 | ||
33 | // ---------------------------------------------------------------------------- | |
34 | // wxStatusBar: a window near the bottom of the frame used for status info | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | class WXDLLEXPORT wxStatusBarBase : public wxWindow | |
38 | { | |
39 | public: | |
40 | wxStatusBarBase(); | |
41 | ||
42 | virtual ~wxStatusBarBase(); | |
43 | ||
44 | // field count | |
45 | // ----------- | |
46 | ||
47 | // set the number of fields and call SetStatusWidths(widths) if widths are | |
48 | // given | |
49 | virtual void SetFieldsCount(int number = 1, const int *widths = NULL); | |
50 | int GetFieldsCount() const { return m_nFields; } | |
51 | ||
52 | // field text | |
53 | // ---------- | |
54 | ||
55 | virtual void SetStatusText(const wxString& text, int number = 0) = 0; | |
56 | virtual wxString GetStatusText(int number = 0) const = 0; | |
57 | ||
58 | void PushStatusText(const wxString& text, int number = 0); | |
59 | void PopStatusText(int number = 0); | |
60 | ||
61 | // fields widths | |
62 | // ------------- | |
63 | ||
64 | // set status field widths as absolute numbers: positive widths mean that | |
65 | // the field has the specified absolute width, negative widths are | |
66 | // interpreted as the sizer options, i.e. the extra space (total space | |
67 | // minus the sum of fixed width fields) is divided between the fields with | |
68 | // negative width according to the abs value of the width (field with width | |
69 | // -2 grows twice as much as one with width -1 &c) | |
70 | virtual void SetStatusWidths(int n, const int widths[]); | |
71 | ||
72 | // field styles | |
73 | // ------------ | |
74 | ||
75 | // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D | |
76 | // border around a field, wxSB_FLAT for no border around a field, so that it | |
77 | // appears flat or wxSB_POPOUT to make the field appear raised. | |
78 | // Setting field styles only works on wxMSW | |
79 | virtual void SetStatusStyles(int n, const int styles[]); | |
80 | ||
81 | // geometry | |
82 | // -------- | |
83 | ||
84 | // Get the position and size of the field's internal bounding rectangle | |
85 | virtual bool GetFieldRect(int i, wxRect& rect) const = 0; | |
86 | ||
87 | // sets the minimal vertical size of the status bar | |
88 | virtual void SetMinHeight(int height) = 0; | |
89 | ||
90 | // get the dimensions of the horizontal and vertical borders | |
91 | virtual int GetBorderX() const = 0; | |
92 | virtual int GetBorderY() const = 0; | |
93 | ||
94 | // don't want status bars to accept the focus at all | |
95 | virtual bool AcceptsFocus() const { return false; } | |
96 | ||
97 | protected: | |
98 | // set the widths array to NULL | |
99 | void InitWidths(); | |
100 | ||
101 | // free the status widths arrays | |
102 | void FreeWidths(); | |
103 | ||
104 | // reset the widths | |
105 | void ReinitWidths() { FreeWidths(); InitWidths(); } | |
106 | ||
107 | // same, for field styles | |
108 | void InitStyles(); | |
109 | void FreeStyles(); | |
110 | void ReinitStyles() { FreeStyles(); InitStyles(); } | |
111 | ||
112 | // same, for text stacks | |
113 | void InitStacks(); | |
114 | void FreeStacks(); | |
115 | void ReinitStacks() { FreeStacks(); InitStacks(); } | |
116 | ||
117 | // calculate the real field widths for the given total available size | |
118 | wxArrayInt CalculateAbsWidths(wxCoord widthTotal) const; | |
119 | ||
120 | // use these functions to access the stacks of field strings | |
121 | wxListString *GetStatusStack(int i) const; | |
122 | wxListString *GetOrCreateStatusStack(int i); | |
123 | ||
124 | // the current number of fields | |
125 | int m_nFields; | |
126 | ||
127 | // the widths of the fields in pixels if !NULL, all fields have the same | |
128 | // width otherwise | |
129 | int *m_statusWidths; | |
130 | ||
131 | // the styles of the fields | |
132 | int *m_statusStyles; | |
133 | ||
134 | // stacks of previous values for PushStatusText/PopStatusText | |
135 | // this is created on demand, use GetStatusStack/GetOrCreateStatusStack | |
136 | wxListString **m_statusTextStacks; | |
137 | ||
138 | DECLARE_NO_COPY_CLASS(wxStatusBarBase) | |
139 | }; | |
140 | ||
141 | // ---------------------------------------------------------------------------- | |
142 | // include the actual wxStatusBar class declaration | |
143 | // ---------------------------------------------------------------------------- | |
144 | ||
145 | #if defined(__WXUNIVERSAL__) | |
146 | #define wxStatusBarUniv wxStatusBar | |
147 | ||
148 | #include "wx/univ/statusbr.h" | |
149 | #elif defined(__WXPALMOS__) | |
150 | #define wxStatusBarPalm wxStatusBar | |
151 | ||
152 | #include "wx/palmos/statusbr.h" | |
153 | #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR | |
154 | #define wxStatusBar95 wxStatusBar | |
155 | ||
156 | #include "wx/msw/statbr95.h" | |
157 | #elif defined(__WXMAC__) | |
158 | #define wxStatusBarMac wxStatusBar | |
159 | ||
160 | #include "wx/generic/statusbr.h" | |
161 | #include "wx/mac/statusbr.h" | |
162 | #else | |
163 | #define wxStatusBarGeneric wxStatusBar | |
164 | ||
165 | #include "wx/generic/statusbr.h" | |
166 | #endif | |
167 | ||
168 | #endif // wxUSE_STATUSBAR | |
169 | ||
170 | #endif | |
171 | // _WX_STATUSBR_H_BASE_ |