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