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