]> git.saurik.com Git - wxWidgets.git/blob - interface/sizer.h
e86108c8cef4c9d0a43c2bb6fbafe9711e3ed97f
[wxWidgets.git] / interface / sizer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: sizer.h
3 // Purpose: interface of wxStdDialogButtonSizer
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxStdDialogButtonSizer
11 @wxheader{sizer.h}
12
13 This class creates button layouts which conform to the standard button spacing
14 and ordering defined by the platform
15 or toolkit's user interface guidelines (if such things exist). By using this
16 class, you can ensure that all your
17 standard dialogs look correct on all major platforms. Currently it conforms to
18 the Windows, GTK+ and Mac OS X
19 human interface guidelines.
20
21 When there aren't interface guidelines defined for a particular platform or
22 toolkit, wxStdDialogButtonSizer reverts
23 to the Windows implementation.
24
25 To use this class, first add buttons to the sizer by calling AddButton (or
26 SetAffirmativeButton, SetNegativeButton,
27 or SetCancelButton) and then call Realize in order to create the actual button
28 layout used. Other than these special
29 operations, this sizer works like any other sizer.
30
31 If you add a button with wxID_SAVE, on Mac OS X the button will be renamed to
32 "Save" and
33 the wxID_NO button will be renamed to "Don't Save" in accordance with the Mac
34 OS X Human Interface Guidelines.
35
36 @library{wxcore}
37 @category{FIXME}
38
39 @see wxSizer, @ref overview_sizeroverview "Sizer overview",
40 wxDialog::CreateButtonSizer
41 */
42 class wxStdDialogButtonSizer : public wxBoxSizer
43 {
44 public:
45 /**
46 Constructor for a wxStdDialogButtonSizer.
47 */
48 wxStdDialogButtonSizer();
49
50 /**
51 Adds a button to the wxStdDialogButtonSizer. The button must have one of the
52 following identifiers:
53 wxID_OK
54 wxID_YES
55 wxID_SAVE
56 wxID_APPLY
57 wxID_CLOSE
58 wxID_NO
59 wxID_CANCEL
60 wxID_HELP
61 wxID_CONTEXT_HELP
62 */
63 void AddButton(wxButton* button);
64
65 /**
66 Rearranges the buttons and applies proper spacing between buttons to make them
67 match the platform or toolkit's interface guidelines.
68 */
69 void Realize();
70
71 /**
72 Sets the affirmative button for the sizer. This allows you to use identifiers
73 other than the standard identifiers outlined above.
74 */
75 void SetAffirmativeButton(wxButton* button);
76
77 /**
78 Sets the cancel button for the sizer. This allows you to use identifiers other
79 than the standard identifiers outlined above.
80 */
81 void SetCancelButton(wxButton* button);
82
83 /**
84 Sets the negative button for the sizer. This allows you to use identifiers
85 other than the standard identifiers outlined above.
86 */
87 void SetNegativeButton(wxButton* button);
88 };
89
90
91
92 /**
93 @class wxSizerItem
94 @wxheader{sizer.h}
95
96 The wxSizerItem class is used to track the position, size and other
97 attributes of each item managed by a wxSizer. It is not usually necessary
98 to use this class because the sizer elements can also be identified by
99 their positions or window or sizer pointers but sometimes it may be more
100 convenient to use it directly.
101
102 @library{wxcore}
103 @category{winlayout}
104 */
105 class wxSizerItem : public wxObject
106 {
107 public:
108 //@{
109 /**
110 Construct a sizer item for tracking a subsizer.
111 */
112 wxSizerItem(int width, int height, int proportion, int flag,
113 int border, wxObject* userData);
114 wxSizerItem(wxWindow* window, const wxSizerFlags& flags);
115 wxSizerItem(wxWindow* window, int proportion, int flag,
116 int border,
117 wxObject* userData);
118 wxSizerItem(wxSizer* window, const wxSizerFlags& flags);
119 wxSizerItem(wxSizer* sizer, int proportion, int flag,
120 int border,
121 wxObject* userData);
122 //@}
123
124 /**
125 Deletes the user data and subsizer, if any.
126 */
127 ~wxSizerItem();
128
129 /**
130 Calculates the minimum desired size for the item, including any space
131 needed by borders.
132 */
133 wxSize CalcMin();
134
135 /**
136 Destroy the window or the windows in a subsizer, depending on the type
137 of item.
138 */
139 void DeleteWindows();
140
141 /**
142 Enable deleting the SizerItem without destroying the contained sizer.
143 */
144 void DetachSizer();
145
146 /**
147 Return the border attribute.
148 */
149 int GetBorder() const;
150
151 /**
152 Return the flags attribute.
153
154 See @ref wxsizer_flags "wxSizer flags list" for details.
155 */
156 int GetFlag() const;
157
158 /**
159 Return the numeric id of wxSizerItem, or @c wxID_NONE if the id has
160 not been set.
161 */
162 int GetId() const;
163
164 /**
165 Get the minimum size needed for the item.
166 */
167 wxSize GetMinSize() const;
168
169 /**
170 What is the current position of the item, as set in the last Layout.
171 */
172 wxPoint GetPosition() const;
173
174 /**
175 Get the proportion item attribute.
176 */
177 int GetProportion() const;
178
179 /**
180 Get the ration item attribute.
181 */
182 float GetRatio() const;
183
184 /**
185 Get the rectangle of the item on the parent window, excluding borders.
186 */
187 wxRect GetRect();
188
189 /**
190 Get the current size of the item, as set in the last Layout.
191 */
192 wxSize GetSize() const;
193
194 /**
195 If this item is tracking a sizer, return it. @NULL otherwise.
196 */
197 wxSizer* GetSizer() const;
198
199 /**
200 If this item is tracking a spacer, return its size.
201 */
202 const wxSize GetSpacer() const;
203
204 /**
205 Get the userData item attribute.
206 */
207 wxObject* GetUserData() const;
208
209 /**
210 If this item is tracking a window then return it. @NULL otherwise.
211 */
212 wxWindow* GetWindow() const;
213
214 /**
215 Returns @true if this item is a window or a spacer and it is shown or if this
216 item is a sizer and not all its elements are hidden. In other words, for sizer
217 items, all of the child elements must be hidden for the sizer itself to be
218 considered hidden.
219 */
220 bool IsShown() const;
221
222 /**
223 Is this item a sizer?
224 */
225 bool IsSizer() const;
226
227 /**
228 Is this item a spacer?
229 */
230 bool IsSpacer() const;
231
232 /**
233 Is this item a window?
234 */
235 bool IsWindow() const;
236
237 /**
238 Set the border item attribute.
239 */
240 void SetBorder(int border);
241
242 /**
243 Set the position and size of the space allocated to the sizer, and
244 adjust the position and size of the item to be within that space
245 taking alignment and borders into account.
246 */
247 void SetDimension(const wxPoint& pos, const wxSize& size);
248
249 /**
250 Set the flag item attribute.
251 */
252 void SetFlag(int flag);
253
254 /**
255 Sets the numeric id of the wxSizerItem to @e id.
256 */
257 void SetId(int id);
258
259 /**
260
261 */
262 void SetInitSize(int x, int y);
263
264 /**
265 Set the proportion item attribute.
266 */
267 void SetProportion(int proportion);
268
269 //@{
270 /**
271 Set the ratio item attribute.
272 */
273 void SetRatio(int width, int height);
274 void SetRatio(wxSize size);
275 void SetRatio(float ratio);
276 //@}
277
278 /**
279 Set the sizer tracked by this item.
280 */
281 void SetSizer(wxSizer* sizer);
282
283 /**
284 Set the size of the spacer tracked by this item.
285 */
286 void SetSpacer(const wxSize& size);
287
288 /**
289 Set the window to be tracked by thsi item.
290 */
291 void SetWindow(wxWindow* window);
292
293 /**
294 Set the show item attribute, which sizers use to determine if the item
295 is to be made part of the layout or not. If the item is tracking a
296 window then it is shown or hidden as needed.
297 */
298 void Show(bool show);
299 };
300
301
302
303 /**
304 @class wxSizerFlags
305 @wxheader{sizer.h}
306
307 Normally, when you add an item to a sizer via
308 wxSizer::Add, you have to specify a lot of flags and
309 parameters which can be unwieldy. This is where wxSizerFlags comes in: it
310 allows you to specify all parameters using the named methods instead. For
311 example, instead of
312
313 @code
314 sizer->Add(ctrl, 0, wxEXPAND | wxALL, 10);
315 @endcode
316
317 you can now write
318
319 @code
320 sizer->Add(ctrl, wxSizerFlags().Expand().Border(10));
321 @endcode
322
323 This is more readable and also allows you to create wxSizerFlags objects which
324 can be reused for several sizer items.
325
326 @code
327 wxSizerFlags flagsExpand(1);
328 flagsExpand.Expand().Border(10);
329
330 sizer->Add(ctrl1, flagsExpand);
331 sizer->Add(ctrl2, flagsExpand);
332 @endcode
333
334 Note that by specification, all methods of wxSizerFlags return the wxSizerFlags
335 object itself to allowing chaining multiple methods calls like in the examples
336 above.
337
338 @library{wxcore}
339 @category{winlayout}
340
341 @see wxSizer
342 */
343 class wxSizerFlags
344 {
345 public:
346 /**
347 Creates the wxSizer with the proportion specified by @e proportion.
348 */
349 wxSizerFlags(int proportion = 0);
350
351 /**
352 Sets the alignment of this wxSizerFlags to @e align.
353 Note that if this method is not called, the wxSizerFlags has no specified
354 alignment.
355
356 @see Top(), Left(), Right(),
357 Bottom(), Centre()
358 */
359 wxSizerFlags Align(int align = 0);
360
361 //@{
362 /**
363 Sets the wxSizerFlags to have a border of a number of pixels specified by
364 @a borderinpixels with the directions specified by @e direction.
365 In the overloaded version without @a borderinpixels parameter, the border of
366 default size, as returned by GetDefaultBorder(),
367 is used.
368 */
369 wxSizerFlags Border(int direction, int borderinpixels);
370 wxSizerFlags Border(int direction = wxALL);
371 //@}
372
373 /**
374 Aligns the object to the bottom, shortcut for @c Align(wxALIGN_BOTTOM)
375
376 @see Align()
377 */
378 wxSizerFlags Bottom();
379
380 /**
381 Sets the object of the wxSizerFlags to center itself in the area it is given.
382 */
383 wxSizerFlags Center();
384
385 /**
386 Center() for people with the other dialect of english.
387 */
388 wxSizerFlags Centre();
389
390 /**
391 Sets the border in the given @a direction having twice the default border
392 size.
393 */
394 wxSizerFlags DoubleBorder(int direction = wxALL);
395
396 /**
397 Sets the border in left and right directions having twice the default border
398 size.
399 */
400 wxSizerFlags DoubleHorzBorder();
401
402 /**
403 Sets the object of the wxSizerFlags to expand to fill as much area as it can.
404 */
405 wxSizerFlags Expand();
406
407 /**
408 Set the @c wxFIXED_MINSIZE flag which indicates that the initial size of
409 the window should be also set as its minimal size.
410 */
411 wxSizerFlags FixedMinSize();
412
413 /**
414 Returns the border used by default in Border() method.
415 */
416 static int GetDefaultBorder();
417
418 /**
419 Aligns the object to the left, shortcut for @c Align(wxALIGN_LEFT)
420
421 @see Align()
422 */
423 wxSizerFlags Left();
424
425 /**
426 Sets the proportion of this wxSizerFlags to @e proportion
427 */
428 wxSizerFlags Proportion(int proportion = 0);
429
430 /**
431 Aligns the object to the right, shortcut for @c Align(wxALIGN_RIGHT)
432
433 @see Align()
434 */
435 wxSizerFlags Right();
436
437 /**
438 Set the @c wx_SHAPED flag which indicates that the elements should
439 always keep the fixed width to height ratio equal to its original value.
440 */
441 wxSizerFlags Shaped();
442
443 /**
444 Aligns the object to the top, shortcut for @c Align(wxALIGN_TOP)
445
446 @see Align()
447 */
448 wxSizerFlags Top();
449
450 /**
451 Sets the border in the given @a direction having thrice the default border
452 size.
453 */
454 wxSizerFlags TripleBorder(int direction = wxALL);
455 };
456
457
458
459 /**
460 @class wxNotebookSizer
461 @wxheader{sizer.h}
462
463 @deprecated
464 This class is deprecated and should not be used in new code! It is no
465 longer needed, wxNotebook control can be inserted
466 into any sizer class and its minimal size will be determined correctly.
467
468 wxNotebookSizer is a specialized sizer to make sizers work in connection
469 with using notebooks. This sizer is different from any other sizer as you
470 must not add any children to it - instead, it queries the notebook class
471 itself. The only thing this sizer does is to determine the size of the
472 biggest page of the notebook and report an adjusted minimal size to a more
473 toplevel sizer.
474
475 @library{wxbase}
476 @category{winlayout}
477
478 @see wxSizer, wxNotebook,
479 @ref overview_sizer "Sizers overview"
480 */
481 class wxNotebookSizer : public wxSizer
482 {
483 public:
484 /**
485 Constructor. It takes an associated notebook as its only parameter.
486 */
487 wxNotebookSizer(wxNotebook* notebook);
488
489 /**
490 Returns the notebook associated with the sizer.
491 */
492 wxNotebook* GetNotebook();
493 };
494
495
496
497 /**
498 @class wxFlexGridSizer
499 @wxheader{sizer.h}
500
501 A flex grid sizer is a sizer which lays out its children in a two-dimensional
502 table with all table fields in one row having the same
503 height and all fields in one column having the same width, but all
504 rows or all columns are not necessarily the same height or width as in
505 the wxGridSizer.
506
507 Since wxWidgets 2.5.0, wxFlexGridSizer can also size items equally in one
508 direction but unequally ("flexibly") in the other. If the sizer is only
509 flexible in one direction (this can be changed using
510 wxFlexGridSizer::SetFlexibleDirection),
511 it needs to be decided how the sizer should grow in the other ("non-flexible")
512 direction in order to fill the available space. The
513 wxFlexGridSizer::SetNonFlexibleGrowMode method
514 serves this purpose.
515
516 @library{wxcore}
517 @category{winlayout}
518
519 @see wxSizer, @ref overview_sizeroverview "Sizer overview"
520 */
521 class wxFlexGridSizer : public wxGridSizer
522 {
523 public:
524 //@{
525 /**
526 Constructor for a wxGridSizer. @a rows and @a cols determine the number of
527 columns and rows in the sizer - if either of the parameters is zero, it will be
528 calculated to form the total number of children in the sizer, thus making the
529 sizer grow dynamically. @a vgap and @a hgap define extra space between
530 all children.
531 */
532 wxFlexGridSizer(int rows, int cols, int vgap, int hgap);
533 wxFlexGridSizer(int cols, int vgap = 0, int hgap = 0);
534 //@}
535
536 /**
537 Specifies that column @a idx (starting from zero) should be grown if
538 there is extra space available to the sizer.
539 The @a proportion parameter has the same meaning as the stretch factor for
540 the sizers() except that if all proportions are 0,
541 then all columns are resized equally (instead of not being resized at all).
542 */
543 void AddGrowableCol(size_t idx, int proportion = 0);
544
545 /**
546 Specifies that row idx (starting from zero) should be grown if there
547 is extra space available to the sizer.
548 See AddGrowableCol() for the description
549 of @a proportion parameter.
550 */
551 void AddGrowableRow(size_t idx, int proportion = 0);
552
553 /**
554 Returns a wxOrientation value that specifies whether the sizer flexibly
555 resizes its columns, rows, or both (default).
556
557 @returns One of the following values:
558
559 @see SetFlexibleDirection()
560 */
561 int GetFlexibleDirection() const;
562
563 /**
564 Returns the value that specifies how the sizer grows in the "non-flexible"
565 direction if there is one.
566
567 @returns One of the following values:
568
569 @see SetFlexibleDirection(),
570 SetNonFlexibleGrowMode()
571 */
572 int GetNonFlexibleGrowMode() const;
573
574 /**
575 Specifies that column idx is no longer growable.
576 */
577 void RemoveGrowableCol(size_t idx);
578
579 /**
580 Specifies that row idx is no longer growable.
581 */
582 void RemoveGrowableRow(size_t idx);
583
584 /**
585 Specifies whether the sizer should flexibly resize its columns, rows, or
586 both. Argument @c direction can be @c wxVERTICAL, @c wxHORIZONTAL
587 or @c wxBOTH (which is the default value). Any other value is ignored. See
588 @ref getflexibledrection() GetFlexibleDirection for the
589 explanation of these values.
590 Note that this method does not trigger relayout.
591 */
592 void SetFlexibleDirection(int direction);
593
594 /**
595 Specifies how the sizer should grow in the non-flexible direction if
596 there is one (so
597 SetFlexibleDirection() must have
598 been called previously). Argument @a mode can be one of those documented in
599 GetNonFlexibleGrowMode(), please
600 see there for their explanation.
601 Note that this method does not trigger relayout.
602 */
603 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode);
604 };
605
606
607
608 /**
609 @class wxSizer
610 @wxheader{sizer.h}
611
612 wxSizer is the abstract base class used for laying out subwindows in a window.
613 You
614 cannot use wxSizer directly; instead, you will have to use one of the sizer
615 classes derived from it. Currently there are wxBoxSizer,
616 wxStaticBoxSizer,
617 wxGridSizer,
618 wxFlexGridSizer,
619 wxWrapSizer
620 and wxGridBagSizer.
621
622 The layout algorithm used by sizers in wxWidgets is closely related to layout
623 in other GUI toolkits, such as Java's AWT, the GTK toolkit or the Qt toolkit.
624 It is
625 based upon the idea of the individual subwindows reporting their minimal
626 required
627 size and their ability to get stretched if the size of the parent window has
628 changed.
629 This will most often mean that the programmer does not set the original size of
630 a dialog in the beginning, rather the dialog will be assigned a sizer and this
631 sizer
632 will be queried about the recommended size. The sizer in turn will query its
633 children, which can be normal windows, empty space or other sizers, so that
634 a hierarchy of sizers can be constructed. Note that wxSizer does not derive
635 from wxWindow
636 and thus does not interfere with tab ordering and requires very little
637 resources compared
638 to a real window on screen.
639
640 What makes sizers so well fitted for use in wxWidgets is the fact that every
641 control
642 reports its own minimal size and the algorithm can handle differences in font
643 sizes
644 or different window (dialog item) sizes on different platforms without
645 problems. If e.g.
646 the standard font as well as the overall design of Motif widgets requires more
647 space than
648 on Windows, the initial dialog size will automatically be bigger on Motif than
649 on Windows.
650
651 Sizers may also be used to control the layout of custom drawn items on the
652 window. The Add(), Insert(), and Prepend() functions return a pointer to
653 the newly added wxSizerItem. Just add empty space of the desired size and
654 attributes, and then use the wxSizerItem::GetRect() method to determine
655 where the drawing operations should take place.
656
657 Please notice that sizers, like child windows, are owned by the library and
658 will be deleted by it which implies that they must be allocated on the
659 heap. However if you create a sizer and do not add it to another sizer or
660 window, the library wouldn't be able to delete such an orphan sizer and in
661 this, and only this, case it should be deleted explicitly.
662
663 @b wxPython note: If you wish to create a sizer class in wxPython you should
664 derive the class from @c wxPySizer in order to get Python-aware
665 capabilities for the various virtual methods.
666
667 @anchor wxsizer_flags
668 @par wxSizer flags
669 The "flag" argument accepted by wxSizeItem constructors and other
670 functions, e.g. wxSizer::Add(), is OR-combination of the following flags.
671 Two main behaviours are defined using these flags. One is the border around
672 a window: the border parameter determines the border width whereas the
673 flags given here determine which side(s) of the item that the border will
674 be added. The other flags determine how the sizer item behaves when the
675 space allotted to the sizer changes, and is somewhat dependent on the
676 specific kind of sizer used.
677 @beginDefList
678 @itemdef{wxTOP<br>
679 wxBOTTOM<br>
680 wxLEFT<br>
681 wxRIGHT<br>
682 wxALL,
683 These flags are used to specify which side(s) of the sizer item
684 the border width will apply to.}
685 @itemdef{wxEXPAND,
686 The item will be expanded to fill the space assigned to the item.}
687 @itemdef{wxSHAPED,
688 The item will be expanded as much as possible while also
689 maintaining its aspect ratio.}
690 @itemdef{wxFIXED_MINSIZE,
691 Normally wxSizers will use GetAdjustedBestSize() to determine what
692 the minimal size of window items should be, and will use that size
693 to calculate the layout. This allows layouts to adjust when an
694 item changes and its best size becomes different. If you would
695 rather have a window item stay the size it started with then use
696 wxFIXED_MINSIZE.}
697 @itemdef{wxALIGN_CENTER<br>
698 wxALIGN_CENTRE<br>
699 wxALIGN_LEFT<br>
700 wxALIGN_RIGHT<br>
701 wxALIGN_TOP<br>
702 wxALIGN_BOTTOM<br>
703 wxALIGN_CENTER_VERTICAL<br>
704 wxALIGN_CENTRE_VERTICAL<br>
705 wxALIGN_CENTER_HORIZONTAL<br>
706 wxALIGN_CENTRE_HORIZONTAL,
707 The wxALIGN flags allow you to specify the alignment of the item
708 within the space allotted to it by the sizer, adjusted for the
709 border if any.}
710 @endDefList
711
712
713 @library{wxcore}
714 @category{winlayout}
715
716 @see @ref overview_sizeroverview "Sizer overview"
717 */
718 class wxSizer : public wxObject
719 {
720 public:
721 /**
722 The constructor. Note that wxSizer is an abstract base class and may not
723 be instantiated.
724 */
725 wxSizer();
726
727 /**
728 The destructor.
729 */
730 ~wxSizer();
731
732 /**
733 Appends a child to the sizer.
734
735 wxSizer itself is an abstract class, but the parameters are equivalent
736 in the derived classes that you will instantiate to use it so they are
737 described here:
738
739 @param window
740 The window to be added to the sizer. Its initial size (either set
741 explicitly by the user or calculated internally when using
742 wxDefaultSize) is interpreted as the minimal and in many cases also
743 the initial size.
744 @param flags
745 A wxSizerFlags object that enables you to specify most of the above
746 parameters more conveniently.
747 */
748 wxSizerItem* Add(wxWindow* window, const wxSizerFlags& flags);
749
750 /**
751 Appends a child to the sizer.
752
753 wxSizer itself is an abstract class, but the parameters are equivalent
754 in the derived classes that you will instantiate to use it so they are
755 described here:
756
757 @param window
758 The window to be added to the sizer. Its initial size (either set
759 explicitly by the user or calculated internally when using
760 wxDefaultSize) is interpreted as the minimal and in many cases also
761 the initial size.
762 @param proportion
763 Although the meaning of this parameter is undefined in wxSizer, it
764 is used in wxBoxSizer to indicate if a child of a sizer can change
765 its size in the main orientation of the wxBoxSizer - where 0 stands
766 for not changeable and a value of more than zero is interpreted
767 relative to the value of other children of the same wxBoxSizer. For
768 example, you might have a horizontal wxBoxSizer with three
769 children, two of which are supposed to change their size with the
770 sizer. Then the two stretchable windows would get a value of 1 each
771 to make them grow and shrink equally with the sizer's horizontal
772 dimension.
773 @param flag
774 OR-combination of flags affecting sizer's behavior. See
775 @ref wxsizer_flags "wxSizer flags list" for details.
776 @param border
777 Determines the border width, if the flag parameter is set to
778 include any border flag.
779 @param userData
780 Allows an extra object to be attached to the sizer item, for use in
781 derived classes when sizing information is more complex than the
782 proportion and flag will allow for.
783 */
784 wxSizerItem* Add(wxWindow* window, int proportion = 0,
785 int flag = 0,
786 int border = 0,
787 wxObject* userData = NULL);
788
789 /**
790 Appends a child to the sizer.
791
792 wxSizer itself is an abstract class, but the parameters are equivalent
793 in the derived classes that you will instantiate to use it so they are
794 described here:
795
796 @param sizer
797 The (child-)sizer to be added to the sizer. This allows placing a
798 child sizer in a sizer and thus to create hierarchies of sizers
799 (typically a vertical box as the top sizer and several horizontal
800 boxes on the level beneath).
801 @param flags
802 A wxSizerFlags object that enables you to specify most of the above
803 parameters more conveniently.
804 */
805 wxSizerItem* Add(wxSizer* sizer, const wxSizerFlags& flags);
806
807 /**
808 Appends a child to the sizer.
809
810 wxSizer itself is an abstract class, but the parameters are equivalent
811 in the derived classes that you will instantiate to use it so they are
812 described here:
813
814 @param sizer
815 The (child-)sizer to be added to the sizer. This allows placing a
816 child sizer in a sizer and thus to create hierarchies of sizers
817 (typically a vertical box as the top sizer and several horizontal
818 boxes on the level beneath).
819 @param proportion
820 Although the meaning of this parameter is undefined in wxSizer, it
821 is used in wxBoxSizer to indicate if a child of a sizer can change
822 its size in the main orientation of the wxBoxSizer - where 0 stands
823 for not changeable and a value of more than zero is interpreted
824 relative to the value of other children of the same wxBoxSizer. For
825 example, you might have a horizontal wxBoxSizer with three
826 children, two of which are supposed to change their size with the
827 sizer. Then the two stretchable windows would get a value of 1 each
828 to make them grow and shrink equally with the sizer's horizontal
829 dimension.
830 @param flag
831 OR-combination of flags affecting sizer's behavior. See
832 @ref wxsizer_flags "wxSizer flags list" for details.
833 @param border
834 Determines the border width, if the flag parameter is set to
835 include any border flag.
836 @param userData
837 Allows an extra object to be attached to the sizer item, for use in
838 derived classes when sizing information is more complex than the
839 proportion and flag will allow for.
840 */
841 wxSizerItem* Add(wxSizer* sizer, int proportion = 0,
842 int flag = 0,
843 int border = 0,
844 wxObject* userData = NULL);
845
846 /**
847 Appends a spacer child to the sizer.
848
849 wxSizer itself is an abstract class, but the parameters are equivalent
850 in the derived classes that you will instantiate to use it so they are
851 described here.
852
853 @a width and @a height specify the dimension of a spacer to be added to
854 the sizer. Adding spacers to sizers gives more flexibility in the
855 design of dialogs; imagine for example a horizontal box with two
856 buttons at the bottom of a dialog: you might want to insert a space
857 between the two buttons and make that space stretchable using the
858 proportion flag and the result will be that the left button will be
859 aligned with the left side of the dialog and the right button with the
860 right side - the space in between will shrink and grow with the dialog.
861
862 @param width
863 Width of the spacer.
864 @param height
865 Height of the spacer.
866 @param proportion
867 Although the meaning of this parameter is undefined in wxSizer, it
868 is used in wxBoxSizer to indicate if a child of a sizer can change
869 its size in the main orientation of the wxBoxSizer - where 0 stands
870 for not changeable and a value of more than zero is interpreted
871 relative to the value of other children of the same wxBoxSizer. For
872 example, you might have a horizontal wxBoxSizer with three
873 children, two of which are supposed to change their size with the
874 sizer. Then the two stretchable windows would get a value of 1 each
875 to make them grow and shrink equally with the sizer's horizontal
876 dimension.
877 @param flag
878 OR-combination of flags affecting sizer's behavior. See
879 @ref wxsizer_flags "wxSizer flags list" for details.
880 @param border
881 Determines the border width, if the flag parameter is set to
882 include any border flag.
883 @param userData
884 Allows an extra object to be attached to the sizer item, for use in
885 derived classes when sizing information is more complex than the
886 proportion and flag will allow for.
887 */
888 wxSizerItem* Add(int width, int height, int proportion = 0,
889 int flag = 0,
890 int border = 0,
891 wxObject* userData = NULL);
892
893 /**
894 Adds non-stretchable space to the sizer. More readable way of calling
895 wxSizer::Add(size, size, 0).
896 */
897 wxSizerItem* AddSpacer(int size);
898
899 /**
900 Adds stretchable space to the sizer. More readable way of calling
901 wxSizer::Add(0, 0, prop).
902 */
903 wxSizerItem* AddStretchSpacer(int prop = 1);
904
905 /**
906 This method is abstract and has to be overwritten by any derived class.
907 Here, the sizer will do the actual calculation of its children's minimal sizes.
908 */
909 wxSize CalcMin();
910
911 /**
912 Detaches all children from the sizer. If @a delete_windows is @true then
913 child windows will also be deleted.
914 */
915 void Clear(bool delete_windows = false);
916
917 /**
918 Computes client area size for @a window so that it matches the sizer's
919 minimal size. Unlike GetMinSize(), this method accounts for other
920 constraints imposed on @e window, namely display's size (returned size
921 will never be too large for the display) and maximum window size if
922 previously set by wxWindow::SetMaxSize(). The returned value is
923 suitable for passing to wxWindow::SetClientSize() or
924 wxWindow::SetMinClientSize().
925
926 @since 2.8.8
927
928 @see ComputeFittingWindowSize(), Fit()
929 */
930 wxSize ComputeFittingClientSize(wxWindow* window);
931
932 /**
933 Like ComputeFittingClientSize(), but converts the result into window
934 size. The returned value is suitable for passing to wxWindow::SetSize()
935 or wxWindow::SetMinSize().
936
937 @since 2.8.8
938
939 @see ComputeFittingClientSize(), Fit()
940 */
941 wxSize ComputeFittingWindowSize(wxWindow* window);
942
943 //@{
944 /**
945 Detach a child from the sizer without destroying it. @a window is the window to
946 be
947 detached, @a sizer is the equivalent sizer and @a index is the position of
948 the child in the sizer, typically 0 for the first item. This method does not
949 cause any layout or resizing to take place, call Layout()
950 to update the layout "on screen" after detaching a child from the sizer.
951 Returns @true if the child item was found and detached, @false otherwise.
952
953 @see Remove()
954 */
955 bool Detach(wxWindow* window);
956 bool Detach(wxSizer* sizer);
957 bool Detach(size_t index);
958 //@}
959
960 /**
961 Tell the sizer to resize the @a window so that its client area matches the
962 sizer's minimal size
963 (ComputeFittingClientSize() is called
964 to determine it).
965 This is commonly done in the constructor of the window
966 itself, see sample in the description
967 of wxBoxSizer. Returns the new window size.
968
969 @see ComputeFittingClientSize(), ComputeFittingWindowSize()
970 */
971 wxSize Fit(wxWindow* window);
972
973 /**
974 Tell the sizer to resize the virtual size of the @a window to match the sizer's
975 minimal size. This will not alter the on screen size of the window, but may
976 cause
977 the addition/removal/alteration of scrollbars required to view the virtual area
978 in
979 windows which manage it.
980
981 @see wxScrolledWindow::SetScrollbars, SetVirtualSizeHints()
982 */
983 void FitInside(wxWindow* window);
984
985 //@{
986 /**
987 Returns the list of the items in this sizer. The elements of type-safe
988 wxList @c wxSizerItemList are objects of type
989 @ref overview_wxsizeritem "wxSizerItem *".
990 */
991 const wxSizerItemList GetChildren();
992 const wxSizerItemList GetChildren();
993 //@}
994
995 /**
996 Returns the window this sizer is used in or @NULL if none.
997 */
998 wxWindow* GetContainingWindow() const;
999
1000 //@{
1001 /**
1002 Finds item of the sizer which holds given @e window, @a sizer or is located
1003 in sizer at position @e index.
1004 Use parameter @a recursive to search in subsizers too.
1005 Returns pointer to item or @NULL.
1006 */
1007 wxSizerItem* GetItem(wxWindow* window, bool recursive = false);
1008 wxSizerItem* GetItem(wxSizer* sizer, bool recursive = false);
1009 wxSizerItem* GetItem(size_t index);
1010 //@}
1011
1012 /**
1013 Finds item of the sizer which has the given @e id. This @a id is not the
1014 window id but the id of the wxSizerItem itself. This is mainly useful for
1015 retrieving the sizers created from XRC resources.
1016 Use parameter @a recursive to search in subsizers too.
1017 Returns pointer to item or @NULL.
1018 */
1019 wxSizerItem* GetItemById(int id, bool recursive = false);
1020
1021 /**
1022 Returns the minimal size of the sizer. This is either the combined minimal
1023 size of all the children and their borders or the minimal size set by
1024 SetMinSize(), depending on which is bigger.
1025 Note that the returned value is client size, not window size.
1026 In particular, if you use the value to set toplevel window's minimal or
1027 actual size, use wxWindow::SetMinClientSize
1028 or wxWindow::SetClientSize, not
1029 wxWindow::SetMinSize
1030 or wxWindow::SetSize.
1031 */
1032 wxSize GetMinSize();
1033
1034 /**
1035 Returns the current position of the sizer.
1036 */
1037 wxPoint GetPosition();
1038
1039 /**
1040 Returns the current size of the sizer.
1041 */
1042 wxSize GetSize();
1043
1044 //@{
1045 /**
1046 Hides the @e window, @e sizer, or item at @e index.
1047 To make a sizer item disappear, use Hide() followed by Layout().
1048 Use parameter @a recursive to hide elements found in subsizers.
1049 Returns @true if the child item was found, @false otherwise.
1050
1051 @see IsShown(), Show()
1052 */
1053 bool Hide(wxWindow* window, bool recursive = false);
1054 bool Hide(wxSizer* sizer, bool recursive = false);
1055 bool Hide(size_t index);
1056 //@}
1057
1058 //@{
1059 /**
1060 Insert a child into the sizer before any existing item at
1061
1062 See Add() for the meaning of the other parameters.
1063
1064 @param index The position this child should assume in the sizer.
1065 */
1066 wxSizerItem* Insert(size_t index, wxWindow* window,
1067 const wxSizerFlags& flags);
1068 wxSizerItem* Insert(size_t index, wxWindow* window,
1069 int proportion = 0,
1070 int flag = 0,
1071 int border = 0,
1072 wxObject* userData = NULL);
1073 wxSizerItem* Insert(size_t index, wxSizer* sizer,
1074 const wxSizerFlags& flags);
1075 wxSizerItem* Insert(size_t index, wxSizer* sizer,
1076 int proportion = 0,
1077 int flag = 0,
1078 int border = 0,
1079 wxObject* userData = NULL);
1080 wxSizerItem* Insert(size_t index, int width, int height,
1081 int proportion = 0,
1082 int flag = 0,
1083 int border = 0,
1084 wxObject* userData = NULL);
1085 //@}
1086
1087 /**
1088 Inserts non-stretchable space to the sizer. More readable way of calling
1089 wxSizer::Insert(size, size, 0).
1090 */
1091 wxSizerItem* InsertSpacer(size_t index, int size);
1092
1093 /**
1094 Inserts stretchable space to the sizer. More readable way of calling
1095 wxSizer::Insert(0, 0, prop).
1096 */
1097 wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
1098
1099 //@{
1100 /**
1101 Returns @true if the @e window, @e sizer, or item at @a index is shown.
1102
1103 @see Hide(), Show()
1104 */
1105 bool IsShown(wxWindow* window) const;
1106 const bool IsShown(wxSizer* sizer) const;
1107 const bool IsShown(size_t index) const;
1108 //@}
1109
1110 /**
1111 Call this to force layout of the children anew, e.g. after having added a child
1112 to or removed a child (window, other sizer or space) from the sizer while
1113 keeping
1114 the current dimension.
1115 */
1116 void Layout();
1117
1118 /**
1119 Same as Add(), but prepends the items to the beginning of the
1120 list of items (windows, subsizers or spaces) owned by this sizer.
1121 */
1122 wxSizerItem* Prepend(wxWindow* window, const wxSizerFlags& flags);
1123
1124 /**
1125 Same as Add(), but prepends the items to the beginning of the
1126 list of items (windows, subsizers or spaces) owned by this sizer.
1127 */
1128 wxSizerItem* Prepend(wxWindow* window, int proportion = 0,
1129 int flag = 0,
1130 int border = 0,
1131 wxObject* userData = NULL);
1132
1133 /**
1134 Same as Add(), but prepends the items to the beginning of the
1135 list of items (windows, subsizers or spaces) owned by this sizer.
1136 */
1137 wxSizerItem* Prepend(wxSizer* sizer,
1138 const wxSizerFlags& flags);
1139
1140 /**
1141 Same as Add(), but prepends the items to the beginning of the
1142 list of items (windows, subsizers or spaces) owned by this sizer.
1143 */
1144 wxSizerItem* Prepend(wxSizer* sizer, int proportion = 0,
1145 int flag = 0,
1146 int border = 0,
1147 wxObject* userData = NULL);
1148
1149 /**
1150 Same as Add(), but prepends the items to the beginning of the
1151 list of items (windows, subsizers or spaces) owned by this sizer.
1152 */
1153 wxSizerItem* Prepend(int width, int height,
1154 int proportion = 0,
1155 int flag = 0,
1156 int border = 0,
1157 wxObject* userData = NULL);
1158
1159 /**
1160 Prepends non-stretchable space to the sizer. More readable way of
1161 calling wxSizer::Prepend(size, size, 0).
1162 */
1163 wxSizerItem* PrependSpacer(int size);
1164
1165 /**
1166 Prepends stretchable space to the sizer. More readable way of calling
1167 wxSizer::Prepend(0, 0, prop).
1168 */
1169 wxSizerItem* PrependStretchSpacer(int prop = 1);
1170
1171 /**
1172 This method is abstract and has to be overwritten by any derived class.
1173 Here, the sizer will do the actual calculation of its children's
1174 positions and sizes.
1175 */
1176 void RecalcSizes();
1177
1178 /**
1179 Removes a child window from the sizer, but does @b not destroy it
1180 (because windows are owned by their parent window, not the sizer).
1181
1182 @deprecated
1183 The overload of this method taking a wxWindow* parameter
1184 is deprecated as it does not destroy the window as would usually be
1185 expected from Remove(). You should use Detach() in new code instead.
1186 There is currently no wxSizer method that will both detach and destroy
1187 a wxWindow item.
1188
1189 @note This method does not cause any layout or resizing to take
1190 place, call Layout() to update the layout "on screen" after
1191 removing a child from the sizer.
1192
1193 @return @true if the child item was found and removed, @false otherwise.
1194 */
1195 bool Remove(wxWindow* window);
1196
1197 /**
1198 Removes a sizer child from the sizer and destroys it.
1199
1200 @note This method does not cause any layout or resizing to take
1201 place, call Layout() to update the layout "on screen" after
1202 removing a child from the sizer.
1203
1204 @param sizer The wxSizer to be removed.
1205
1206 @return @true if the child item was found and removed, @false otherwise.
1207 */
1208 bool Remove(wxSizer* sizer);
1209
1210 /**
1211 Removes a child from the sizer and destroys it if it is a sizer or a
1212 spacer, but not if it is a window (because windows are owned by their
1213 parent window, not the sizer).
1214
1215 @note This method does not cause any layout or resizing to take
1216 place, call Layout() to update the layout "on screen" after
1217 removing a child from the sizer.
1218
1219 @param index The position of the child in the sizer, e.g. 0 for the
1220 first item.
1221
1222 @return @true if the child item was found and removed, @false otherwise.
1223 */
1224 bool Remove(size_t index);
1225
1226 //@{
1227 /**
1228 Detaches the given @e oldwin, @a oldsz child from the sizer and
1229 replaces it with the given window, sizer, or wxSizerItem.
1230 The detached child is removed @b only if it is a sizer or a spacer
1231 (because windows are owned by their parent window, not the sizer).
1232 Use parameter @a recursive to search the given element recursively in subsizers.
1233
1234 This method does not cause any layout or resizing to take place, call
1235 Layout() to update the layout "on screen" after replacing a
1236 child from the sizer.
1237 Returns @true if the child item was found and removed, @false otherwise.
1238 */
1239 bool Replace(wxWindow* oldwin, wxWindow* newwin,
1240 bool recursive = false);
1241 bool Replace(wxSizer* oldsz, wxSizer* newsz,
1242 bool recursive = false);
1243 bool Remove(size_t oldindex, wxSizerItem* newitem);
1244 //@}
1245
1246 /**
1247 Call this to force the sizer to take the given dimension and thus force
1248 the items owned by the sizer to resize themselves according to the
1249 rules defined by the parameter in the Add() and Prepend() methods.
1250 */
1251 void SetDimension(int x, int y, int width, int height);
1252
1253 //@{
1254 /**
1255 Set an item's minimum size by window, sizer, or position. The item will be
1256 found recursively
1257 in the sizer's descendants. This function enables an application to set the
1258 size of an item
1259 after initial creation.
1260 */
1261 void SetItemMinSize(wxWindow* window, int width, int height);
1262 void SetItemMinSize(wxSizer* sizer, int width, int height);
1263 void SetItemMinSize(size_t index, int width, int height);
1264 //@}
1265
1266 /**
1267 Call this to give the sizer a minimal size. Normally, the sizer will
1268 calculate its minimal size based purely on how much space its children
1269 need. After calling this method GetMinSize() will return either the
1270 minimal size as requested by its children or the minimal size set here,
1271 depending on which is bigger.
1272 */
1273 void SetMinSize(const wxSize& size);
1274
1275 /**
1276 @overload
1277 */
1278 void SetMinSize(int width, int height);
1279
1280 /**
1281 This method first calls Fit() and then
1282 wxTopLevelWindow::SetSizeHints on the @e window
1283 passed to it. This only makes sense when @a window is actually a
1284 wxTopLevelWindow such as a wxFrame or a
1285 wxDialog, since SetSizeHints only has any effect in these classes.
1286 It does nothing in normal windows or controls.
1287 This method is implicitly used by wxWindow::SetSizerAndFit
1288 which is commonly invoked in the constructor of a toplevel window itself (see
1289 the sample in the description of wxBoxSizer) if the
1290 toplevel window is resizable.
1291 */
1292 void SetSizeHints(wxWindow* window);
1293
1294 /**
1295 Tell the sizer to set the minimal size of the @a window virtual area to match
1296 the sizer's
1297 minimal size. For windows with managed scrollbars this will set them
1298 appropriately.
1299
1300 @see wxScrolledWindow::SetScrollbars
1301 */
1302 void SetVirtualSizeHints(wxWindow* window);
1303
1304 //@{
1305 /**
1306 Shows or hides the @e window, @e sizer, or item at @e index.
1307 To make a sizer item disappear or reappear, use Show() followed by Layout().
1308 Use parameter @a recursive to show or hide elements found in subsizers.
1309 Returns @true if the child item was found, @false otherwise.
1310
1311 @see Hide(), IsShown()
1312 */
1313 bool Show(wxWindow* window, bool show = true,
1314 bool recursive = false);
1315 bool Show(wxSizer* sizer, bool show = true,
1316 bool recursive = false);
1317 bool Show(size_t index, bool show = true);
1318 //@}
1319 };
1320
1321
1322
1323 /**
1324 @class wxGridSizer
1325 @wxheader{sizer.h}
1326
1327 A grid sizer is a sizer which lays out its children in a two-dimensional
1328 table with all table fields having the same size,
1329 i.e. the width of each field is the width of the widest child,
1330 the height of each field is the height of the tallest child.
1331
1332 @library{wxcore}
1333 @category{winlayout}
1334
1335 @see wxSizer, @ref overview_sizeroverview "Sizer overview"
1336 */
1337 class wxGridSizer : public wxSizer
1338 {
1339 public:
1340 //@{
1341 /**
1342 Constructor for a wxGridSizer. @a rows and @a cols determine the number of
1343 columns and rows in the sizer - if either of the parameters is zero, it will be
1344 calculated to form the total number of children in the sizer, thus making the
1345 sizer grow dynamically. @a vgap and @a hgap define extra space between
1346 all children.
1347 */
1348 wxGridSizer(int rows, int cols, int vgap, int hgap);
1349 wxGridSizer(int cols, int vgap = 0, int hgap = 0);
1350 //@}
1351
1352 /**
1353 Returns the number of columns in the sizer.
1354 */
1355 int GetCols();
1356
1357 /**
1358 Returns the horizontal gap (in pixels) between cells in the sizer.
1359 */
1360 int GetHGap();
1361
1362 /**
1363 Returns the number of rows in the sizer.
1364 */
1365 int GetRows();
1366
1367 /**
1368 Returns the vertical gap (in pixels) between the cells in the sizer.
1369 */
1370 int GetVGap();
1371
1372 /**
1373 Sets the number of columns in the sizer.
1374 */
1375 void SetCols(int cols);
1376
1377 /**
1378 Sets the horizontal gap (in pixels) between cells in the sizer.
1379 */
1380 void SetHGap(int gap);
1381
1382 /**
1383 Sets the number of rows in the sizer.
1384 */
1385 void SetRows(int rows);
1386
1387 /**
1388 Sets the vertical gap (in pixels) between the cells in the sizer.
1389 */
1390 void SetVGap(int gap);
1391 };
1392
1393
1394
1395 /**
1396 @class wxStaticBoxSizer
1397 @wxheader{sizer.h}
1398
1399 wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static
1400 box around the sizer. This static box may be either created independently or
1401 the sizer may create it itself as a convenience. In any case, the sizer owns
1402 the wxStaticBox control and will delete it if it is
1403 deleted.
1404
1405 @library{wxcore}
1406 @category{winlayout}
1407
1408 @see wxSizer, wxStaticBox, wxBoxSizer, @ref overview_sizeroverview "Sizer
1409 overview"
1410 */
1411 class wxStaticBoxSizer : public wxBoxSizer
1412 {
1413 public:
1414 //@{
1415 /**
1416 The first constructor uses an already existing static box. It takes the
1417 associated static box and the orientation @e orient, which can be either
1418 @c wxVERTICAL or @c wxHORIZONTAL as parameters.
1419 The second one creates a new static box with the given label and parent window.
1420 */
1421 wxStaticBoxSizer(wxStaticBox* box, int orient);
1422 wxStaticBoxSizer(int orient, wxWindow parent,
1423 const wxString& label = wxEmptyString);
1424 //@}
1425
1426 /**
1427 Returns the static box associated with the sizer.
1428 */
1429 wxStaticBox* GetStaticBox();
1430 };
1431
1432
1433
1434 /**
1435 @class wxBoxSizer
1436 @wxheader{sizer.h}
1437
1438 The basic idea behind a box sizer is that windows will most often be laid out
1439 in rather
1440 simple basic geometry, typically in a row or a column or several hierarchies of
1441 either.
1442
1443 For more information, please see @ref overview_boxsizerprogramming "Programming
1444 with wxBoxSizer".
1445
1446 @library{wxcore}
1447 @category{winlayout}
1448
1449 @see wxSizer, @ref overview_sizeroverview "Sizer overview"
1450 */
1451 class wxBoxSizer : public wxSizer
1452 {
1453 public:
1454 /**
1455 Constructor for a wxBoxSizer. @a orient may be either of wxVERTICAL
1456 or wxHORIZONTAL for creating either a column sizer or a row sizer.
1457 */
1458 wxBoxSizer(int orient);
1459
1460 /**
1461 Implements the calculation of a box sizer's minimal. It is used internally
1462 only and must not be called by the user. Documented for information.
1463 */
1464 wxSize CalcMin();
1465
1466 /**
1467 Returns the orientation of the box sizer, either wxVERTICAL
1468 or wxHORIZONTAL.
1469 */
1470 int GetOrientation();
1471
1472 /**
1473 Implements the calculation of a box sizer's dimensions and then sets
1474 the size of its children (calling wxWindow::SetSize
1475 if the child is a window). It is used internally only and must not be called
1476 by the user (call Layout() if you want to resize). Documented for information.
1477 */
1478 void RecalcSizes();
1479 };
1480