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