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