]>
Commit | Line | Data |
---|---|---|
5279a24d RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: sizer.h | |
a4ab8ed5 | 3 | // Purpose: provide wxSizer class for layout |
5279a24d | 4 | // Author: Robert Roebling and Robin Dunn |
5f813ad6 | 5 | // Modified by: Ron Lee, Vadim Zeitlin (wxSizerFlags) |
0c0d686f | 6 | // Created: |
5279a24d | 7 | // RCS-ID: $Id$ |
a4ab8ed5 | 8 | // Copyright: (c) Robin Dunn, Robert Roebling |
65571936 | 9 | // Licence: wxWindows licence |
5279a24d RR |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef __WXSIZER_H__ | |
13 | #define __WXSIZER_H__ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
5279a24d RR |
16 | #pragma interface "sizer.h" |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
acf2ac37 | 21 | #include "wx/button.h" |
5279a24d RR |
22 | #include "wx/window.h" |
23 | #include "wx/frame.h" | |
24 | #include "wx/dialog.h" | |
c845a197 | 25 | #include "wx/bookctrl.h" |
5279a24d RR |
26 | |
27 | //--------------------------------------------------------------------------- | |
28 | // classes | |
29 | //--------------------------------------------------------------------------- | |
30 | ||
446e5259 VS |
31 | class WXDLLEXPORT wxSizerItem; |
32 | class WXDLLEXPORT wxSizer; | |
33 | class WXDLLEXPORT wxBoxSizer; | |
5279a24d | 34 | |
5f813ad6 VZ |
35 | |
36 | // ---------------------------------------------------------------------------- | |
37 | // wxSizerFlags: flags used for an item in the sizer | |
38 | // ---------------------------------------------------------------------------- | |
39 | ||
40 | class WXDLLEXPORT wxSizerFlags | |
41 | { | |
42 | public: | |
43 | // construct the flags object initialized with the given proportion (0 by | |
44 | // default) | |
45 | wxSizerFlags(int proportion = 0) : m_proportion(proportion) | |
46 | { | |
47 | m_flags = 0; | |
48 | m_borderInPixels = 0; | |
49 | } | |
50 | ||
51 | // setters for all sizer flags, they all return the object itself so that | |
52 | // calls to them can be chained | |
53 | ||
54 | wxSizerFlags& Proportion(int proportion) | |
55 | { | |
56 | m_proportion = proportion; | |
57 | return *this; | |
58 | } | |
59 | ||
60 | wxSizerFlags& Align(int alignment) // combination of wxAlignment values | |
61 | { | |
62 | m_flags &= wxALL; | |
63 | m_flags |= alignment; | |
64 | ||
65 | return *this; | |
66 | } | |
67 | ||
68 | // some shortcuts for Align() | |
69 | wxSizerFlags& Expand() { return Align(wxEXPAND); } | |
70 | wxSizerFlags& Centre() { return Align(wxCENTRE); } | |
71 | wxSizerFlags& Center() { return Centre(); } | |
72 | ||
73 | ||
74 | wxSizerFlags& Border(int direction, int borderInPixels) | |
75 | { | |
76 | m_flags &= ~wxALL; | |
77 | m_flags |= direction; | |
78 | ||
79 | m_borderInPixels = borderInPixels; | |
80 | ||
81 | return *this; | |
82 | } | |
83 | ||
84 | wxSizerFlags& Border(int direction = wxALL) | |
85 | { | |
86 | // FIXME: default border size shouldn't be hardcoded | |
87 | return Border(direction, 5); | |
88 | } | |
89 | ||
90 | ||
91 | // accessors for wxSizer only | |
92 | int GetProportion() const { return m_proportion; } | |
93 | int GetFlags() const { return m_flags; } | |
94 | int GetBorderInPixels() const { return m_borderInPixels; } | |
95 | ||
96 | private: | |
97 | int m_proportion; | |
98 | int m_flags; | |
99 | int m_borderInPixels; | |
100 | }; | |
101 | ||
102 | ||
5279a24d | 103 | //--------------------------------------------------------------------------- |
3417c2cd | 104 | // wxSizerItem |
5279a24d RR |
105 | //--------------------------------------------------------------------------- |
106 | ||
3417c2cd | 107 | class WXDLLEXPORT wxSizerItem: public wxObject |
5279a24d RR |
108 | { |
109 | public: | |
5f813ad6 VZ |
110 | // window with flags |
111 | wxSizerItem(wxWindow *window, const wxSizerFlags& flags) | |
112 | { | |
113 | Init(flags); | |
114 | ||
115 | m_window = window; | |
116 | } | |
117 | ||
118 | // sizer with flags | |
119 | wxSizerItem(wxSizer *sizer, const wxSizerFlags& flags) | |
120 | { | |
121 | Init(flags); | |
122 | ||
123 | m_sizer = sizer; | |
124 | } | |
df5ddbca RR |
125 | |
126 | // window | |
12a3f227 RL |
127 | wxSizerItem( wxWindow *window, |
128 | int proportion, | |
129 | int flag, | |
130 | int border, | |
131 | wxObject* userData ); | |
df5ddbca RR |
132 | |
133 | // subsizer | |
12a3f227 RL |
134 | wxSizerItem( wxSizer *sizer, |
135 | int proportion, | |
136 | int flag, | |
137 | int border, | |
138 | wxObject* userData ); | |
df5ddbca | 139 | |
5f813ad6 VZ |
140 | // spacer |
141 | wxSizerItem( int width, | |
142 | int height, | |
143 | int proportion, | |
144 | int flag, | |
145 | int border, | |
146 | wxObject* userData); | |
147 | ||
20b35a69 RD |
148 | wxSizerItem(); |
149 | virtual ~wxSizerItem(); | |
dc259b79 | 150 | |
84f7908b | 151 | virtual void DeleteWindows(); |
df5ddbca | 152 | |
96fdbb60 RL |
153 | // Enable deleting the SizerItem without destroying the contained sizer. |
154 | void DetachSizer() | |
155 | { m_sizer = 0; } | |
156 | ||
9cbee2ce | 157 | virtual wxSize GetSize() const; |
df5ddbca RR |
158 | virtual wxSize CalcMin(); |
159 | virtual void SetDimension( wxPoint pos, wxSize size ); | |
160 | ||
9cbee2ce | 161 | wxSize GetMinSize() const |
df5ddbca | 162 | { return m_minSize; } |
ba763a45 RD |
163 | wxSize GetMinSizeWithBorder() const; |
164 | ||
1eba2193 RD |
165 | void SetMinSize(const wxSize& size) |
166 | { | |
ba763a45 | 167 | if (IsWindow()) m_window->SetMinSize(size); |
8b2bac62 | 168 | m_minSize = size; |
1eba2193 RD |
169 | } |
170 | void SetMinSize( int x, int y ) | |
8b2bac62 | 171 | { SetMinSize(wxSize(x, y)); } |
12a3f227 | 172 | void SetInitSize( int x, int y ) |
1eba2193 | 173 | { SetMinSize(wxSize(x, y)); } |
df5ddbca RR |
174 | |
175 | void SetRatio( int width, int height ) | |
176 | // if either of dimensions is zero, ratio is assumed to be 1 | |
177 | // to avoid "divide by zero" errors | |
178 | { m_ratio = (width && height) ? ((float) width / (float) height) : 1; } | |
179 | void SetRatio( wxSize size ) | |
180 | { m_ratio = (size.x && size.y) ? ((float) size.x / (float) size.y) : 1; } | |
2aab8f16 | 181 | void SetRatio( float ratio ) |
df5ddbca | 182 | { m_ratio = ratio; } |
2aab8f16 | 183 | float GetRatio() const |
df5ddbca RR |
184 | { return m_ratio; } |
185 | ||
56eee37f WS |
186 | virtual wxRect GetRect() { return m_zoneRect; } |
187 | ||
9cbee2ce RL |
188 | bool IsWindow() const; |
189 | bool IsSizer() const; | |
190 | bool IsSpacer() const; | |
2aab8f16 | 191 | |
12a3f227 RL |
192 | // Deprecated in 2.6, use {G,S}etProportion instead. |
193 | wxDEPRECATED( void SetOption( int option ) ); | |
194 | wxDEPRECATED( int GetOption() const ); | |
195 | ||
196 | void SetProportion( int proportion ) | |
197 | { m_proportion = proportion; } | |
198 | int GetProportion() const | |
199 | { return m_proportion; } | |
df5ddbca RR |
200 | void SetFlag( int flag ) |
201 | { m_flag = flag; } | |
12a3f227 RL |
202 | int GetFlag() const |
203 | { return m_flag; } | |
df5ddbca RR |
204 | void SetBorder( int border ) |
205 | { m_border = border; } | |
12a3f227 RL |
206 | int GetBorder() const |
207 | { return m_border; } | |
df5ddbca RR |
208 | |
209 | wxWindow *GetWindow() const | |
210 | { return m_window; } | |
211 | void SetWindow( wxWindow *window ) | |
1621c234 | 212 | { m_window = window; m_minSize = window->GetSize(); } |
df5ddbca RR |
213 | wxSizer *GetSizer() const |
214 | { return m_sizer; } | |
215 | void SetSizer( wxSizer *sizer ) | |
216 | { m_sizer = sizer; } | |
12a3f227 RL |
217 | const wxSize &GetSpacer() const |
218 | { return m_size; } | |
219 | void SetSpacer( const wxSize &size ) | |
220 | { m_size = size; m_minSize = size; } | |
221 | ||
222 | void Show ( bool show ); | |
2b5f62a0 VZ |
223 | bool IsShown() const |
224 | { return m_show; } | |
12a3f227 | 225 | |
9cbee2ce | 226 | wxObject* GetUserData() const |
df5ddbca | 227 | { return m_userData; } |
9cbee2ce | 228 | wxPoint GetPosition() const |
df5ddbca | 229 | { return m_pos; } |
0c0d686f | 230 | |
c62ac5b6 | 231 | protected: |
5f813ad6 VZ |
232 | // common part of several ctors |
233 | void Init(); | |
234 | ||
235 | // common part of ctors taking wxSizerFlags | |
236 | void Init(const wxSizerFlags& flags); | |
237 | ||
238 | ||
df5ddbca RR |
239 | wxWindow *m_window; |
240 | wxSizer *m_sizer; | |
241 | wxSize m_size; | |
242 | wxPoint m_pos; | |
243 | wxSize m_minSize; | |
12a3f227 | 244 | int m_proportion; |
df5ddbca RR |
245 | int m_border; |
246 | int m_flag; | |
56eee37f | 247 | wxRect m_zoneRect; // Rectangle for window or item (not including borders) |
2b5f62a0 | 248 | |
e0d8fb45 | 249 | // If true, then this item is considered in the layout |
dc259b79 | 250 | // calculation. Otherwise, it is skipped over. |
2b5f62a0 | 251 | bool m_show; |
12a3f227 RL |
252 | |
253 | // Aspect ratio can always be calculated from m_size, | |
254 | // but this would cause precision loss when the window | |
255 | // is shrunk. It is safer to preserve the initial value. | |
df5ddbca | 256 | float m_ratio; |
2b5f62a0 | 257 | |
df5ddbca | 258 | wxObject *m_userData; |
2aab8f16 | 259 | |
9cbee2ce | 260 | private: |
4393b50c | 261 | DECLARE_CLASS(wxSizerItem) |
22f3361e | 262 | DECLARE_NO_COPY_CLASS(wxSizerItem) |
c62ac5b6 | 263 | }; |
5279a24d | 264 | |
12a3f227 RL |
265 | WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList ); |
266 | ||
5f813ad6 | 267 | |
5279a24d | 268 | //--------------------------------------------------------------------------- |
3417c2cd | 269 | // wxSizer |
5279a24d RR |
270 | //--------------------------------------------------------------------------- |
271 | ||
2aab8f16 | 272 | class WXDLLEXPORT wxSizer: public wxObject, public wxClientDataContainer |
5279a24d RR |
273 | { |
274 | public: | |
f6bcfd97 BP |
275 | wxSizer(); |
276 | ~wxSizer(); | |
277 | ||
436ae7cf VZ |
278 | // methods for adding elements to the sizer: there are Add/Insert/Prepend |
279 | // overloads for each of window/sizer/spacer/wxSizerItem | |
56eee37f WS |
280 | inline wxSizerItem* Add( wxWindow *window, |
281 | int proportion = 0, | |
282 | int flag = 0, | |
283 | int border = 0, | |
284 | wxObject* userData = NULL ); | |
285 | inline wxSizerItem* Add( wxSizer *sizer, | |
286 | int proportion = 0, | |
287 | int flag = 0, | |
288 | int border = 0, | |
289 | wxObject* userData = NULL ); | |
290 | inline wxSizerItem* Add( int width, | |
291 | int height, | |
292 | int proportion = 0, | |
293 | int flag = 0, | |
294 | int border = 0, | |
295 | wxObject* userData = NULL ); | |
296 | inline wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags ); | |
297 | inline wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags ); | |
298 | inline wxSizerItem* Add( wxSizerItem *item ); | |
299 | ||
300 | inline wxSizerItem* AddSpacer(int size); | |
301 | inline wxSizerItem* AddStretchSpacer(int prop = 1); | |
302 | ||
303 | inline wxSizerItem* Insert( size_t index, | |
304 | wxWindow *window, | |
305 | int proportion = 0, | |
306 | int flag = 0, | |
307 | int border = 0, | |
308 | wxObject* userData = NULL ); | |
309 | inline wxSizerItem* Insert( size_t index, | |
310 | wxSizer *sizer, | |
311 | int proportion = 0, | |
312 | int flag = 0, | |
313 | int border = 0, | |
314 | wxObject* userData = NULL ); | |
315 | inline wxSizerItem* Insert( size_t index, | |
316 | int width, | |
317 | int height, | |
318 | int proportion = 0, | |
319 | int flag = 0, | |
320 | int border = 0, | |
321 | wxObject* userData = NULL ); | |
322 | inline wxSizerItem* Insert( size_t index, | |
323 | wxWindow *window, | |
324 | const wxSizerFlags& flags ); | |
325 | inline wxSizerItem* Insert( size_t index, | |
326 | wxSizer *sizer, | |
327 | const wxSizerFlags& flags ); | |
328 | virtual wxSizerItem* Insert( size_t index, wxSizerItem *item ); | |
329 | ||
330 | inline wxSizerItem* InsertSpacer(size_t index, int size); | |
331 | inline wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1); | |
332 | ||
333 | inline wxSizerItem* Prepend( wxWindow *window, | |
334 | int proportion = 0, | |
335 | int flag = 0, | |
336 | int border = 0, | |
337 | wxObject* userData = NULL ); | |
338 | inline wxSizerItem* Prepend( wxSizer *sizer, | |
339 | int proportion = 0, | |
340 | int flag = 0, | |
341 | int border = 0, | |
342 | wxObject* userData = NULL ); | |
343 | inline wxSizerItem* Prepend( int width, | |
344 | int height, | |
345 | int proportion = 0, | |
346 | int flag = 0, | |
347 | int border = 0, | |
348 | wxObject* userData = NULL ); | |
349 | inline wxSizerItem* Prepend( wxWindow *window, const wxSizerFlags& flags ); | |
350 | inline wxSizerItem* Prepend( wxSizer *sizer, const wxSizerFlags& flags ); | |
351 | inline wxSizerItem* Prepend( wxSizerItem *item ); | |
352 | ||
353 | inline wxSizerItem* PrependSpacer(int size); | |
354 | inline wxSizerItem* PrependStretchSpacer(int prop = 1); | |
8e32ea1c | 355 | |
749bb9f1 | 356 | |
12a3f227 RL |
357 | // Deprecated in 2.6 since historically it does not delete the window, |
358 | // use Detach instead. | |
359 | wxDEPRECATED( virtual bool Remove( wxWindow *window ) ); | |
f6bcfd97 | 360 | virtual bool Remove( wxSizer *sizer ); |
e0d8fb45 | 361 | virtual bool Remove( int index ); |
00976fe5 | 362 | |
12a3f227 | 363 | virtual bool Detach( wxWindow *window ); |
00976fe5 | 364 | virtual bool Detach( wxSizer *sizer ); |
e0d8fb45 | 365 | virtual bool Detach( int index ); |
00976fe5 | 366 | |
e0d8fb45 | 367 | virtual void Clear( bool delete_windows = false ); |
84f7908b | 368 | virtual void DeleteWindows(); |
f6bcfd97 BP |
369 | |
370 | void SetMinSize( int width, int height ) | |
371 | { DoSetMinSize( width, height ); } | |
372 | void SetMinSize( wxSize size ) | |
373 | { DoSetMinSize( size.x, size.y ); } | |
1e6feb95 | 374 | |
f6bcfd97 BP |
375 | /* Searches recursively */ |
376 | bool SetItemMinSize( wxWindow *window, int width, int height ) | |
377 | { return DoSetItemMinSize( window, width, height ); } | |
378 | bool SetItemMinSize( wxWindow *window, wxSize size ) | |
379 | { return DoSetItemMinSize( window, size.x, size.y ); } | |
1e6feb95 | 380 | |
f6bcfd97 BP |
381 | /* Searches recursively */ |
382 | bool SetItemMinSize( wxSizer *sizer, int width, int height ) | |
383 | { return DoSetItemMinSize( sizer, width, height ); } | |
384 | bool SetItemMinSize( wxSizer *sizer, wxSize size ) | |
385 | { return DoSetItemMinSize( sizer, size.x, size.y ); } | |
1e6feb95 | 386 | |
12a3f227 RL |
387 | bool SetItemMinSize( size_t index, int width, int height ) |
388 | { return DoSetItemMinSize( index, width, height ); } | |
389 | bool SetItemMinSize( size_t index, wxSize size ) | |
390 | { return DoSetItemMinSize( index, size.x, size.y ); } | |
1e6feb95 | 391 | |
9cbee2ce | 392 | wxSize GetSize() const |
f6bcfd97 | 393 | { return m_size; } |
9cbee2ce | 394 | wxPoint GetPosition() const |
f6bcfd97 | 395 | { return m_position; } |
1e6feb95 | 396 | |
f6bcfd97 BP |
397 | /* Calculate the minimal size or return m_minSize if bigger. */ |
398 | wxSize GetMinSize(); | |
399 | ||
400 | virtual void RecalcSizes() = 0; | |
401 | virtual wxSize CalcMin() = 0; | |
402 | ||
403 | virtual void Layout(); | |
404 | ||
e5251d4f | 405 | wxSize Fit( wxWindow *window ); |
566d84a7 | 406 | void FitInside( wxWindow *window ); |
f6bcfd97 | 407 | void SetSizeHints( wxWindow *window ); |
566d84a7 | 408 | void SetVirtualSizeHints( wxWindow *window ); |
f6bcfd97 | 409 | |
12a3f227 | 410 | wxSizerItemList& GetChildren() |
f6bcfd97 BP |
411 | { return m_children; } |
412 | ||
413 | void SetDimension( int x, int y, int width, int height ); | |
0c0d686f | 414 | |
9f13661f WS |
415 | wxSizerItem* GetItem( wxWindow *window, bool recursive = false ); |
416 | wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false ); | |
417 | wxSizerItem* GetItem( size_t index ); | |
418 | ||
12a3f227 | 419 | // Manage whether individual scene items are considered |
2b5f62a0 | 420 | // in the layout calculations or not. |
8b2bac62 WS |
421 | bool Show( wxWindow *window, bool show = true, bool recursive = false ); |
422 | bool Show( wxSizer *sizer, bool show = true, bool recursive = false ); | |
423 | bool Show( size_t index, bool show = true ); | |
12a3f227 | 424 | |
8b2bac62 WS |
425 | bool Hide( wxSizer *sizer, bool recursive = false ) |
426 | { return Show( sizer, false, recursive ); } | |
427 | bool Hide( wxWindow *window, bool recursive = false ) | |
428 | { return Show( window, false, recursive ); } | |
429 | bool Hide( size_t index ) | |
430 | { return Show( index, false ); } | |
2b5f62a0 | 431 | |
9cbee2ce RL |
432 | bool IsShown( wxWindow *window ) const; |
433 | bool IsShown( wxSizer *sizer ) const; | |
434 | bool IsShown( size_t index ) const; | |
dc259b79 | 435 | |
2b5f62a0 | 436 | // Recursively call wxWindow::Show () on all sizer items. |
eb2a7883 | 437 | virtual void ShowItems (bool show); |
2b5f62a0 | 438 | |
f6bcfd97 | 439 | protected: |
12a3f227 RL |
440 | wxSize m_size; |
441 | wxSize m_minSize; | |
442 | wxPoint m_position; | |
443 | wxSizerItemList m_children; | |
f6bcfd97 | 444 | |
9cbee2ce | 445 | wxSize GetMaxWindowSize( wxWindow *window ) const; |
f6bcfd97 | 446 | wxSize GetMinWindowSize( wxWindow *window ); |
9cbee2ce | 447 | wxSize GetMaxClientSize( wxWindow *window ) const; |
566d84a7 | 448 | wxSize GetMinClientSize( wxWindow *window ); |
65ba4113 | 449 | wxSize FitSize( wxWindow *window ); |
566d84a7 | 450 | wxSize VirtualFitSize( wxWindow *window ); |
65ba4113 | 451 | |
f6bcfd97 BP |
452 | virtual void DoSetMinSize( int width, int height ); |
453 | virtual bool DoSetItemMinSize( wxWindow *window, int width, int height ); | |
454 | virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height ); | |
12a3f227 | 455 | virtual bool DoSetItemMinSize( size_t index, int width, int height ); |
1e6feb95 | 456 | |
9cbee2ce | 457 | private: |
4393b50c | 458 | DECLARE_CLASS(wxSizer) |
f6bcfd97 | 459 | }; |
c62ac5b6 | 460 | |
f6bcfd97 BP |
461 | //--------------------------------------------------------------------------- |
462 | // wxGridSizer | |
463 | //--------------------------------------------------------------------------- | |
0c0d686f | 464 | |
f6bcfd97 BP |
465 | class WXDLLEXPORT wxGridSizer: public wxSizer |
466 | { | |
467 | public: | |
468 | wxGridSizer( int rows, int cols, int vgap, int hgap ); | |
469 | wxGridSizer( int cols, int vgap = 0, int hgap = 0 ); | |
1e6feb95 | 470 | |
5d76f462 VZ |
471 | virtual void RecalcSizes(); |
472 | virtual wxSize CalcMin(); | |
f6bcfd97 BP |
473 | |
474 | void SetCols( int cols ) { m_cols = cols; } | |
475 | void SetRows( int rows ) { m_rows = rows; } | |
476 | void SetVGap( int gap ) { m_vgap = gap; } | |
477 | void SetHGap( int gap ) { m_hgap = gap; } | |
9cbee2ce RL |
478 | int GetCols() const { return m_cols; } |
479 | int GetRows() const { return m_rows; } | |
480 | int GetVGap() const { return m_vgap; } | |
481 | int GetHGap() const { return m_hgap; } | |
1e6feb95 | 482 | |
f6bcfd97 BP |
483 | protected: |
484 | int m_rows; | |
485 | int m_cols; | |
486 | int m_vgap; | |
487 | int m_hgap; | |
1e6feb95 | 488 | |
0ca5105b VZ |
489 | // return the number of total items and the number of columns and rows |
490 | int CalcRowsCols(int& rows, int& cols) const; | |
491 | ||
f6bcfd97 | 492 | void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ); |
1e6feb95 | 493 | |
9cbee2ce | 494 | private: |
4393b50c | 495 | DECLARE_CLASS(wxGridSizer) |
f6bcfd97 | 496 | }; |
5279a24d | 497 | |
f6bcfd97 BP |
498 | //--------------------------------------------------------------------------- |
499 | // wxFlexGridSizer | |
500 | //--------------------------------------------------------------------------- | |
0c0d686f | 501 | |
5d76f462 VZ |
502 | // the bevaiour for resizing wxFlexGridSizer cells in the "non-flexible" |
503 | // direction | |
504 | enum wxFlexSizerGrowMode | |
505 | { | |
506 | // don't resize the cells in non-flexible direction at all | |
507 | wxFLEX_GROWMODE_NONE, | |
508 | ||
509 | // uniformly resize only the specified ones (default) | |
510 | wxFLEX_GROWMODE_SPECIFIED, | |
511 | ||
512 | // uniformly resize all cells | |
513 | wxFLEX_GROWMODE_ALL | |
514 | }; | |
515 | ||
f6bcfd97 BP |
516 | class WXDLLEXPORT wxFlexGridSizer: public wxGridSizer |
517 | { | |
518 | public: | |
5d76f462 | 519 | // ctors/dtor |
f6bcfd97 BP |
520 | wxFlexGridSizer( int rows, int cols, int vgap, int hgap ); |
521 | wxFlexGridSizer( int cols, int vgap = 0, int hgap = 0 ); | |
5d76f462 | 522 | virtual ~wxFlexGridSizer(); |
1e6feb95 | 523 | |
1e6feb95 | 524 | |
5d76f462 VZ |
525 | // set the rows/columns which will grow (the others will remain of the |
526 | // constant initial size) | |
e8800dcf | 527 | void AddGrowableRow( size_t idx, int proportion = 0 ); |
f6bcfd97 | 528 | void RemoveGrowableRow( size_t idx ); |
e8800dcf | 529 | void AddGrowableCol( size_t idx, int proportion = 0 ); |
f6bcfd97 | 530 | void RemoveGrowableCol( size_t idx ); |
0c0d686f | 531 | |
1e6feb95 | 532 | |
5d76f462 VZ |
533 | // the sizer cells may grow in both directions, not grow at all or only |
534 | // grow in one direction but not the other | |
535 | ||
536 | // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default) | |
537 | void SetFlexibleDirection(int direction) { m_flexDirection = direction; } | |
538 | int GetFlexibleDirection() const { return m_flexDirection; } | |
539 | ||
540 | // note that the grow mode only applies to the direction which is not | |
541 | // flexible | |
542 | void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode) { m_growMode = mode; } | |
543 | wxFlexSizerGrowMode GetNonFlexibleGrowMode() const { return m_growMode; } | |
544 | ||
fc1fcd0e RD |
545 | // Read-only access to the row heights and col widths arrays |
546 | const wxArrayInt& GetRowHeights() const { return m_rowHeights; } | |
547 | const wxArrayInt& GetColWidths() const { return m_colWidths; } | |
8b2bac62 | 548 | |
5d76f462 VZ |
549 | // implementation |
550 | virtual void RecalcSizes(); | |
551 | virtual wxSize CalcMin(); | |
552 | ||
553 | protected: | |
20b35a69 RD |
554 | void AdjustForFlexDirection(); |
555 | void AdjustForGrowables(const wxSize& sz, const wxSize& minsz, | |
556 | int nrows, int ncols); | |
8b2bac62 | 557 | |
5d76f462 VZ |
558 | // the heights/widths of all rows/columns |
559 | wxArrayInt m_rowHeights, | |
560 | m_colWidths; | |
561 | ||
562 | // indices of the growable columns and rows | |
563 | wxArrayInt m_growableRows, | |
564 | m_growableCols; | |
565 | ||
e8800dcf VZ |
566 | // proportion values of the corresponding growable rows and columns |
567 | wxArrayInt m_growableRowsProportions, | |
568 | m_growableColsProportions; | |
569 | ||
5d76f462 VZ |
570 | // parameters describing whether the growable cells should be resized in |
571 | // both directions or only one | |
572 | int m_flexDirection; | |
573 | wxFlexSizerGrowMode m_growMode; | |
1e6feb95 | 574 | |
ba763a45 RD |
575 | // saves CalcMin result to optimize RecalcSizes |
576 | wxSize m_calculatedMinSize; | |
577 | ||
9cbee2ce | 578 | private: |
4393b50c | 579 | DECLARE_CLASS(wxFlexGridSizer) |
22f3361e | 580 | DECLARE_NO_COPY_CLASS(wxFlexGridSizer) |
c62ac5b6 RR |
581 | }; |
582 | ||
583 | //--------------------------------------------------------------------------- | |
92afa2b1 | 584 | // wxBoxSizer |
c62ac5b6 RR |
585 | //--------------------------------------------------------------------------- |
586 | ||
92afa2b1 | 587 | class WXDLLEXPORT wxBoxSizer: public wxSizer |
61d514bb RR |
588 | { |
589 | public: | |
f6bcfd97 | 590 | wxBoxSizer( int orient ); |
0c0d686f | 591 | |
f6bcfd97 BP |
592 | void RecalcSizes(); |
593 | wxSize CalcMin(); | |
0c0d686f | 594 | |
9cbee2ce | 595 | int GetOrientation() const |
f6bcfd97 | 596 | { return m_orient; } |
0c0d686f | 597 | |
b657b4c9 JS |
598 | void SetOrientation(int orient) |
599 | { m_orient = orient; } | |
600 | ||
61d514bb RR |
601 | protected: |
602 | int m_orient; | |
603 | int m_stretchable; | |
604 | int m_minWidth; | |
605 | int m_minHeight; | |
606 | int m_fixedWidth; | |
607 | int m_fixedHeight; | |
1e6feb95 | 608 | |
9cbee2ce | 609 | private: |
4393b50c | 610 | DECLARE_CLASS(wxBoxSizer) |
61d514bb | 611 | }; |
0c0d686f | 612 | |
27ea1d8a RR |
613 | //--------------------------------------------------------------------------- |
614 | // wxStaticBoxSizer | |
615 | //--------------------------------------------------------------------------- | |
616 | ||
1e6feb95 VZ |
617 | #if wxUSE_STATBOX |
618 | ||
619 | class WXDLLEXPORT wxStaticBox; | |
620 | ||
27ea1d8a RR |
621 | class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer |
622 | { | |
623 | public: | |
6c1635b5 | 624 | wxStaticBoxSizer(wxStaticBox *box, int orient); |
450a1593 | 625 | wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString); |
0c0d686f | 626 | |
f6bcfd97 BP |
627 | void RecalcSizes(); |
628 | wxSize CalcMin(); | |
0c0d686f | 629 | |
9cbee2ce | 630 | wxStaticBox *GetStaticBox() const |
f6bcfd97 | 631 | { return m_staticBox; } |
0c0d686f | 632 | |
eb2a7883 VZ |
633 | // override to hide/show the static box as well |
634 | virtual void ShowItems (bool show); | |
635 | ||
27ea1d8a | 636 | protected: |
f6bcfd97 | 637 | wxStaticBox *m_staticBox; |
1e6feb95 | 638 | |
9cbee2ce | 639 | private: |
4393b50c | 640 | DECLARE_CLASS(wxStaticBoxSizer) |
22f3361e | 641 | DECLARE_NO_COPY_CLASS(wxStaticBoxSizer) |
27ea1d8a RR |
642 | }; |
643 | ||
1e6feb95 VZ |
644 | #endif // wxUSE_STATBOX |
645 | ||
974c2a59 WS |
646 | #if wxUSE_BUTTON |
647 | ||
acf2ac37 RR |
648 | class WXDLLEXPORT wxStdDialogButtonSizer: public wxBoxSizer |
649 | { | |
650 | public: | |
acf2ac37 RR |
651 | // Constructor just creates a new wxBoxSizer, not much else. |
652 | // Box sizer orientation is automatically determined here: | |
653 | // vertical for PDAs, horizontal for everything else? | |
b181a505 | 654 | wxStdDialogButtonSizer(); |
acf2ac37 | 655 | |
acf2ac37 | 656 | // Checks button ID against system IDs and sets one of the pointers below |
b181a505 RR |
657 | // to this button. Does not do any sizer-related things here. |
658 | void AddButton(wxButton *button); | |
acf2ac37 | 659 | |
b181a505 RR |
660 | // Use these if no standard ID can/should be used |
661 | void SetAffirmativeButton( wxButton *button ); | |
662 | void SetNegativeButton( wxButton *button ); | |
663 | void SetCancelButton( wxButton *button ); | |
acf2ac37 | 664 | |
acf2ac37 RR |
665 | // All platform-specific code here, checks which buttons exist and add |
666 | // them to the sizer accordingly. | |
667 | // Note - one potential hack on Mac we could use here, | |
668 | // if m_buttonAffirmative is wxID_SAVE then ensure wxID_SAVE | |
669 | // is set to _("Save") and m_buttonNegative is set to _("Don't Save") | |
670 | // I wouldn't add any other hacks like that into here, | |
671 | // but this one I can see being useful. | |
718903fe | 672 | void Realize(); |
974c2a59 | 673 | |
acf2ac37 RR |
674 | wxButton *GetAffirmativeButton() const { return m_buttonAffirmative; } |
675 | wxButton *GetApplyButton() const { return m_buttonApply; } | |
676 | wxButton *GetNegativeButton() const { return m_buttonNegative; } | |
677 | wxButton *GetCancelButton() const { return m_buttonCancel; } | |
678 | wxButton *GetHelpButton() const { return m_buttonHelp; } | |
679 | ||
680 | protected: | |
b181a505 | 681 | wxButton *m_buttonAffirmative; // wxID_OK, wxID_YES, wxID_SAVE go here |
acf2ac37 | 682 | wxButton *m_buttonApply; |
b181a505 | 683 | wxButton *m_buttonNegative; // wxID_NO |
acf2ac37 RR |
684 | wxButton *m_buttonCancel; |
685 | wxButton *m_buttonHelp; | |
974c2a59 | 686 | |
acf2ac37 RR |
687 | private: |
688 | DECLARE_CLASS(wxStdDialogButtonSizer) | |
b181a505 | 689 | DECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer) |
acf2ac37 | 690 | }; |
adbf2d73 | 691 | |
6b5c4761 | 692 | #endif // wxUSE_BUTTON |
974c2a59 | 693 | |
adbf2d73 VS |
694 | #if WXWIN_COMPATIBILITY_2_4 |
695 | // NB: wxBookCtrlSizer and wxNotebookSizer are deprecated, they | |
61c083e7 | 696 | // don't do anything. wxBookCtrlBase::DoGetBestSize does the job now. |
adbf2d73 | 697 | |
ade4eb65 VZ |
698 | // ---------------------------------------------------------------------------- |
699 | // wxBookCtrlSizer | |
700 | // ---------------------------------------------------------------------------- | |
83edc0a5 | 701 | |
ade4eb65 | 702 | #if wxUSE_BOOKCTRL |
65e4f9b9 | 703 | |
8e32ea1c | 704 | // this sizer works with wxNotebook/wxListbook/... and sizes the control to |
ade4eb65 | 705 | // fit its pages |
61c083e7 | 706 | class WXDLLEXPORT wxBookCtrlBase; |
1e6feb95 | 707 | |
ade4eb65 | 708 | class WXDLLEXPORT wxBookCtrlSizer : public wxSizer |
83edc0a5 | 709 | { |
83edc0a5 | 710 | public: |
61c083e7 | 711 | wxDEPRECATED( wxBookCtrlSizer(wxBookCtrlBase *bookctrl) ); |
83edc0a5 | 712 | |
61c083e7 | 713 | wxBookCtrlBase *GetControl() const { return m_bookctrl; } |
8b2bac62 | 714 | |
ade4eb65 VZ |
715 | virtual void RecalcSizes(); |
716 | virtual wxSize CalcMin(); | |
83edc0a5 | 717 | |
83edc0a5 | 718 | protected: |
adbf2d73 | 719 | // this protected ctor lets us mark the real one above as deprecated |
749bb9f1 | 720 | // and still have warning-free build of the library itself: |
adbf2d73 | 721 | wxBookCtrlSizer() {} |
8b2bac62 | 722 | |
61c083e7 | 723 | wxBookCtrlBase *m_bookctrl; |
ade4eb65 VZ |
724 | |
725 | private: | |
726 | DECLARE_CLASS(wxBookCtrlSizer) | |
727 | DECLARE_NO_COPY_CLASS(wxBookCtrlSizer) | |
728 | }; | |
729 | ||
730 | ||
731 | #if wxUSE_NOTEBOOK | |
732 | ||
61c083e7 | 733 | // before wxBookCtrlBase we only had wxNotebookSizer, keep it for backwards |
ade4eb65 VZ |
734 | // compatibility |
735 | class WXDLLEXPORT wxNotebook; | |
736 | ||
737 | class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer | |
738 | { | |
739 | public: | |
adbf2d73 | 740 | wxDEPRECATED( wxNotebookSizer(wxNotebook *nb) ); |
ade4eb65 VZ |
741 | |
742 | wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; } | |
1e6feb95 | 743 | |
9cbee2ce | 744 | private: |
4393b50c | 745 | DECLARE_CLASS(wxNotebookSizer) |
22f3361e | 746 | DECLARE_NO_COPY_CLASS(wxNotebookSizer) |
83edc0a5 RR |
747 | }; |
748 | ||
1e6feb95 | 749 | #endif // wxUSE_NOTEBOOK |
65e4f9b9 | 750 | |
ade4eb65 VZ |
751 | #endif // wxUSE_BOOKCTRL |
752 | ||
adbf2d73 VS |
753 | #endif // WXWIN_COMPATIBILITY_2_4 |
754 | ||
8e32ea1c VZ |
755 | // ---------------------------------------------------------------------------- |
756 | // inline functions implementation | |
757 | // ---------------------------------------------------------------------------- | |
758 | ||
56eee37f | 759 | inline wxSizerItem* |
8e32ea1c VZ |
760 | wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) |
761 | { | |
56eee37f | 762 | return Add( new wxSizerItem( window, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
763 | } |
764 | ||
56eee37f | 765 | inline wxSizerItem* |
8e32ea1c VZ |
766 | wxSizer::Add( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData ) |
767 | { | |
56eee37f | 768 | return Add( new wxSizerItem( sizer, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
769 | } |
770 | ||
56eee37f | 771 | inline wxSizerItem* |
8e32ea1c VZ |
772 | wxSizer::Add( int width, int height, int proportion, int flag, int border, wxObject* userData ) |
773 | { | |
56eee37f | 774 | return Add( new wxSizerItem( width, height, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
775 | } |
776 | ||
56eee37f | 777 | inline wxSizerItem* |
5f813ad6 VZ |
778 | wxSizer::Add( wxWindow *window, const wxSizerFlags& flags ) |
779 | { | |
56eee37f | 780 | return Add( new wxSizerItem(window, flags) ); |
5f813ad6 VZ |
781 | } |
782 | ||
56eee37f | 783 | inline wxSizerItem* |
5f813ad6 VZ |
784 | wxSizer::Add( wxSizer *sizer, const wxSizerFlags& flags ) |
785 | { | |
56eee37f | 786 | return Add( new wxSizerItem(sizer, flags) ); |
5f813ad6 VZ |
787 | } |
788 | ||
56eee37f | 789 | inline wxSizerItem* |
8e32ea1c VZ |
790 | wxSizer::Add( wxSizerItem *item ) |
791 | { | |
56eee37f | 792 | return Insert( m_children.GetCount(), item ); |
8e32ea1c VZ |
793 | } |
794 | ||
56eee37f | 795 | inline wxSizerItem* |
8e32ea1c VZ |
796 | wxSizer::AddSpacer(int size) |
797 | { | |
56eee37f | 798 | return Add(size, size); |
8e32ea1c VZ |
799 | } |
800 | ||
56eee37f | 801 | inline wxSizerItem* |
8e32ea1c VZ |
802 | wxSizer::AddStretchSpacer(int prop) |
803 | { | |
56eee37f | 804 | return Add(0, 0, prop); |
8e32ea1c VZ |
805 | } |
806 | ||
56eee37f | 807 | inline wxSizerItem* |
8e32ea1c VZ |
808 | wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) |
809 | { | |
56eee37f | 810 | return Prepend( new wxSizerItem( window, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
811 | } |
812 | ||
56eee37f | 813 | inline wxSizerItem* |
8e32ea1c VZ |
814 | wxSizer::Prepend( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData ) |
815 | { | |
56eee37f | 816 | return Prepend( new wxSizerItem( sizer, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
817 | } |
818 | ||
56eee37f | 819 | inline wxSizerItem* |
8e32ea1c VZ |
820 | wxSizer::Prepend( int width, int height, int proportion, int flag, int border, wxObject* userData ) |
821 | { | |
56eee37f | 822 | return Prepend( new wxSizerItem( width, height, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
823 | } |
824 | ||
56eee37f | 825 | inline wxSizerItem* |
8e32ea1c VZ |
826 | wxSizer::Prepend( wxSizerItem *item ) |
827 | { | |
56eee37f | 828 | return Insert( 0, item ); |
8e32ea1c VZ |
829 | } |
830 | ||
56eee37f | 831 | inline wxSizerItem* |
8e32ea1c VZ |
832 | wxSizer::PrependSpacer(int size) |
833 | { | |
56eee37f | 834 | return Prepend(size, size); |
8e32ea1c VZ |
835 | } |
836 | ||
56eee37f | 837 | inline wxSizerItem* |
8e32ea1c VZ |
838 | wxSizer::PrependStretchSpacer(int prop) |
839 | { | |
56eee37f | 840 | return Prepend(0, 0, prop); |
8e32ea1c VZ |
841 | } |
842 | ||
56eee37f | 843 | inline wxSizerItem* |
5f813ad6 VZ |
844 | wxSizer::Prepend( wxWindow *window, const wxSizerFlags& flags ) |
845 | { | |
56eee37f | 846 | return Prepend( new wxSizerItem(window, flags) ); |
5f813ad6 VZ |
847 | } |
848 | ||
56eee37f | 849 | inline wxSizerItem* |
5f813ad6 VZ |
850 | wxSizer::Prepend( wxSizer *sizer, const wxSizerFlags& flags ) |
851 | { | |
56eee37f | 852 | return Prepend( new wxSizerItem(sizer, flags) ); |
5f813ad6 VZ |
853 | } |
854 | ||
56eee37f | 855 | inline wxSizerItem* |
8e32ea1c | 856 | wxSizer::Insert( size_t index, |
5f813ad6 VZ |
857 | wxWindow *window, |
858 | int proportion, | |
859 | int flag, | |
860 | int border, | |
861 | wxObject* userData ) | |
8e32ea1c | 862 | { |
56eee37f | 863 | return Insert( index, new wxSizerItem( window, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
864 | } |
865 | ||
56eee37f | 866 | inline wxSizerItem* |
8e32ea1c | 867 | wxSizer::Insert( size_t index, |
5f813ad6 VZ |
868 | wxSizer *sizer, |
869 | int proportion, | |
870 | int flag, | |
871 | int border, | |
872 | wxObject* userData ) | |
8e32ea1c | 873 | { |
56eee37f | 874 | return Insert( index, new wxSizerItem( sizer, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
875 | } |
876 | ||
56eee37f | 877 | inline wxSizerItem* |
8e32ea1c | 878 | wxSizer::Insert( size_t index, |
5f813ad6 VZ |
879 | int width, |
880 | int height, | |
881 | int proportion, | |
882 | int flag, | |
883 | int border, | |
884 | wxObject* userData ) | |
8e32ea1c | 885 | { |
56eee37f | 886 | return Insert( index, new wxSizerItem( width, height, proportion, flag, border, userData ) ); |
8e32ea1c VZ |
887 | } |
888 | ||
56eee37f | 889 | inline wxSizerItem* |
5f813ad6 VZ |
890 | wxSizer::Insert( size_t index, wxWindow *window, const wxSizerFlags& flags ) |
891 | { | |
56eee37f | 892 | return Insert( index, new wxSizerItem(window, flags) ); |
5f813ad6 VZ |
893 | } |
894 | ||
56eee37f | 895 | inline wxSizerItem* |
5f813ad6 VZ |
896 | wxSizer::Insert( size_t index, wxSizer *sizer, const wxSizerFlags& flags ) |
897 | { | |
56eee37f | 898 | return Insert( index, new wxSizerItem(sizer, flags) ); |
5f813ad6 VZ |
899 | } |
900 | ||
56eee37f | 901 | inline wxSizerItem* |
8e32ea1c VZ |
902 | wxSizer::InsertSpacer(size_t index, int size) |
903 | { | |
56eee37f | 904 | return Insert(index, size, size); |
8e32ea1c VZ |
905 | } |
906 | ||
56eee37f | 907 | inline wxSizerItem* |
8e32ea1c VZ |
908 | wxSizer::InsertStretchSpacer(size_t index, int prop) |
909 | { | |
56eee37f | 910 | return Insert(index, 0, 0, prop); |
8e32ea1c VZ |
911 | } |
912 | ||
adbf2d73 | 913 | |
ade4eb65 | 914 | #endif // __WXSIZER_H__ |
65e4f9b9 | 915 |