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