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