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