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