]>
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$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
e725ba4f FM |
9 | |
10 | /** | |
788194ff | 11 | @class wxSizer |
e725ba4f | 12 | |
788194ff FM |
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. | |
e725ba4f | 17 | |
788194ff FM |
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. | |
e725ba4f | 23 | |
788194ff FM |
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. | |
e725ba4f | 31 | |
788194ff FM |
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. | |
7c913512 | 38 | |
788194ff FM |
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. | |
7c913512 | 45 | |
788194ff FM |
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. | |
7c913512 | 51 | |
788194ff FM |
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 | |
7c913512 | 57 | |
788194ff FM |
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 | |
7c913512 | 109 | |
23324ae1 | 110 | @library{wxcore} |
4b962ba1 | 111 | @category{winlayout} |
7c913512 | 112 | |
788194ff | 113 | @see @ref overview_sizer |
23324ae1 | 114 | */ |
788194ff | 115 | class wxSizer : public wxObject |
23324ae1 FM |
116 | { |
117 | public: | |
118 | /** | |
788194ff FM |
119 | The constructor. |
120 | Note that wxSizer is an abstract base class and may not be instantiated. | |
23324ae1 | 121 | */ |
788194ff | 122 | wxSizer(); |
23324ae1 FM |
123 | |
124 | /** | |
788194ff | 125 | The destructor. |
23324ae1 | 126 | */ |
788194ff | 127 | virtual ~wxSizer(); |
23324ae1 FM |
128 | |
129 | /** | |
788194ff | 130 | Appends a child to the sizer. |
23324ae1 | 131 | |
788194ff FM |
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: | |
4876436a | 135 | |
788194ff FM |
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. | |
23324ae1 | 144 | */ |
788194ff | 145 | wxSizerItem* Add(wxWindow* window, const wxSizerFlags& flags); |
23324ae1 FM |
146 | |
147 | /** | |
788194ff | 148 | Appends a child to the sizer. |
23324ae1 | 149 | |
788194ff FM |
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: | |
4876436a | 153 | |
788194ff FM |
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. | |
23324ae1 | 180 | */ |
788194ff FM |
181 | wxSizerItem* Add(wxWindow* window, |
182 | int proportion = 0, | |
183 | int flag = 0, | |
184 | int border = 0, | |
185 | wxObject* userData = NULL); | |
7c913512 | 186 | |
23324ae1 | 187 | /** |
788194ff | 188 | Appends a child to the sizer. |
e725ba4f | 189 | |
788194ff FM |
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: | |
e725ba4f | 193 | |
788194ff FM |
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. | |
e725ba4f | 202 | */ |
788194ff | 203 | wxSizerItem* Add(wxSizer* sizer, const wxSizerFlags& flags); |
23324ae1 FM |
204 | |
205 | /** | |
788194ff | 206 | Appends a child to the sizer. |
23324ae1 | 207 | |
788194ff FM |
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: | |
23324ae1 | 211 | |
788194ff FM |
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. | |
23324ae1 | 238 | */ |
788194ff FM |
239 | wxSizerItem* Add(wxSizer* sizer, |
240 | int proportion = 0, | |
241 | int flag = 0, | |
242 | int border = 0, | |
243 | wxObject* userData = NULL); | |
23324ae1 FM |
244 | |
245 | /** | |
788194ff FM |
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. | |
23324ae1 | 286 | */ |
788194ff FM |
287 | wxSizerItem* Add(int width, int height, |
288 | int proportion = 0, | |
289 | int flag = 0, | |
290 | int border = 0, | |
291 | wxObject* userData = NULL); | |
23324ae1 FM |
292 | |
293 | /** | |
1a2df6a7 VZ |
294 | This base function adds non-stretchable space to both the horizontal |
295 | and vertical orientation of the sizer. | |
788194ff FM |
296 | More readable way of calling: |
297 | @code | |
298 | wxSizer::Add(size, size, 0). | |
299 | @endcode | |
1a2df6a7 | 300 | @see wxBoxSizer::AddSpacer() |
23324ae1 | 301 | */ |
1a2df6a7 | 302 | virtual wxSizerItem *AddSpacer(int size); |
23324ae1 FM |
303 | |
304 | /** | |
788194ff FM |
305 | Adds stretchable space to the sizer. |
306 | More readable way of calling: | |
307 | @code | |
308 | wxSizer::Add(0, 0, prop). | |
309 | @endcode | |
23324ae1 | 310 | */ |
788194ff | 311 | wxSizerItem* AddStretchSpacer(int prop = 1); |
23324ae1 FM |
312 | |
313 | /** | |
788194ff FM |
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. | |
23324ae1 | 316 | */ |
788194ff | 317 | virtual wxSize CalcMin() = 0; |
23324ae1 FM |
318 | |
319 | /** | |
788194ff FM |
320 | Detaches all children from the sizer. |
321 | If @a delete_windows is @true then child windows will also be deleted. | |
23324ae1 | 322 | */ |
788194ff | 323 | virtual void Clear(bool delete_windows = false); |
23324ae1 | 324 | |
7e927914 | 325 | /** |
788194ff FM |
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(). | |
7e927914 | 331 | |
788194ff FM |
332 | The returned value is suitable for passing to wxWindow::SetClientSize() or |
333 | wxWindow::SetMinClientSize(). | |
7e927914 | 334 | |
788194ff | 335 | @since 2.8.8 |
7e927914 | 336 | |
788194ff | 337 | @see ComputeFittingWindowSize(), Fit() |
23324ae1 | 338 | */ |
788194ff | 339 | wxSize ComputeFittingClientSize(wxWindow* window); |
23324ae1 FM |
340 | |
341 | /** | |
788194ff FM |
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(). | |
23324ae1 | 345 | |
788194ff | 346 | @since 2.8.8 |
23324ae1 | 347 | |
788194ff | 348 | @see ComputeFittingClientSize(), Fit() |
23324ae1 | 349 | */ |
788194ff | 350 | wxSize ComputeFittingWindowSize(wxWindow* window); |
23324ae1 FM |
351 | |
352 | /** | |
788194ff | 353 | Detach the child @a window from the sizer without destroying it. |
23324ae1 | 354 | |
788194ff FM |
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. | |
23324ae1 | 357 | |
788194ff | 358 | Returns @true if the child item was found and detached, @false otherwise. |
23324ae1 | 359 | |
788194ff | 360 | @see Remove() |
23324ae1 | 361 | */ |
788194ff | 362 | virtual bool Detach(wxWindow* window); |
23324ae1 FM |
363 | |
364 | /** | |
788194ff FM |
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() | |
23324ae1 | 373 | */ |
788194ff | 374 | virtual bool Detach(wxSizer* sizer); |
23324ae1 FM |
375 | |
376 | /** | |
788194ff | 377 | Detach a item at position @a index from the sizer without destroying it. |
01195a1b | 378 | |
788194ff FM |
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. | |
01195a1b | 382 | |
788194ff | 383 | @see Remove() |
23324ae1 | 384 | */ |
788194ff | 385 | virtual bool Detach(int index); |
23324ae1 FM |
386 | |
387 | /** | |
788194ff FM |
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() | |
23324ae1 | 396 | */ |
788194ff | 397 | wxSize Fit(wxWindow* window); |
23324ae1 FM |
398 | |
399 | /** | |
788194ff FM |
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() | |
23324ae1 | 406 | */ |
788194ff | 407 | void FitInside(wxWindow* window); |
23324ae1 | 408 | |
788194ff | 409 | //@{ |
23324ae1 | 410 | /** |
788194ff FM |
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. | |
23324ae1 | 415 | */ |
788194ff FM |
416 | wxSizerItemList& GetChildren(); |
417 | const wxSizerItemList& GetChildren() const; | |
418 | //@} | |
23324ae1 FM |
419 | |
420 | /** | |
788194ff | 421 | Returns the window this sizer is used in or @NULL if none. |
23324ae1 | 422 | */ |
788194ff | 423 | wxWindow* GetContainingWindow() const; |
23324ae1 FM |
424 | |
425 | /** | |
788194ff FM |
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. | |
23324ae1 | 430 | */ |
788194ff | 431 | size_t GetItemCount() const; |
23324ae1 FM |
432 | |
433 | /** | |
788194ff FM |
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. | |
23324ae1 | 437 | */ |
788194ff | 438 | wxSizerItem* GetItem(wxWindow* window, bool recursive = false); |
23324ae1 FM |
439 | |
440 | /** | |
788194ff FM |
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. | |
23324ae1 | 444 | */ |
788194ff FM |
445 | |
446 | wxSizerItem* GetItem(wxSizer* sizer, bool recursive = false); | |
23324ae1 FM |
447 | |
448 | /** | |
788194ff FM |
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. | |
23324ae1 | 452 | */ |
788194ff | 453 | wxSizerItem* GetItem(size_t index); |
23324ae1 FM |
454 | |
455 | /** | |
788194ff FM |
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. | |
23324ae1 | 461 | */ |
788194ff | 462 | wxSizerItem* GetItemById(int id, bool recursive = false); |
23324ae1 | 463 | |
23324ae1 | 464 | /** |
788194ff | 465 | Returns the minimal size of the sizer. |
23324ae1 | 466 | |
788194ff FM |
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(). | |
23324ae1 | 473 | */ |
788194ff | 474 | wxSize GetMinSize(); |
23324ae1 FM |
475 | |
476 | /** | |
788194ff | 477 | Returns the current position of the sizer. |
23324ae1 | 478 | */ |
788194ff | 479 | wxPoint GetPosition() const; |
23324ae1 FM |
480 | |
481 | /** | |
788194ff | 482 | Returns the current size of the sizer. |
23324ae1 | 483 | */ |
788194ff | 484 | wxSize GetSize() const; |
23324ae1 FM |
485 | |
486 | /** | |
788194ff | 487 | Hides the child @a window. |
7c913512 | 488 | |
788194ff | 489 | To make a sizer item disappear, use Hide() followed by Layout(). |
7c913512 | 490 | |
788194ff FM |
491 | Use parameter @a recursive to hide elements found in subsizers. |
492 | Returns @true if the child item was found, @false otherwise. | |
7c913512 | 493 | |
788194ff FM |
494 | @see IsShown(), Show() |
495 | */ | |
496 | bool Hide(wxWindow* window, bool recursive = false); | |
7c913512 | 497 | |
788194ff FM |
498 | /** |
499 | Hides the child @a sizer. | |
7c913512 | 500 | |
788194ff | 501 | To make a sizer item disappear, use Hide() followed by Layout(). |
7c913512 | 502 | |
788194ff FM |
503 | Use parameter @a recursive to hide elements found in subsizers. |
504 | Returns @true if the child item was found, @false otherwise. | |
7c913512 | 505 | |
788194ff | 506 | @see IsShown(), Show() |
23324ae1 | 507 | */ |
788194ff | 508 | bool Hide(wxSizer* sizer, bool recursive = false); |
23324ae1 FM |
509 | |
510 | /** | |
788194ff | 511 | Hides the item at position @a index. |
30a56ea8 | 512 | |
788194ff | 513 | To make a sizer item disappear, use Hide() followed by Layout(). |
3c4f71cc | 514 | |
788194ff FM |
515 | Use parameter @a recursive to hide elements found in subsizers. |
516 | Returns @true if the child item was found, @false otherwise. | |
30a56ea8 | 517 | |
788194ff | 518 | @see IsShown(), Show() |
23324ae1 | 519 | */ |
788194ff | 520 | bool Hide(size_t index); |
23324ae1 | 521 | |
23324ae1 | 522 | /** |
788194ff FM |
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. | |
23324ae1 | 526 | */ |
788194ff FM |
527 | wxSizerItem* Insert(size_t index, wxWindow* window, |
528 | const wxSizerFlags& flags); | |
feaa1ecb VS |
529 | |
530 | /** | |
788194ff | 531 | Insert a child into the sizer before any existing item at @a index. |
feaa1ecb | 532 | |
788194ff | 533 | See Add() for the meaning of the other parameters. |
feaa1ecb | 534 | */ |
788194ff FM |
535 | wxSizerItem* Insert(size_t index, wxWindow* window, |
536 | int proportion = 0, | |
537 | int flag = 0, | |
538 | int border = 0, | |
539 | wxObject* userData = NULL); | |
23324ae1 FM |
540 | |
541 | /** | |
788194ff | 542 | Insert a child into the sizer before any existing item at @a index. |
3c4f71cc | 543 | |
788194ff | 544 | See Add() for the meaning of the other parameters. |
23324ae1 | 545 | */ |
788194ff FM |
546 | wxSizerItem* Insert(size_t index, wxSizer* sizer, |
547 | const wxSizerFlags& flags); | |
23324ae1 FM |
548 | |
549 | /** | |
788194ff | 550 | Insert a child into the sizer before any existing item at @a index. |
23324ae1 | 551 | |
788194ff | 552 | See Add() for the meaning of the other parameters. |
23324ae1 | 553 | */ |
788194ff FM |
554 | wxSizerItem* Insert(size_t index, wxSizer* sizer, |
555 | int proportion = 0, | |
556 | int flag = 0, | |
557 | int border = 0, | |
558 | wxObject* userData = NULL); | |
23324ae1 FM |
559 | |
560 | /** | |
788194ff FM |
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. | |
23324ae1 | 564 | */ |
788194ff FM |
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); | |
23324ae1 FM |
570 | |
571 | /** | |
788194ff | 572 | Inserts non-stretchable space to the sizer. |
f81114dc | 573 | More readable way of calling wxSizer::Insert(index, size, size). |
23324ae1 | 574 | */ |
788194ff | 575 | wxSizerItem* InsertSpacer(size_t index, int size); |
23324ae1 FM |
576 | |
577 | /** | |
788194ff FM |
578 | Inserts stretchable space to the sizer. |
579 | More readable way of calling wxSizer::Insert(0, 0, prop). | |
23324ae1 | 580 | */ |
788194ff | 581 | wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1); |
23324ae1 FM |
582 | |
583 | /** | |
788194ff FM |
584 | Return @true if the sizer has no elements. |
585 | ||
586 | @see GetItemCount() | |
587 | */ | |
588 | bool IsEmpty() const; | |
23324ae1 | 589 | |
01195a1b | 590 | /** |
788194ff | 591 | Returns @true if the @a window is shown. |
01195a1b | 592 | |
788194ff | 593 | @see Hide(), Show(), wxSizerItem::IsShown() |
01195a1b | 594 | */ |
788194ff | 595 | bool IsShown(wxWindow* window) const; |
01195a1b | 596 | |
23324ae1 | 597 | /** |
788194ff FM |
598 | Returns @true if the @a sizer is shown. |
599 | ||
600 | @see Hide(), Show(), wxSizerItem::IsShown() | |
23324ae1 | 601 | */ |
788194ff | 602 | bool IsShown(wxSizer* sizer) const; |
23324ae1 FM |
603 | |
604 | /** | |
788194ff | 605 | Returns @true if the item at @a index is shown. |
3c4f71cc | 606 | |
788194ff | 607 | @see Hide(), Show(), wxSizerItem::IsShown() |
23324ae1 | 608 | */ |
788194ff | 609 | bool IsShown(size_t index) const; |
23324ae1 FM |
610 | |
611 | /** | |
788194ff FM |
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. | |
23324ae1 | 615 | */ |
788194ff | 616 | virtual void Layout(); |
23324ae1 FM |
617 | |
618 | /** | |
788194ff FM |
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. | |
23324ae1 | 621 | */ |
788194ff | 622 | wxSizerItem* Prepend(wxWindow* window, const wxSizerFlags& flags); |
23324ae1 FM |
623 | |
624 | /** | |
788194ff FM |
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. | |
23324ae1 | 627 | */ |
788194ff FM |
628 | wxSizerItem* Prepend(wxWindow* window, int proportion = 0, |
629 | int flag = 0, | |
630 | int border = 0, | |
631 | wxObject* userData = NULL); | |
23324ae1 FM |
632 | |
633 | /** | |
788194ff FM |
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. | |
23324ae1 | 636 | */ |
788194ff FM |
637 | wxSizerItem* Prepend(wxSizer* sizer, |
638 | const wxSizerFlags& flags); | |
23324ae1 FM |
639 | |
640 | /** | |
788194ff FM |
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. | |
23324ae1 | 643 | */ |
788194ff FM |
644 | wxSizerItem* Prepend(wxSizer* sizer, int proportion = 0, |
645 | int flag = 0, | |
646 | int border = 0, | |
647 | wxObject* userData = NULL); | |
23324ae1 | 648 | |
788194ff FM |
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); | |
23324ae1 | 658 | |
788194ff FM |
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); | |
e54c96f1 | 664 | |
788194ff FM |
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); | |
7c913512 | 670 | |
788194ff FM |
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; | |
7c913512 | 677 | |
788194ff FM |
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). | |
7c913512 | 681 | |
788194ff FM |
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); | |
7c913512 | 696 | |
23324ae1 | 697 | /** |
788194ff | 698 | Removes a sizer child from the sizer and destroys it. |
e725ba4f | 699 | |
788194ff FM |
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. | |
e725ba4f | 703 | |
788194ff FM |
704 | @param sizer The wxSizer to be removed. |
705 | ||
706 | @return @true if the child item was found and removed, @false otherwise. | |
23324ae1 | 707 | */ |
788194ff | 708 | virtual bool Remove(wxSizer* sizer); |
23324ae1 FM |
709 | |
710 | /** | |
788194ff FM |
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). | |
67ef83eb | 714 | |
788194ff FM |
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. | |
67ef83eb | 718 | |
788194ff FM |
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. | |
23324ae1 | 723 | */ |
788194ff | 724 | virtual bool Remove(int index); |
23324ae1 FM |
725 | |
726 | /** | |
788194ff FM |
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). | |
67ef83eb | 730 | |
788194ff FM |
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. | |
23324ae1 | 738 | */ |
788194ff FM |
739 | virtual bool Replace(wxWindow* oldwin, wxWindow* newwin, |
740 | bool recursive = false); | |
23324ae1 FM |
741 | |
742 | /** | |
788194ff FM |
743 | Detaches the given @a oldsz from the sizer and replaces it with the |
744 | given @a newsz. The detached child sizer is deleted. | |
3c4f71cc | 745 | |
788194ff | 746 | Use parameter @a recursive to search the given element recursively in subsizers. |
3c4f71cc | 747 | |
788194ff FM |
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. | |
23324ae1 | 753 | */ |
788194ff FM |
754 | virtual bool Replace(wxSizer* oldsz, wxSizer* newsz, |
755 | bool recursive = false); | |
23324ae1 FM |
756 | |
757 | /** | |
788194ff FM |
758 | Detaches the given item at position @a index from the sizer and |
759 | replaces it with the given wxSizerItem @a newitem. | |
3c4f71cc | 760 | |
788194ff FM |
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). | |
893039c0 | 764 | |
788194ff FM |
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. | |
3c4f71cc | 768 | |
788194ff | 769 | Returns @true if the child item was found and removed, @false otherwise. |
23324ae1 | 770 | */ |
788194ff | 771 | virtual bool Replace(size_t index, wxSizerItem* newitem); |
23324ae1 | 772 | |
67ef83eb | 773 | /** |
788194ff FM |
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. | |
67ef83eb | 777 | */ |
788194ff | 778 | void SetDimension(int x, int y, int width, int height); |
67ef83eb VZ |
779 | |
780 | /** | |
788194ff FM |
781 | @overload |
782 | */ | |
783 | void SetDimension(const wxPoint& pos, const wxSize& size); | |
67ef83eb | 784 | |
788194ff FM |
785 | /** |
786 | Set an item's minimum size by window, sizer, or position. | |
787 | ||
788194ff FM |
788 | This function enables an application to set the size of an item after |
789 | initial creation. | |
790 | ||
58c69c44 VZ |
791 | The @a window or @a sizer will be found recursively in the sizer's |
792 | descendants. | |
793 | ||
788194ff | 794 | @see wxSizerItem::SetMinSize() |
58c69c44 VZ |
795 | |
796 | @return | |
797 | @true if the minimal size was successfully set or @false if the | |
798 | item was not found. | |
67ef83eb | 799 | */ |
58c69c44 | 800 | //@{ |
788194ff | 801 | bool SetItemMinSize(wxWindow* window, int width, int height); |
58c69c44 | 802 | bool SetItemMinSize(wxWindow* window, const wxSize& size); |
67ef83eb | 803 | |
788194ff | 804 | bool SetItemMinSize(wxSizer* sizer, int width, int height); |
58c69c44 | 805 | bool SetItemMinSize(wxSizer* sizer, const wxSize& size); |
23324ae1 | 806 | |
788194ff | 807 | bool SetItemMinSize(size_t index, int width, int height); |
58c69c44 VZ |
808 | bool SetItemMinSize(size_t index, const wxSize& size); |
809 | //@} | |
23324ae1 FM |
810 | |
811 | /** | |
788194ff | 812 | Call this to give the sizer a minimal size. |
e725ba4f | 813 | |
788194ff FM |
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. | |
23324ae1 | 818 | */ |
788194ff | 819 | void SetMinSize(const wxSize& size); |
23324ae1 FM |
820 | |
821 | /** | |
788194ff FM |
822 | @overload |
823 | */ | |
824 | void SetMinSize(int width, int height); | |
e725ba4f | 825 | |
788194ff FM |
826 | /** |
827 | This method first calls Fit() and then wxTopLevelWindow::SetSizeHints() | |
828 | on the @a window passed to it. | |
23324ae1 | 829 | |
788194ff FM |
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. | |
23324ae1 | 833 | |
788194ff FM |
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); | |
e54c96f1 | 840 | |
788194ff FM |
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. | |
7c913512 | 845 | |
df7d641d VZ |
846 | @deprecated This is exactly the same as FitInside() in wxWidgets 2.9 |
847 | and later, please replace calls to it with FitInside(). | |
7c913512 | 848 | |
788194ff | 849 | @see wxScrolled::SetScrollbars() |
23324ae1 | 850 | */ |
788194ff | 851 | void SetVirtualSizeHints(wxWindow* window); |
23324ae1 FM |
852 | |
853 | /** | |
788194ff FM |
854 | Shows or hides the @a window. |
855 | To make a sizer item disappear or reappear, use Show() followed by Layout(). | |
23324ae1 | 856 | |
788194ff | 857 | Use parameter @a recursive to show or hide elements found in subsizers. |
5886ce02 | 858 | |
788194ff | 859 | Returns @true if the child item was found, @false otherwise. |
3c4f71cc | 860 | |
788194ff | 861 | @see Hide(), IsShown() |
5886ce02 | 862 | */ |
788194ff FM |
863 | bool Show(wxWindow* window, bool show = true, |
864 | bool recursive = false); | |
3c4f71cc | 865 | |
5886ce02 | 866 | /** |
788194ff FM |
867 | Shows or hides @a sizer. |
868 | To make a sizer item disappear or reappear, use Show() followed by Layout(). | |
3c4f71cc | 869 | |
788194ff | 870 | Use parameter @a recursive to show or hide elements found in subsizers. |
3c4f71cc | 871 | |
788194ff | 872 | Returns @true if the child item was found, @false otherwise. |
3c4f71cc | 873 | |
788194ff | 874 | @see Hide(), IsShown() |
5886ce02 | 875 | */ |
788194ff FM |
876 | bool Show(wxSizer* sizer, bool show = true, |
877 | bool recursive = false); | |
3c4f71cc | 878 | |
5886ce02 | 879 | /** |
788194ff FM |
880 | Shows the item at @a index. |
881 | To make a sizer item disappear or reappear, use Show() followed by Layout(). | |
3c4f71cc | 882 | |
788194ff | 883 | Returns @true if the child item was found, @false otherwise. |
3c4f71cc | 884 | |
788194ff | 885 | @see Hide(), IsShown() |
23324ae1 | 886 | */ |
788194ff FM |
887 | bool Show(size_t index, bool show = true); |
888 | }; | |
5886ce02 | 889 | |
5886ce02 | 890 | |
788194ff FM |
891 | /** |
892 | @class wxStdDialogButtonSizer | |
5886ce02 | 893 | |
788194ff FM |
894 | This class creates button layouts which conform to the standard button spacing |
895 | and ordering defined by the platform or toolkit's user interface guidelines | |
896 | (if such things exist). By using this class, you can ensure that all your | |
897 | standard dialogs look correct on all major platforms. Currently it conforms to | |
898 | the Windows, GTK+ and Mac OS X human interface guidelines. | |
5886ce02 | 899 | |
788194ff FM |
900 | When there aren't interface guidelines defined for a particular platform or |
901 | toolkit, wxStdDialogButtonSizer reverts to the Windows implementation. | |
23324ae1 | 902 | |
788194ff FM |
903 | To use this class, first add buttons to the sizer by calling |
904 | wxStdDialogButtonSizer::AddButton (or wxStdDialogButtonSizer::SetAffirmativeButton, | |
905 | wxStdDialogButtonSizer::SetNegativeButton or wxStdDialogButtonSizer::SetCancelButton) | |
906 | and then call Realize in order to create the actual button layout used. | |
907 | Other than these special operations, this sizer works like any other sizer. | |
23324ae1 | 908 | |
788194ff FM |
909 | If you add a button with wxID_SAVE, on Mac OS X the button will be renamed to |
910 | "Save" and the wxID_NO button will be renamed to "Don't Save" in accordance | |
911 | with the Mac OS X Human Interface Guidelines. | |
912 | ||
913 | @library{wxcore} | |
914 | @category{winlayout} | |
23324ae1 | 915 | |
788194ff FM |
916 | @see wxSizer, @ref overview_sizer, wxDialog::CreateButtonSizer |
917 | */ | |
918 | class wxStdDialogButtonSizer : public wxBoxSizer | |
919 | { | |
920 | public: | |
23324ae1 | 921 | /** |
788194ff | 922 | Constructor for a wxStdDialogButtonSizer. |
23324ae1 | 923 | */ |
788194ff | 924 | wxStdDialogButtonSizer(); |
23324ae1 FM |
925 | |
926 | /** | |
788194ff FM |
927 | Adds a button to the wxStdDialogButtonSizer. The @a button must have |
928 | one of the following identifiers: | |
929 | - wxID_OK | |
930 | - wxID_YES | |
931 | - wxID_SAVE | |
932 | - wxID_APPLY | |
933 | - wxID_CLOSE | |
934 | - wxID_NO | |
935 | - wxID_CANCEL | |
936 | - wxID_HELP | |
937 | - wxID_CONTEXT_HELP | |
23324ae1 | 938 | */ |
788194ff | 939 | void AddButton(wxButton* button); |
23324ae1 FM |
940 | |
941 | /** | |
788194ff FM |
942 | Rearranges the buttons and applies proper spacing between buttons to make |
943 | them match the platform or toolkit's interface guidelines. | |
23324ae1 | 944 | */ |
788194ff | 945 | void Realize(); |
23324ae1 FM |
946 | |
947 | /** | |
788194ff | 948 | Sets the affirmative button for the sizer. |
491a5ece | 949 | |
788194ff FM |
950 | This allows you to use identifiers other than the standard identifiers |
951 | outlined above. | |
23324ae1 | 952 | */ |
788194ff | 953 | void SetAffirmativeButton(wxButton* button); |
23324ae1 | 954 | |
23324ae1 | 955 | /** |
788194ff | 956 | Sets the cancel button for the sizer. |
3c4f71cc | 957 | |
788194ff FM |
958 | This allows you to use identifiers other than the standard identifiers |
959 | outlined above. | |
23324ae1 | 960 | */ |
788194ff | 961 | void SetCancelButton(wxButton* button); |
1c340cc6 RR |
962 | |
963 | /** | |
788194ff | 964 | Sets the negative button for the sizer. |
98ccd545 | 965 | |
788194ff FM |
966 | This allows you to use identifiers other than the standard identifiers |
967 | outlined above. | |
1c340cc6 | 968 | */ |
788194ff FM |
969 | void SetNegativeButton(wxButton* button); |
970 | }; | |
98ccd545 | 971 | |
1c340cc6 | 972 | |
23324ae1 | 973 | |
788194ff FM |
974 | /** |
975 | @class wxSizerItem | |
e725ba4f | 976 | |
788194ff FM |
977 | The wxSizerItem class is used to track the position, size and other |
978 | attributes of each item managed by a wxSizer. | |
3c4f71cc | 979 | |
788194ff FM |
980 | It is not usually necessary to use this class because the sizer elements can |
981 | also be identified by their positions or window or sizer pointers but sometimes | |
982 | it may be more convenient to use it directly. | |
23324ae1 | 983 | |
788194ff FM |
984 | @library{wxcore} |
985 | @category{winlayout} | |
986 | */ | |
987 | class wxSizerItem : public wxObject | |
988 | { | |
989 | public: | |
23324ae1 | 990 | /** |
788194ff | 991 | Construct a sizer item for tracking a spacer. |
23324ae1 | 992 | */ |
788194ff FM |
993 | wxSizerItem(int width, int height, int proportion, int flag, |
994 | int border, wxObject* userData); | |
23324ae1 | 995 | |
e725ba4f | 996 | //@{ |
23324ae1 | 997 | /** |
788194ff | 998 | Construct a sizer item for tracking a window. |
1c340cc6 | 999 | */ |
788194ff FM |
1000 | wxSizerItem(wxWindow* window, const wxSizerFlags& flags); |
1001 | wxSizerItem(wxWindow* window, int proportion, int flag, | |
1002 | int border, | |
1003 | wxObject* userData); | |
e725ba4f | 1004 | //@} |
23324ae1 | 1005 | |
788194ff | 1006 | //@{ |
23324ae1 | 1007 | /** |
788194ff | 1008 | Construct a sizer item for tracking a subsizer. |
23324ae1 | 1009 | */ |
788194ff FM |
1010 | wxSizerItem(wxSizer* window, const wxSizerFlags& flags); |
1011 | wxSizerItem(wxSizer* sizer, int proportion, int flag, | |
1012 | int border, | |
1013 | wxObject* userData); | |
1014 | //@} | |
23324ae1 | 1015 | |
6b527e15 | 1016 | /** |
788194ff | 1017 | Deletes the user data and subsizer, if any. |
6b527e15 | 1018 | */ |
788194ff | 1019 | virtual ~wxSizerItem(); |
2f39b5a3 | 1020 | |
16e40259 VZ |
1021 | /** |
1022 | Set the window to be tracked by this item. | |
1023 | ||
1024 | The old window isn't deleted as it is now owned by the sizer item. | |
1025 | */ | |
1026 | void AssignWindow(wxWindow *window); | |
1027 | ||
1028 | /** | |
1029 | Set the sizer tracked by this item. | |
1030 | ||
1031 | Old sizer, if any, is deleted. | |
1032 | */ | |
1033 | void AssignSizer(wxSizer *sizer); | |
1034 | ||
1035 | //@{ | |
1036 | /** | |
1037 | Set the size of the spacer tracked by this item. | |
1038 | ||
1039 | Old spacer, if any, is deleted. | |
1040 | */ | |
1041 | void AssignSpacer(const wxSize& size); | |
1042 | void AssignSpacer(int w, int h) { AssignSpacer(wxSize(w, h)); } | |
1043 | //@} | |
1044 | ||
23324ae1 | 1045 | /** |
788194ff FM |
1046 | Calculates the minimum desired size for the item, including any space |
1047 | needed by borders. | |
23324ae1 | 1048 | */ |
788194ff | 1049 | virtual wxSize CalcMin(); |
98ccd545 | 1050 | |
cbf2bf6a | 1051 | /** |
788194ff FM |
1052 | Destroy the window or the windows in a subsizer, depending on the type |
1053 | of item. | |
cbf2bf6a | 1054 | */ |
788194ff | 1055 | virtual void DeleteWindows(); |
e725ba4f | 1056 | |
cbf2bf6a | 1057 | /** |
788194ff | 1058 | Enable deleting the SizerItem without destroying the contained sizer. |
cbf2bf6a | 1059 | */ |
788194ff | 1060 | void DetachSizer(); |
23324ae1 FM |
1061 | |
1062 | /** | |
788194ff | 1063 | Return the border attribute. |
23324ae1 | 1064 | */ |
788194ff | 1065 | int GetBorder() const; |
23324ae1 FM |
1066 | |
1067 | /** | |
788194ff | 1068 | Return the flags attribute. |
e725ba4f | 1069 | |
788194ff | 1070 | See @ref wxsizer_flags "wxSizer flags list" for details. |
23324ae1 | 1071 | */ |
788194ff | 1072 | int GetFlag() const; |
23324ae1 FM |
1073 | |
1074 | /** | |
788194ff FM |
1075 | Return the numeric id of wxSizerItem, or @c wxID_NONE if the id has |
1076 | not been set. | |
23324ae1 | 1077 | */ |
788194ff | 1078 | int GetId() const; |
23324ae1 FM |
1079 | |
1080 | /** | |
788194ff | 1081 | Get the minimum size needed for the item. |
23324ae1 | 1082 | */ |
788194ff | 1083 | wxSize GetMinSize() const; |
23324ae1 | 1084 | |
23324ae1 | 1085 | /** |
788194ff | 1086 | Sets the minimum size to be allocated for this item. |
98ccd545 | 1087 | |
788194ff FM |
1088 | If this item is a window, the @a size is also passed to |
1089 | wxWindow::SetMinSize(). | |
1090 | */ | |
1091 | void SetMinSize(const wxSize& size); | |
98ccd545 | 1092 | |
788194ff FM |
1093 | /** |
1094 | @overload | |
1095 | */ | |
1096 | void SetMinSize(int x, int y); | |
3c4f71cc | 1097 | |
788194ff FM |
1098 | /** |
1099 | What is the current position of the item, as set in the last Layout. | |
23324ae1 | 1100 | */ |
788194ff | 1101 | wxPoint GetPosition() const; |
1c340cc6 RR |
1102 | |
1103 | /** | |
788194ff | 1104 | Get the proportion item attribute. |
1c340cc6 | 1105 | */ |
788194ff | 1106 | int GetProportion() const; |
1c340cc6 RR |
1107 | |
1108 | /** | |
788194ff FM |
1109 | Get the ration item attribute. |
1110 | */ | |
1111 | float GetRatio() const; | |
1c340cc6 | 1112 | |
788194ff FM |
1113 | /** |
1114 | Get the rectangle of the item on the parent window, excluding borders. | |
1c340cc6 | 1115 | */ |
788194ff | 1116 | virtual wxRect GetRect(); |
23324ae1 | 1117 | |
23324ae1 | 1118 | /** |
788194ff FM |
1119 | Get the current size of the item, as set in the last Layout. |
1120 | */ | |
1121 | virtual wxSize GetSize() const; | |
3c4f71cc | 1122 | |
788194ff FM |
1123 | /** |
1124 | If this item is tracking a sizer, return it. @NULL otherwise. | |
23324ae1 | 1125 | */ |
788194ff | 1126 | wxSizer* GetSizer() const; |
1c340cc6 RR |
1127 | |
1128 | /** | |
788194ff FM |
1129 | If this item is tracking a spacer, return its size. |
1130 | */ | |
1131 | wxSize GetSpacer() const; | |
1c340cc6 | 1132 | |
788194ff FM |
1133 | /** |
1134 | Get the userData item attribute. | |
1c340cc6 | 1135 | */ |
788194ff | 1136 | wxObject* GetUserData() const; |
1c340cc6 RR |
1137 | |
1138 | /** | |
788194ff | 1139 | If this item is tracking a window then return it. @NULL otherwise. |
1c340cc6 | 1140 | */ |
788194ff | 1141 | wxWindow* GetWindow() const; |
1c340cc6 RR |
1142 | |
1143 | /** | |
788194ff FM |
1144 | Returns @true if this item is a window or a spacer and it is shown or |
1145 | if this item is a sizer and not all of its elements are hidden. | |
1c340cc6 | 1146 | |
788194ff FM |
1147 | In other words, for sizer items, all of the child elements must be |
1148 | hidden for the sizer itself to be considered hidden. | |
1149 | ||
1150 | As an exception, if the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was | |
1151 | used for this sizer item, then IsShown() always returns @true for it | |
1152 | (see wxSizerFlags::ReserveSpaceEvenIfHidden()). | |
1c340cc6 | 1153 | */ |
788194ff | 1154 | bool IsShown() const; |
1c340cc6 RR |
1155 | |
1156 | /** | |
788194ff | 1157 | Is this item a sizer? |
1c340cc6 | 1158 | */ |
788194ff | 1159 | bool IsSizer() const; |
23324ae1 FM |
1160 | |
1161 | /** | |
788194ff | 1162 | Is this item a spacer? |
23324ae1 | 1163 | */ |
788194ff | 1164 | bool IsSpacer() const; |
23324ae1 FM |
1165 | |
1166 | /** | |
788194ff | 1167 | Is this item a window? |
23324ae1 | 1168 | */ |
788194ff | 1169 | bool IsWindow() const; |
23324ae1 | 1170 | |
6e1f851b | 1171 | /** |
788194ff FM |
1172 | Set the border item attribute. |
1173 | */ | |
1174 | void SetBorder(int border); | |
6e1f851b | 1175 | |
23324ae1 | 1176 | /** |
788194ff FM |
1177 | Set the position and size of the space allocated to the sizer, and |
1178 | adjust the position and size of the item to be within that space | |
1179 | taking alignment and borders into account. | |
23324ae1 | 1180 | */ |
788194ff | 1181 | virtual void SetDimension(const wxPoint& pos, const wxSize& size); |
01195a1b VS |
1182 | |
1183 | /** | |
788194ff | 1184 | Set the flag item attribute. |
01195a1b | 1185 | */ |
788194ff | 1186 | void SetFlag(int flag); |
01195a1b VS |
1187 | |
1188 | /** | |
788194ff FM |
1189 | Sets the numeric id of the wxSizerItem to @e id. |
1190 | */ | |
1191 | void SetId(int id); | |
01195a1b | 1192 | |
788194ff FM |
1193 | /** |
1194 | @todo docme. | |
01195a1b | 1195 | */ |
788194ff | 1196 | void SetInitSize(int x, int y); |
23324ae1 FM |
1197 | |
1198 | /** | |
788194ff | 1199 | Set the proportion item attribute. |
23324ae1 | 1200 | */ |
788194ff | 1201 | void SetProportion(int proportion); |
23324ae1 | 1202 | |
788194ff | 1203 | //@{ |
23324ae1 | 1204 | /** |
788194ff | 1205 | Set the ratio item attribute. |
23324ae1 | 1206 | */ |
788194ff FM |
1207 | void SetRatio(int width, int height); |
1208 | void SetRatio(wxSize size); | |
1209 | void SetRatio(float ratio); | |
1210 | //@} | |
5886ce02 VS |
1211 | |
1212 | /** | |
788194ff | 1213 | Set the sizer tracked by this item. |
16e40259 VZ |
1214 | |
1215 | @deprecated This function does not free the old sizer which may result | |
1216 | in memory leaks, use AssignSizer() which does free it instead. | |
5886ce02 | 1217 | */ |
788194ff | 1218 | void SetSizer(wxSizer* sizer); |
5886ce02 VS |
1219 | |
1220 | /** | |
788194ff | 1221 | Set the size of the spacer tracked by this item. |
16e40259 VZ |
1222 | |
1223 | @deprecated This function does not free the old spacer which may result | |
1224 | in memory leaks, use AssignSpacer() which does free it instead. | |
5886ce02 | 1225 | */ |
788194ff | 1226 | void SetSpacer(const wxSize& size); |
5886ce02 VS |
1227 | |
1228 | /** | |
788194ff FM |
1229 | Set the window to be tracked by this item. |
1230 | @deprecated @todo provide deprecation description | |
5886ce02 | 1231 | */ |
788194ff | 1232 | void SetWindow(wxWindow* window); |
5886ce02 VS |
1233 | |
1234 | /** | |
788194ff FM |
1235 | Set the show item attribute, which sizers use to determine if the item |
1236 | is to be made part of the layout or not. If the item is tracking a | |
1237 | window then it is shown or hidden as needed. | |
5886ce02 | 1238 | */ |
788194ff FM |
1239 | void Show(bool show); |
1240 | }; | |
1241 | ||
1242 | ||
23324ae1 | 1243 | |
788194ff FM |
1244 | /** |
1245 | @class wxSizerFlags | |
1246 | ||
1247 | Container for sizer items flags providing readable names for them. | |
1248 | ||
1249 | Normally, when you add an item to a sizer via wxSizer::Add, you have to | |
1250 | specify a lot of flags and parameters which can be unwieldy. This is where | |
1251 | wxSizerFlags comes in: it allows you to specify all parameters using the | |
1252 | named methods instead. For example, instead of | |
1253 | ||
1254 | @code | |
1255 | sizer->Add(ctrl, 0, wxEXPAND | wxALL, 10); | |
1256 | @endcode | |
1257 | ||
1258 | you can now write | |
1259 | ||
1260 | @code | |
1261 | sizer->Add(ctrl, wxSizerFlags().Expand().Border(wxALL, 10)); | |
1262 | @endcode | |
1263 | ||
1264 | This is more readable and also allows you to create wxSizerFlags objects which | |
1265 | can be reused for several sizer items. | |
1266 | ||
1267 | @code | |
1268 | wxSizerFlags flagsExpand(1); | |
1269 | flagsExpand.Expand().Border(wxALL, 10); | |
1270 | ||
1271 | sizer->Add(ctrl1, flagsExpand); | |
1272 | sizer->Add(ctrl2, flagsExpand); | |
1273 | @endcode | |
1274 | ||
1275 | Note that by specification, all methods of wxSizerFlags return the wxSizerFlags | |
1276 | object itself to allowing chaining multiple methods calls like in the examples | |
1277 | above. | |
1278 | ||
1279 | @library{wxcore} | |
1280 | @category{winlayout} | |
1281 | ||
1282 | @see wxSizer | |
1283 | */ | |
1284 | class wxSizerFlags | |
1285 | { | |
1286 | public: | |
23324ae1 | 1287 | /** |
788194ff | 1288 | Creates the wxSizer with the proportion specified by @a proportion. |
23324ae1 | 1289 | */ |
788194ff | 1290 | wxSizerFlags(int proportion = 0); |
23324ae1 FM |
1291 | |
1292 | /** | |
788194ff FM |
1293 | Sets the alignment of this wxSizerFlags to @a align. |
1294 | ||
1295 | This method replaces the previously set alignment with the specified one. | |
1296 | ||
1297 | @param alignment | |
1298 | Combination of @c wxALIGN_XXX bit masks. | |
1299 | ||
1300 | @see Top(), Left(), Right(), Bottom(), Centre() | |
23324ae1 | 1301 | */ |
788194ff | 1302 | wxSizerFlags& Align(int alignment); |
23324ae1 FM |
1303 | |
1304 | /** | |
788194ff FM |
1305 | Sets the wxSizerFlags to have a border of a number of pixels specified |
1306 | by @a borderinpixels with the directions specified by @a direction. | |
23324ae1 | 1307 | */ |
788194ff | 1308 | wxSizerFlags& Border(int direction, int borderinpixels); |
23324ae1 | 1309 | |
23324ae1 | 1310 | /** |
788194ff FM |
1311 | Sets the wxSizerFlags to have a border with size as returned by |
1312 | GetDefaultBorder(). | |
5886ce02 | 1313 | |
788194ff FM |
1314 | @param direction |
1315 | Direction(s) to apply the border in. | |
1316 | */ | |
1317 | wxSizerFlags& Border(int direction = wxALL); | |
5886ce02 | 1318 | |
788194ff FM |
1319 | /** |
1320 | Aligns the object to the bottom, similar for @c Align(wxALIGN_BOTTOM). | |
5886ce02 | 1321 | |
788194ff FM |
1322 | Unlike Align(), this method doesn't change the horizontal alignment of |
1323 | the item. | |
23324ae1 | 1324 | */ |
788194ff | 1325 | wxSizerFlags& Bottom(); |
5886ce02 VS |
1326 | |
1327 | /** | |
788194ff FM |
1328 | Sets the object of the wxSizerFlags to center itself in the area it is |
1329 | given. | |
1330 | */ | |
1331 | wxSizerFlags& Center(); | |
5886ce02 | 1332 | |
788194ff FM |
1333 | /** |
1334 | Center() for people with the other dialect of English. | |
1335 | */ | |
1336 | wxSizerFlags& Centre(); | |
5886ce02 | 1337 | |
788194ff FM |
1338 | /** |
1339 | Sets the border in the given @a direction having twice the default | |
1340 | border size. | |
1341 | */ | |
1342 | wxSizerFlags& DoubleBorder(int direction = wxALL); | |
5886ce02 | 1343 | |
788194ff FM |
1344 | /** |
1345 | Sets the border in left and right directions having twice the default | |
1346 | border size. | |
5886ce02 | 1347 | */ |
788194ff | 1348 | wxSizerFlags& DoubleHorzBorder(); |
5886ce02 VS |
1349 | |
1350 | /** | |
788194ff FM |
1351 | Sets the object of the wxSizerFlags to expand to fill as much area as |
1352 | it can. | |
1353 | */ | |
1354 | wxSizerFlags& Expand(); | |
5886ce02 | 1355 | |
788194ff FM |
1356 | /** |
1357 | Set the @c wxFIXED_MINSIZE flag which indicates that the initial size | |
1358 | of the window should be also set as its minimal size. | |
1359 | */ | |
1360 | wxSizerFlags& FixedMinSize(); | |
5886ce02 | 1361 | |
788194ff FM |
1362 | /** |
1363 | Set the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag. Normally wxSizers | |
1364 | don't allocate space for hidden windows or other items. This flag | |
1365 | overrides this behavior so that sufficient space is allocated for the | |
1366 | window even if it isn't visible. This makes it possible to dynamically | |
1367 | show and hide controls without resizing parent dialog, for example. | |
5886ce02 | 1368 | |
788194ff | 1369 | @since 2.8.8 |
5886ce02 | 1370 | */ |
788194ff | 1371 | wxSizerFlags& ReserveSpaceEvenIfHidden(); |
23324ae1 | 1372 | |
23324ae1 | 1373 | /** |
788194ff FM |
1374 | Returns the border used by default in Border() method. |
1375 | */ | |
1376 | static int GetDefaultBorder(); | |
3c4f71cc | 1377 | |
788194ff FM |
1378 | /** |
1379 | Aligns the object to the left, similar for @c Align(wxALIGN_LEFT). | |
98ccd545 | 1380 | |
788194ff FM |
1381 | Unlike Align(), this method doesn't change the vertical alignment of |
1382 | the item. | |
23324ae1 | 1383 | */ |
788194ff | 1384 | wxSizerFlags& Left(); |
98ccd545 | 1385 | |
1c340cc6 | 1386 | /** |
788194ff FM |
1387 | Sets the proportion of this wxSizerFlags to @e proportion |
1388 | */ | |
1389 | wxSizerFlags& Proportion(int proportion); | |
1c340cc6 | 1390 | |
788194ff FM |
1391 | /** |
1392 | Aligns the object to the right, similar for @c Align(wxALIGN_RIGHT). | |
98ccd545 | 1393 | |
788194ff FM |
1394 | Unlike Align(), this method doesn't change the vertical alignment of |
1395 | the item. | |
1c340cc6 | 1396 | */ |
788194ff | 1397 | wxSizerFlags& Right(); |
98ccd545 | 1398 | |
1c340cc6 | 1399 | /** |
788194ff FM |
1400 | Set the @c wx_SHAPED flag which indicates that the elements should |
1401 | always keep the fixed width to height ratio equal to its original value. | |
1402 | */ | |
1403 | wxSizerFlags& Shaped(); | |
98ccd545 | 1404 | |
788194ff FM |
1405 | /** |
1406 | Aligns the object to the top, similar for @c Align(wxALIGN_TOP). | |
98ccd545 | 1407 | |
788194ff FM |
1408 | Unlike Align(), this method doesn't change the horizontal alignment of |
1409 | the item. | |
1c340cc6 | 1410 | */ |
788194ff | 1411 | wxSizerFlags& Top(); |
23324ae1 FM |
1412 | |
1413 | /** | |
788194ff FM |
1414 | Sets the border in the given @a direction having thrice the default |
1415 | border size. | |
23324ae1 | 1416 | */ |
788194ff FM |
1417 | wxSizerFlags& TripleBorder(int direction = wxALL); |
1418 | }; | |
98ccd545 | 1419 | |
23324ae1 | 1420 | |
52ceb90e FM |
1421 | /** |
1422 | Values which define the behaviour for resizing wxFlexGridSizer cells in the | |
1423 | "non-flexible" direction. | |
1424 | */ | |
1425 | enum wxFlexSizerGrowMode | |
1426 | { | |
1427 | /// Don't resize the cells in non-flexible direction at all. | |
1428 | wxFLEX_GROWMODE_NONE, | |
1429 | ||
1430 | /// Uniformly resize only the specified ones (default). | |
1431 | wxFLEX_GROWMODE_SPECIFIED, | |
1432 | ||
1433 | /// Uniformly resize all cells. | |
1434 | wxFLEX_GROWMODE_ALL | |
1435 | }; | |
1436 | ||
788194ff FM |
1437 | /** |
1438 | @class wxFlexGridSizer | |
7e927914 | 1439 | |
788194ff FM |
1440 | A flex grid sizer is a sizer which lays out its children in a two-dimensional |
1441 | table with all table fields in one row having the same height and all fields | |
1442 | in one column having the same width, but all rows or all columns are not | |
1443 | necessarily the same height or width as in the wxGridSizer. | |
1444 | ||
1445 | Since wxWidgets 2.5.0, wxFlexGridSizer can also size items equally in one | |
1446 | direction but unequally ("flexibly") in the other. If the sizer is only | |
1447 | flexible in one direction (this can be changed using wxFlexGridSizer::SetFlexibleDirection), | |
1448 | it needs to be decided how the sizer should grow in the other ("non-flexible") | |
1449 | direction in order to fill the available space. | |
1450 | The wxFlexGridSizer::SetNonFlexibleGrowMode() method serves this purpose. | |
1c340cc6 | 1451 | |
788194ff FM |
1452 | @library{wxcore} |
1453 | @category{winlayout} | |
1454 | ||
1455 | @see wxSizer, @ref overview_sizer | |
1456 | */ | |
1457 | class wxFlexGridSizer : public wxGridSizer | |
1458 | { | |
1459 | public: | |
1460 | //@{ | |
1c340cc6 | 1461 | /** |
4a00e77c | 1462 | wxFlexGridSizer constructors. |
1c340cc6 | 1463 | |
61503542 | 1464 | Please see wxGridSizer::wxGridSizer documentation. |
4a00e77c VZ |
1465 | |
1466 | @since 2.9.1 (except for the four argument overload) | |
1c340cc6 | 1467 | */ |
d7bb2926 | 1468 | wxFlexGridSizer( int cols, int vgap, int hgap ); |
4a00e77c VZ |
1469 | wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); |
1470 | ||
1471 | wxFlexGridSizer( int rows, int cols, int vgap, int hgap ); | |
1472 | wxFlexGridSizer( int rows, int cols, const wxSize& gap ); | |
788194ff | 1473 | //@} |
1c340cc6 RR |
1474 | |
1475 | /** | |
788194ff FM |
1476 | Specifies that column @a idx (starting from zero) should be grown if |
1477 | there is extra space available to the sizer. | |
1c340cc6 | 1478 | |
788194ff | 1479 | The @a proportion parameter has the same meaning as the stretch factor |
a008d6e5 FM |
1480 | for the sizers (see wxBoxSizer) except that if all proportions are 0, |
1481 | then all columns are resized equally (instead of not being resized at all). | |
1c340cc6 | 1482 | |
a008d6e5 | 1483 | Notice that the column must not be already growable, if you need to change |
788194ff FM |
1484 | the proportion you must call RemoveGrowableCol() first and then make it |
1485 | growable (with a different proportion) again. You can use IsColGrowable() | |
1486 | to check whether a column is already growable. | |
1c340cc6 | 1487 | */ |
788194ff | 1488 | void AddGrowableCol(size_t idx, int proportion = 0); |
23324ae1 | 1489 | |
23324ae1 | 1490 | /** |
788194ff FM |
1491 | Specifies that row idx (starting from zero) should be grown if there |
1492 | is extra space available to the sizer. | |
e725ba4f | 1493 | |
788194ff FM |
1494 | This is identical to AddGrowableCol() except that it works with rows |
1495 | and not columns. | |
23324ae1 | 1496 | */ |
788194ff | 1497 | void AddGrowableRow(size_t idx, int proportion = 0); |
23324ae1 FM |
1498 | |
1499 | /** | |
a008d6e5 | 1500 | Returns a ::wxOrientation value that specifies whether the sizer flexibly |
788194ff | 1501 | resizes its columns, rows, or both (default). |
e725ba4f | 1502 | |
788194ff FM |
1503 | @return |
1504 | One of the following values: | |
1505 | - wxVERTICAL: Rows are flexibly sized. | |
1506 | - wxHORIZONTAL: Columns are flexibly sized. | |
1507 | - wxBOTH: Both rows and columns are flexibly sized (this is the default value). | |
e725ba4f | 1508 | |
788194ff | 1509 | @see SetFlexibleDirection() |
23324ae1 | 1510 | */ |
788194ff | 1511 | int GetFlexibleDirection() const; |
23324ae1 FM |
1512 | |
1513 | /** | |
788194ff FM |
1514 | Returns the value that specifies how the sizer grows in the "non-flexible" |
1515 | direction if there is one. | |
3c4f71cc | 1516 | |
788194ff | 1517 | The behaviour of the elements in the flexible direction (i.e. both rows |
a008d6e5 FM |
1518 | and columns by default, or rows only if GetFlexibleDirection() is |
1519 | @c wxVERTICAL or columns only if it is @c wxHORIZONTAL) is always governed | |
788194ff FM |
1520 | by their proportion as specified in the call to AddGrowableRow() or |
1521 | AddGrowableCol(). What happens in the other direction depends on the | |
1522 | value of returned by this function as described below. | |
e725ba4f | 1523 | |
788194ff FM |
1524 | @return |
1525 | One of the following values: | |
1526 | - wxFLEX_GROWMODE_NONE: Sizer doesn't grow its elements at all in | |
1527 | the non-flexible direction. | |
1528 | - wxFLEX_GROWMODE_SPECIFIED: Sizer honors growable columns/rows set | |
1529 | with AddGrowableCol() and AddGrowableRow() in the non-flexible | |
1530 | direction as well. In this case equal sizing applies to minimum | |
1531 | sizes of columns or rows (this is the default value). | |
1532 | - wxFLEX_GROWMODE_ALL: Sizer equally stretches all columns or rows in | |
1533 | the non-flexible direction, independently of the proportions | |
1534 | applied in the flexible direction. | |
1535 | ||
1536 | @see SetFlexibleDirection(), SetNonFlexibleGrowMode() | |
23324ae1 | 1537 | */ |
788194ff | 1538 | wxFlexSizerGrowMode GetNonFlexibleGrowMode() const; |
23324ae1 | 1539 | |
23324ae1 | 1540 | /** |
788194ff | 1541 | Returns @true if column @a idx is growable. |
98ccd545 | 1542 | |
788194ff FM |
1543 | @since 2.9.0 |
1544 | */ | |
1545 | bool IsColGrowable(size_t idx); | |
98ccd545 | 1546 | |
788194ff FM |
1547 | /** |
1548 | Returns @true if row @a idx is growable. | |
3c4f71cc | 1549 | |
788194ff | 1550 | @since 2.9.0 |
23324ae1 | 1551 | */ |
788194ff | 1552 | bool IsRowGrowable(size_t idx); |
1c340cc6 RR |
1553 | |
1554 | /** | |
a008d6e5 | 1555 | Specifies that the @a idx column index is no longer growable. |
788194ff FM |
1556 | */ |
1557 | void RemoveGrowableCol(size_t idx); | |
98ccd545 | 1558 | |
788194ff | 1559 | /** |
a008d6e5 | 1560 | Specifies that the @a idx row index is no longer growable. |
788194ff FM |
1561 | */ |
1562 | void RemoveGrowableRow(size_t idx); | |
98ccd545 | 1563 | |
788194ff FM |
1564 | /** |
1565 | Specifies whether the sizer should flexibly resize its columns, rows, or both. | |
1c340cc6 | 1566 | |
788194ff FM |
1567 | Argument @a direction can be @c wxVERTICAL, @c wxHORIZONTAL or @c wxBOTH |
1568 | (which is the default value). Any other value is ignored. | |
a008d6e5 | 1569 | |
788194ff FM |
1570 | See GetFlexibleDirection() for the explanation of these values. |
1571 | Note that this method does not trigger relayout. | |
1c340cc6 | 1572 | */ |
788194ff | 1573 | void SetFlexibleDirection(int direction); |
1c340cc6 RR |
1574 | |
1575 | /** | |
788194ff FM |
1576 | Specifies how the sizer should grow in the non-flexible direction if |
1577 | there is one (so SetFlexibleDirection() must have been called previously). | |
1c340cc6 | 1578 | |
788194ff FM |
1579 | Argument @a mode can be one of those documented in GetNonFlexibleGrowMode(), |
1580 | please see there for their explanation. | |
1581 | Note that this method does not trigger relayout. | |
1c340cc6 | 1582 | */ |
788194ff | 1583 | void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode); |
23324ae1 FM |
1584 | }; |
1585 | ||
1586 | ||
1587 | /** | |
1588 | @class wxGridSizer | |
7c913512 | 1589 | |
23324ae1 | 1590 | A grid sizer is a sizer which lays out its children in a two-dimensional |
e725ba4f FM |
1591 | table with all table fields having the same size, i.e. the width of each |
1592 | field is the width of the widest child, the height of each field is the | |
1593 | height of the tallest child. | |
7c913512 | 1594 | |
23324ae1 FM |
1595 | @library{wxcore} |
1596 | @category{winlayout} | |
7c913512 | 1597 | |
e725ba4f | 1598 | @see wxSizer, @ref overview_sizer |
23324ae1 FM |
1599 | */ |
1600 | class wxGridSizer : public wxSizer | |
1601 | { | |
1602 | public: | |
1603 | //@{ | |
1604 | /** | |
7e6edd27 | 1605 | wxGridSizer constructors. |
e725ba4f | 1606 | |
61503542 | 1607 | Usually only the number of columns in the flex grid sizer needs to be |
7e6edd27 VZ |
1608 | specified using @a cols argument. The number of rows will be deduced |
1609 | automatically depending on the number of the elements added to the | |
61503542 VZ |
1610 | sizer. |
1611 | ||
1612 | If a constructor form with @a rows parameter is used (and the value of | |
1613 | @a rows argument is not zero, meaning "unspecified") the sizer will | |
1614 | check that no more than @c cols*rows elements are added to it, i.e. | |
1615 | that no more than the given number of @a rows is used. Adding less than | |
1616 | maximally allowed number of items is not an error however. | |
e725ba4f | 1617 | |
61503542 VZ |
1618 | Finally, it is also possible to specify the number of rows and use 0 |
1619 | for @a cols. In this case, the sizer will use the given fixed number of | |
1620 | rows and as many columns as necessary. | |
1621 | ||
1622 | The @a gap (or @a vgap and @a hgap, which correspond to the height and | |
1623 | width of the wxSize object) argument defines the size of the padding | |
1624 | between the rows (its vertical component, or @a vgap) and columns | |
7345d6c1 | 1625 | (its horizontal component, or @a hgap), in pixels. |
7e6edd27 | 1626 | |
61503542 | 1627 | |
7e6edd27 | 1628 | @since 2.9.1 (except for the four argument overload) |
23324ae1 | 1629 | */ |
7e6edd27 VZ |
1630 | wxGridSizer( int cols, int vgap, int hgap ); |
1631 | wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); | |
1632 | ||
1633 | wxGridSizer( int rows, int cols, int vgap, int hgap ); | |
1634 | wxGridSizer( int rows, int cols, const wxSize& gap ); | |
23324ae1 FM |
1635 | //@} |
1636 | ||
1637 | /** | |
0e92a846 | 1638 | Returns the number of columns that has been specified for the |
0274a797 VZ |
1639 | sizer. |
1640 | ||
1641 | Returns zero if the sizer is automatically adjusting the number of | |
0e92a846 RR |
1642 | columns depending on number of its children. To get the effective |
1643 | number of columns or rows being currently used, see GetEffectiveColsCount() | |
23324ae1 | 1644 | */ |
adaaa686 | 1645 | int GetCols() const; |
0e92a846 RR |
1646 | |
1647 | /** | |
1648 | Returns the number of rows that has been specified for the | |
1649 | sizer. | |
1650 | ||
1651 | Returns zero if the sizer is automatically adjusting the number of | |
1652 | rows depending on number of its children. To get the effective | |
1653 | number of columns or rows being currently used, see GetEffectiveRowsCount(). | |
1654 | */ | |
0274a797 | 1655 | int GetRows() const; |
23324ae1 FM |
1656 | |
1657 | /** | |
0e92a846 | 1658 | Returns the number of columns currently used by the sizer. |
0274a797 VZ |
1659 | |
1660 | This will depend on the number of children the sizer has if | |
1661 | the sizer is automatically adjusting the number of columns/rows. | |
1662 | ||
1663 | @since 2.9.1 | |
23324ae1 | 1664 | */ |
0274a797 | 1665 | int GetEffectiveColsCount() const; |
0e92a846 RR |
1666 | |
1667 | /** | |
1668 | Returns the number of rows currently used by the sizer. | |
1669 | ||
1670 | This will depend on the number of children the sizer has if | |
1671 | the sizer is automatically adjusting the number of columns/rows. | |
1672 | ||
1673 | @since 2.9.1 | |
1674 | */ | |
0274a797 | 1675 | int GetEffectiveRowsCount() const; |
23324ae1 FM |
1676 | |
1677 | /** | |
0274a797 | 1678 | Returns the horizontal gap (in pixels) between cells in the sizer. |
23324ae1 | 1679 | */ |
0274a797 | 1680 | int GetHGap() const; |
23324ae1 FM |
1681 | |
1682 | /** | |
1683 | Returns the vertical gap (in pixels) between the cells in the sizer. | |
1684 | */ | |
adaaa686 | 1685 | int GetVGap() const; |
23324ae1 FM |
1686 | |
1687 | /** | |
1688 | Sets the number of columns in the sizer. | |
1689 | */ | |
1690 | void SetCols(int cols); | |
1691 | ||
1692 | /** | |
1693 | Sets the horizontal gap (in pixels) between cells in the sizer. | |
1694 | */ | |
1695 | void SetHGap(int gap); | |
1696 | ||
1697 | /** | |
1698 | Sets the number of rows in the sizer. | |
1699 | */ | |
1700 | void SetRows(int rows); | |
1701 | ||
1702 | /** | |
1703 | Sets the vertical gap (in pixels) between the cells in the sizer. | |
1704 | */ | |
1705 | void SetVGap(int gap); | |
1706 | }; | |
1707 | ||
1708 | ||
e54c96f1 | 1709 | |
23324ae1 FM |
1710 | /** |
1711 | @class wxStaticBoxSizer | |
7c913512 | 1712 | |
338c3ec7 | 1713 | wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static box around |
f3289ffb FM |
1714 | the sizer. |
1715 | ||
338c3ec7 | 1716 | The static box may be either created independently or the sizer may create it |
f3289ffb FM |
1717 | itself as a convenience. In any case, the sizer owns the wxStaticBox control |
1718 | and will delete it in the wxStaticBoxSizer destructor. | |
338c3ec7 VZ |
1719 | |
1720 | Note that since wxWidgets 2.9.1 you are encouraged to create the windows | |
1721 | which are added to wxStaticBoxSizer as children of wxStaticBox itself, see | |
1722 | this class documentation for more details. | |
1723 | ||
1724 | Example of use of this class: | |
39cdc95f | 1725 | @code |
338c3ec7 VZ |
1726 | void MyFrame::CreateControls() |
1727 | { | |
1728 | wxPanel *panel = new wxPanel(this); | |
1729 | ... | |
1730 | wxStaticBoxSizer *sz = new wxStaticBoxSizer(wxVERTICAL, panel, "Box"); | |
1731 | sz->Add(new wxStaticText(sz->GetStaticBox(), wxID_ANY, | |
1732 | "This window is a child of the staticbox")); | |
1733 | ... | |
1734 | } | |
39cdc95f | 1735 | @endcode |
7c913512 | 1736 | |
23324ae1 FM |
1737 | @library{wxcore} |
1738 | @category{winlayout} | |
7c913512 | 1739 | |
98ccd545 | 1740 | @see wxSizer, wxStaticBox, wxBoxSizer, @ref overview_sizer |
23324ae1 FM |
1741 | */ |
1742 | class wxStaticBoxSizer : public wxBoxSizer | |
1743 | { | |
1744 | public: | |
23324ae1 | 1745 | /** |
e725ba4f FM |
1746 | This constructor uses an already existing static box. |
1747 | ||
f3289ffb FM |
1748 | @param box |
1749 | The static box to associate with the sizer (which will take its | |
1750 | ownership). | |
1751 | @param orient | |
1752 | Can be either @c wxVERTICAL or @c wxHORIZONTAL. | |
23324ae1 FM |
1753 | */ |
1754 | wxStaticBoxSizer(wxStaticBox* box, int orient); | |
e725ba4f FM |
1755 | |
1756 | /** | |
1757 | This constructor creates a new static box with the given label and parent window. | |
1758 | */ | |
11e3af6e | 1759 | wxStaticBoxSizer(int orient, wxWindow *parent, |
7c913512 | 1760 | const wxString& label = wxEmptyString); |
23324ae1 FM |
1761 | |
1762 | /** | |
1763 | Returns the static box associated with the sizer. | |
1764 | */ | |
18e8e19b | 1765 | wxStaticBox* GetStaticBox() const; |
23324ae1 FM |
1766 | }; |
1767 | ||
1768 | ||
e54c96f1 | 1769 | |
23324ae1 FM |
1770 | /** |
1771 | @class wxBoxSizer | |
7c913512 | 1772 | |
23324ae1 | 1773 | The basic idea behind a box sizer is that windows will most often be laid out |
e725ba4f FM |
1774 | in rather simple basic geometry, typically in a row or a column or several |
1775 | hierarchies of either. | |
7c913512 | 1776 | |
e725ba4f | 1777 | For more information, please see @ref overview_sizer_box. |
7c913512 | 1778 | |
23324ae1 FM |
1779 | @library{wxcore} |
1780 | @category{winlayout} | |
7c913512 | 1781 | |
e725ba4f | 1782 | @see wxSizer, @ref overview_sizer |
23324ae1 FM |
1783 | */ |
1784 | class wxBoxSizer : public wxSizer | |
1785 | { | |
1786 | public: | |
1787 | /** | |
4cc4bfaf | 1788 | Constructor for a wxBoxSizer. @a orient may be either of wxVERTICAL |
23324ae1 FM |
1789 | or wxHORIZONTAL for creating either a column sizer or a row sizer. |
1790 | */ | |
1791 | wxBoxSizer(int orient); | |
1792 | ||
1a2df6a7 VZ |
1793 | /** |
1794 | Adds non-stretchable space to the main orientation of the sizer only. | |
1795 | More readable way of calling: | |
1796 | @code | |
1797 | if ( wxBoxSizer::IsVertical() ) | |
1798 | { | |
1799 | wxBoxSizer::Add(0, size, 0). | |
1800 | } | |
1801 | else | |
1802 | { | |
1803 | wxBoxSizer::Add(size, 0, 0). | |
1804 | } | |
1805 | @endcode | |
1806 | */ | |
1807 | virtual wxSizerItem *AddSpacer(int size); | |
1808 | ||
23324ae1 | 1809 | /** |
e725ba4f FM |
1810 | Implements the calculation of a box sizer's minimal. |
1811 | ||
1812 | It is used internally only and must not be called by the user. | |
1813 | Documented for information. | |
23324ae1 | 1814 | */ |
98ccd545 | 1815 | virtual wxSize CalcMin(); |
23324ae1 FM |
1816 | |
1817 | /** | |
1818 | Returns the orientation of the box sizer, either wxVERTICAL | |
1819 | or wxHORIZONTAL. | |
1820 | */ | |
98ccd545 | 1821 | int GetOrientation() const; |
23324ae1 FM |
1822 | |
1823 | /** | |
1824 | Implements the calculation of a box sizer's dimensions and then sets | |
e725ba4f FM |
1825 | the size of its children (calling wxWindow::SetSize if the child is a window). |
1826 | ||
1827 | It is used internally only and must not be called by the user | |
1828 | (call Layout() if you want to resize). Documented for information. | |
23324ae1 FM |
1829 | */ |
1830 | void RecalcSizes(); | |
1831 | }; | |
e54c96f1 | 1832 |