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