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