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