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