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