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