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