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 // NOTE: even if it is not pure virtual, SetStatusText() must be overloaded by
109 // the derived classes to update the given text in the native control
110 virtual void SetStatusText(const wxString
& text
, int number
= 0)
111 { m_panes
[number
].GetStack().Last() = text
; }
112 virtual wxString
GetStatusText(int number
= 0) const
113 { return m_panes
[number
].GetStack().Last(); }
114 const wxArrayString
& GetStatusStack(int n
) const
115 { return m_panes
[n
].GetStack(); }
117 void PushStatusText(const wxString
& text
, int number
= 0);
118 void PopStatusText(int number
= 0);
123 // set status field widths as absolute numbers: positive widths mean that
124 // the field has the specified absolute width, negative widths are
125 // interpreted as the sizer options, i.e. the extra space (total space
126 // minus the sum of fixed width fields) is divided between the fields with
127 // negative width according to the abs value of the width (field with width
128 // -2 grows twice as much as one with width -1 &c)
129 virtual void SetStatusWidths(int n
, const int widths
[]);
131 int GetStatusWidth(int n
) const
132 { return m_panes
[n
].GetWidth(); }
137 // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
138 // border around a field, wxSB_FLAT for no border around a field, so that it
139 // appears flat or wxSB_POPOUT to make the field appear raised.
140 // Setting field styles only works on wxMSW
141 virtual void SetStatusStyles(int n
, const int styles
[]);
143 int GetStatusStyle(int n
) const
144 { return m_panes
[n
].GetStyle(); }
149 // Get the position and size of the field's internal bounding rectangle
150 virtual bool GetFieldRect(int i
, wxRect
& rect
) const = 0;
152 // sets the minimal vertical size of the status bar
153 virtual void SetMinHeight(int height
) = 0;
155 // get the dimensions of the horizontal and vertical borders
156 virtual int GetBorderX() const = 0;
157 virtual int GetBorderY() const = 0;
159 wxSize
GetBorders() const
160 { return wxSize(GetBorderX(), GetBorderY()); }
165 const wxStatusBarPane
& GetField(int n
) const
166 { return m_panes
[n
]; }
168 // wxWindow overrides:
170 // don't want status bars to accept the focus at all
171 virtual bool AcceptsFocus() const { return false; }
173 // the client size of a toplevel window doesn't include the status bar
174 virtual bool CanBeOutsideClientArea() const { return true; }
177 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
179 // calculate the real field widths for the given total available size
180 wxArrayInt
CalculateAbsWidths(wxCoord widthTotal
) const;
182 // an internal utility used to keep track of which panes have labels
183 // which were last rendered as ellipsized...
184 void SetEllipsizedFlag(int n
, bool ellipsized
)
185 { m_panes
[n
].m_bEllipsized
= ellipsized
; }
187 // the array with the pane infos:
188 wxStatusBarPaneArray m_panes
;
190 // if true overrides the width info of the wxStatusBarPanes
191 bool m_bSameWidthForAllPanes
;
193 wxDECLARE_NO_COPY_CLASS(wxStatusBarBase
);
196 // ----------------------------------------------------------------------------
197 // include the actual wxStatusBar class declaration
198 // ----------------------------------------------------------------------------
200 #if defined(__WXUNIVERSAL__)
201 #define wxStatusBarUniv wxStatusBar
202 #include "wx/univ/statusbr.h"
203 #elif defined(__WXPALMOS__)
204 #define wxStatusBarPalm wxStatusBar
205 #include "wx/palmos/statusbr.h"
206 #elif defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR
207 #include "wx/msw/statusbar.h"
208 #elif defined(__WXMAC__)
209 #define wxStatusBarMac wxStatusBar
210 #include "wx/generic/statusbr.h"
211 #include "wx/osx/statusbr.h"
213 #define wxStatusBarGeneric wxStatusBar
214 #include "wx/generic/statusbr.h"
217 #endif // wxUSE_STATUSBAR
220 // _WX_STATUSBR_H_BASE_