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