1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStatusBar class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STATUSBR_H_BASE_
13 #define _WX_STATUSBR_H_BASE_
19 #include "wx/window.h"
21 #include "wx/dynarray.h"
23 extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusBarNameStr
[];
25 // ----------------------------------------------------------------------------
26 // wxStatusBar constants
27 // ----------------------------------------------------------------------------
30 #define wxST_SIZEGRIP 0x0010
31 #define wxST_SHOW_TIPS 0x0020
33 #define wxST_DEFAULT_STYLE (wxST_SIZEGRIP|wxST_SHOW_TIPS|wxFULL_REPAINT_ON_RESIZE)
35 // style flags for fields
36 #define wxSB_NORMAL 0x0000
37 #define wxSB_FLAT 0x0001
38 #define wxSB_RAISED 0x0002
40 // ----------------------------------------------------------------------------
41 // wxStatusBarPane: an helper for wxStatusBar
42 // ----------------------------------------------------------------------------
44 class WXDLLIMPEXP_CORE wxStatusBarPane
46 // only wxStatusBarBase can access our internal members and modify them:
47 friend class WXDLLIMPEXP_FWD_CORE wxStatusBarBase
;
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; }
59 const wxArrayString
& GetStack() const
60 { return m_arrStack
; }
62 // implementation-only getter:
63 bool IsEllipsized() const
64 { return m_bEllipsized
; }
66 // NOTE: there are no setters in wxStatusBarPane;
67 // use wxStatusBar functions to modify a wxStatusBarPane
71 int m_nWidth
; // the width maybe negative, indicating a variable-width field
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
;
80 // was the m_arrStack.Last() string shown in the status bar control ellipsized?
84 WX_DECLARE_OBJARRAY(wxStatusBarPane
, wxStatusBarPaneArray
);
86 // ----------------------------------------------------------------------------
87 // wxStatusBar: a window near the bottom of the frame used for status info
88 // ----------------------------------------------------------------------------
90 class WXDLLIMPEXP_CORE wxStatusBarBase
: public wxWindow
95 virtual ~wxStatusBarBase();
100 // set the number of fields and call SetStatusWidths(widths) if widths are
102 virtual void SetFieldsCount(int number
= 1, const int *widths
= NULL
);
103 int GetFieldsCount() const { return m_panes
.GetCount(); }
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(); }
115 void PushStatusText(const wxString
& text
, int number
= 0);
116 void PopStatusText(int number
= 0);
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
[]);
129 int GetStatusWidth(int n
) const
130 { return m_panes
[n
].GetWidth(); }
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
[]);
141 int GetStatusStyle(int n
) const
142 { return m_panes
[n
].GetStyle(); }
147 // Get the position and size of the field's internal bounding rectangle
148 virtual bool GetFieldRect(int i
, wxRect
& rect
) const = 0;
150 // sets the minimal vertical size of the status bar
151 virtual void SetMinHeight(int height
) = 0;
153 // get the dimensions of the horizontal and vertical borders
154 virtual int GetBorderX() const = 0;
155 virtual int GetBorderY() const = 0;
157 wxSize
GetBorders() const
158 { return wxSize(GetBorderX(), GetBorderY()); }
163 const wxStatusBarPane
& GetField(int n
) const
164 { return m_panes
[n
]; }
166 // wxWindow overrides:
168 // don't want status bars to accept the focus at all
169 virtual bool AcceptsFocus() const { return false; }
171 // the client size of a toplevel window doesn't include the status bar
172 virtual bool CanBeOutsideClientArea() const { return true; }
175 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
177 // calculate the real field widths for the given total available size
178 wxArrayInt
CalculateAbsWidths(wxCoord widthTotal
) const;
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
; }
185 // the array with the pane infos:
186 wxStatusBarPaneArray m_panes
;
188 // if true overrides the width info of the wxStatusBarPanes
189 bool m_bSameWidthForAllPanes
;
191 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase
);
194 // ----------------------------------------------------------------------------
195 // include the actual wxStatusBar class declaration
196 // ----------------------------------------------------------------------------
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"
211 #define wxStatusBarGeneric wxStatusBar
212 #include "wx/generic/statusbr.h"
215 #endif // wxUSE_STATUSBAR
218 // _WX_STATUSBR_H_BASE_