]>
Commit | Line | Data |
---|---|---|
5279a24d RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: sizer.h | |
0c0d686f | 3 | // Purpose: provide wxSizer class for layouting |
5279a24d RR |
4 | // Author: Robert Roebling and Robin Dunn |
5 | // Modified by: | |
0c0d686f | 6 | // Created: |
5279a24d RR |
7 | // RCS-ID: $Id$ |
8 | // Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef __WXSIZER_H__ | |
13 | #define __WXSIZER_H__ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "sizer.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #include "wx/window.h" | |
22 | #include "wx/frame.h" | |
23 | #include "wx/dialog.h" | |
24 | ||
25 | //--------------------------------------------------------------------------- | |
26 | // classes | |
27 | //--------------------------------------------------------------------------- | |
28 | ||
27ea1d8a | 29 | class wxStaticBox; |
83edc0a5 | 30 | class wxNotebook; |
27ea1d8a | 31 | |
3417c2cd RR |
32 | class wxSizerItem; |
33 | class wxSizer; | |
92afa2b1 | 34 | class wxBoxSizer; |
27ea1d8a | 35 | class wxStaticBoxSizer; |
5279a24d RR |
36 | |
37 | //--------------------------------------------------------------------------- | |
3417c2cd | 38 | // wxSizerItem |
5279a24d RR |
39 | //--------------------------------------------------------------------------- |
40 | ||
3417c2cd | 41 | class WXDLLEXPORT wxSizerItem: public wxObject |
5279a24d | 42 | { |
0c0d686f | 43 | DECLARE_CLASS(wxSizerItem); |
5279a24d RR |
44 | public: |
45 | // spacer | |
0c0d686f | 46 | wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData); |
5279a24d RR |
47 | |
48 | // window | |
0c0d686f | 49 | wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData ); |
5279a24d RR |
50 | |
51 | // subsizer | |
0c0d686f RD |
52 | wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData ); |
53 | ||
54 | ~wxSizerItem(); | |
5279a24d | 55 | |
c62ac5b6 RR |
56 | virtual wxSize GetSize(); |
57 | virtual wxSize CalcMin(); | |
58 | virtual void SetDimension( wxPoint pos, wxSize size ); | |
0c0d686f | 59 | |
be2577e4 RD |
60 | void SetRatio( int width, int height ) |
61 | // if either of dimensions is zero, ratio is assumed to be 1 | |
62 | // to avoid "divide by zero" errors | |
63 | { m_ratio = (width && height) ? ((float) width / (float) height) : 1; } | |
64 | void SetRatio( wxSize size ) | |
65 | { m_ratio = (size.x && size.y) ? ((float) size.x / (float) size.y) : 1; } | |
66 | void SetRatio( float ratio ) { m_ratio = ratio; } | |
67 | float GetRatio() const { return m_ratio; } | |
68 | ||
5279a24d | 69 | bool IsWindow(); |
3417c2cd | 70 | bool IsSizer(); |
5279a24d | 71 | bool IsSpacer(); |
0c0d686f RD |
72 | |
73 | wxWindow *GetWindow() const | |
5279a24d | 74 | { return m_window; } |
0c0d686f | 75 | wxSizer *GetSizer() const |
5279a24d RR |
76 | { return m_sizer; } |
77 | int GetOption() const | |
78 | { return m_option; } | |
d597fcb7 RR |
79 | int GetFlag() const |
80 | { return m_flag; } | |
81 | int GetBorder() const | |
82 | { return m_border; } | |
0c0d686f RD |
83 | wxObject* GetUserData() |
84 | { return m_userData; } | |
85 | ||
c62ac5b6 | 86 | protected: |
5279a24d | 87 | wxWindow *m_window; |
3417c2cd | 88 | wxSizer *m_sizer; |
d597fcb7 | 89 | wxSize m_size; |
5279a24d RR |
90 | wxSize m_minSize; |
91 | int m_option; | |
d597fcb7 RR |
92 | int m_border; |
93 | int m_flag; | |
be2577e4 RD |
94 | // als: aspect ratio can always be calculated from m_size, |
95 | // but this would cause precision loss when the window | |
96 | // is shrinked. it is safer to preserve initial value. | |
97 | float m_ratio; | |
0c0d686f | 98 | wxObject *m_userData; |
c62ac5b6 | 99 | }; |
5279a24d RR |
100 | |
101 | //--------------------------------------------------------------------------- | |
3417c2cd | 102 | // wxSizer |
5279a24d RR |
103 | //--------------------------------------------------------------------------- |
104 | ||
3417c2cd | 105 | class WXDLLEXPORT wxSizer: public wxObject |
5279a24d | 106 | { |
0c0d686f | 107 | DECLARE_CLASS(wxSizer); |
5279a24d | 108 | public: |
3417c2cd RR |
109 | wxSizer(); |
110 | ~wxSizer(); | |
0c0d686f RD |
111 | |
112 | virtual void Add( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); | |
113 | virtual void Add( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); | |
114 | virtual void Add( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); | |
115 | ||
116 | virtual void Prepend( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); | |
117 | virtual void Prepend( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); | |
118 | virtual void Prepend( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL ); | |
119 | ||
42b4e99e RR |
120 | virtual bool Remove( wxWindow *window ); |
121 | virtual bool Remove( wxSizer *sizer ); | |
122 | virtual bool Remove( int pos ); | |
0c0d686f | 123 | |
c62ac5b6 | 124 | void SetDimension( int x, int y, int width, int height ); |
0c0d686f | 125 | |
5279a24d RR |
126 | wxSize GetSize() |
127 | { return m_size; } | |
128 | wxPoint GetPosition() | |
129 | { return m_position; } | |
130 | wxSize GetMinSize() | |
131 | { return CalcMin(); } | |
c62ac5b6 | 132 | |
5279a24d RR |
133 | virtual void RecalcSizes() = 0; |
134 | virtual wxSize CalcMin() = 0; | |
0c0d686f | 135 | |
c62ac5b6 | 136 | virtual void Layout(); |
5279a24d RR |
137 | |
138 | void Fit( wxWindow *window ); | |
139 | void SetSizeHints( wxWindow *window ); | |
0c0d686f RD |
140 | |
141 | wxList& GetChildren() | |
142 | { return m_children; } | |
143 | ||
c62ac5b6 | 144 | protected: |
5279a24d RR |
145 | wxSize m_size; |
146 | wxPoint m_position; | |
147 | wxList m_children; | |
0c0d686f | 148 | |
5279a24d | 149 | wxSize GetMinWindowSize( wxWindow *window ); |
c62ac5b6 RR |
150 | }; |
151 | ||
152 | //--------------------------------------------------------------------------- | |
92afa2b1 | 153 | // wxBoxSizer |
c62ac5b6 RR |
154 | //--------------------------------------------------------------------------- |
155 | ||
92afa2b1 | 156 | class WXDLLEXPORT wxBoxSizer: public wxSizer |
61d514bb | 157 | { |
0c0d686f | 158 | DECLARE_CLASS(wxBoxSizer); |
61d514bb | 159 | public: |
92afa2b1 | 160 | wxBoxSizer( int orient ); |
0c0d686f | 161 | |
61d514bb RR |
162 | void RecalcSizes(); |
163 | wxSize CalcMin(); | |
0c0d686f | 164 | |
61d514bb RR |
165 | int GetOrientation() |
166 | { return m_orient; } | |
0c0d686f | 167 | |
61d514bb RR |
168 | protected: |
169 | int m_orient; | |
170 | int m_stretchable; | |
171 | int m_minWidth; | |
172 | int m_minHeight; | |
173 | int m_fixedWidth; | |
174 | int m_fixedHeight; | |
175 | }; | |
0c0d686f | 176 | |
27ea1d8a RR |
177 | //--------------------------------------------------------------------------- |
178 | // wxStaticBoxSizer | |
179 | //--------------------------------------------------------------------------- | |
180 | ||
181 | class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer | |
182 | { | |
0c0d686f | 183 | DECLARE_CLASS(wxStaticBoxSizer); |
27ea1d8a RR |
184 | public: |
185 | wxStaticBoxSizer( wxStaticBox *box, int orient ); | |
0c0d686f | 186 | |
27ea1d8a RR |
187 | void RecalcSizes(); |
188 | wxSize CalcMin(); | |
0c0d686f | 189 | |
27ea1d8a RR |
190 | wxStaticBox *GetStaticBox() |
191 | { return m_staticBox; } | |
0c0d686f | 192 | |
27ea1d8a RR |
193 | protected: |
194 | wxStaticBox *m_staticBox; | |
195 | }; | |
196 | ||
83edc0a5 RR |
197 | //--------------------------------------------------------------------------- |
198 | // wxNotebookSizer | |
199 | //--------------------------------------------------------------------------- | |
200 | ||
65e4f9b9 VS |
201 | #if wxUSE_NOTEBOOK |
202 | ||
83edc0a5 RR |
203 | class WXDLLEXPORT wxNotebookSizer: public wxSizer |
204 | { | |
205 | DECLARE_CLASS(wxNotebookSizer); | |
206 | public: | |
207 | wxNotebookSizer( wxNotebook *nb ); | |
208 | ||
209 | void RecalcSizes(); | |
210 | wxSize CalcMin(); | |
211 | ||
212 | wxNotebook *GetNotebook() | |
213 | { return m_notebook; } | |
214 | ||
215 | protected: | |
216 | wxNotebook *m_notebook; | |
217 | }; | |
218 | ||
65e4f9b9 VS |
219 | #endif |
220 | ||
221 | ||
5279a24d RR |
222 | #endif |
223 | // __WXSIZER_H__ |