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