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