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