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