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