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