]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_sizers.i
Added wx.ArtProvider.GetSize
[wxWidgets.git] / wxPython / src / _sizers.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _sizers.i
3// Purpose: SWIG interface defs for the Sizers
4//
5// Author: Robin Dunn
6//
7// Created: 18-Sept-1999
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17
18%{
19%}
20
21//---------------------------------------------------------------------------
22%newgroup;
23
3ea6e0ec
RD
24DocStr(wxSizerItem,
25"The wx.SizerItem class is used to track the position, size and other
26attributes of each item managed by a `wx.Sizer`. In normal usage user
27code should never need to deal directly with a wx.SizerItem, but
28custom classes derived from `wx.PySizer` will probably need to use the
29collection of wx.SizerItems held by wx.Sizer when calculating layout.
30
31:see: `wx.Sizer`, `wx.GBSizerItem`", "");
d14a1e28
RD
32
33class wxSizerItem : public wxObject {
34public:
3ea6e0ec
RD
35 DocCtorStr(
36 wxSizerItem(),
37 "Constructs an empty wx.SizerItem. Either a window, sizer or spacer
38size will need to be set before this item can be used in a Sizer.
39
40You will probably never need to create a wx.SizerItem directly as they
41are created automatically when the sizer's Add, Insert or Prepend
42methods are called.
43
44:see: `wx.SizerItemSpacer`, `wx.SizerItemWindow`, `wx.SizerItemSizer`", "");
45
46
7e8f0df9 47
3ea6e0ec
RD
48 %extend {
49 DocStr(
50 wxSizerItem( wxWindow *window, int proportion, int flag,
51 int border, PyObject* userData=NULL ),
7e8f0df9
RD
52 "Constructs a `wx.SizerItem` for tracking a window.", "");
53
1b8c7ba6
RD
54 %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, int flag,
55 int border, PyObject* userData=NULL ))
56 {
3ea6e0ec
RD
57 wxPyUserData* data = NULL;
58 if ( userData ) {
59 bool blocked = wxPyBeginBlockThreads();
60 data = new wxPyUserData(userData);
61 wxPyEndBlockThreads(blocked);
62 }
63 return new wxSizerItem(window, proportion, flag, border, data);
64 }
65
7e8f0df9 66
3ea6e0ec
RD
67 DocStr(
68 wxSizerItem( int width, int height, int proportion, int flag,
69 int border, PyObject* userData=NULL),
70 "Constructs a `wx.SizerItem` for tracking a spacer.", "");
7e8f0df9 71
1b8c7ba6
RD
72 %RenameCtor(SizerItemSpacer, wxSizerItem( int width, int height, int proportion, int flag,
73 int border, PyObject* userData=NULL))
74 {
3ea6e0ec
RD
75 wxPyUserData* data = NULL;
76 if ( userData ) {
77 bool blocked = wxPyBeginBlockThreads();
78 data = new wxPyUserData(userData);
79 wxPyEndBlockThreads(blocked);
80 }
81 return new wxSizerItem(width, height, proportion, flag, border, data);
82 }
7e8f0df9 83
3ea6e0ec
RD
84 DocStr(
85 wxSizerItem( wxSizer *sizer, int proportion, int flag,
86 int border, PyObject* userData=NULL ),
1b8c7ba6 87 "Constructs a `wx.SizerItem` for tracking a subsizer", "");
7e8f0df9 88
1b8c7ba6
RD
89 %RenameCtor(SizerItemSizer, wxSizerItem( wxSizer *sizer, int proportion, int flag,
90 int border, PyObject* userData=NULL ))
91 {
3ea6e0ec
RD
92 wxPyUserData* data = NULL;
93 if ( userData ) {
94 bool blocked = wxPyBeginBlockThreads();
95 data = new wxPyUserData(userData);
96 wxPyEndBlockThreads(blocked);
97 }
98 return new wxSizerItem(sizer, proportion, flag, border, data);
99 }
100 }
d14a1e28 101
d14a1e28 102
7e8f0df9 103
3ea6e0ec
RD
104 DocDeclStr(
105 void , DeleteWindows(),
106 "Destroy the window or the windows in a subsizer, depending on the type
107of item.", "");
7e8f0df9 108
3ea6e0ec
RD
109 DocDeclStr(
110 void , DetachSizer(),
111 "Enable deleting the SizerItem without destroying the contained sizer.", "");
7e8f0df9 112
d14a1e28 113
3ea6e0ec
RD
114 DocDeclStr(
115 wxSize , GetSize(),
116 "Get the current size of the item, as set in the last Layout.", "");
7e8f0df9 117
3ea6e0ec
RD
118 DocDeclStr(
119 wxSize , CalcMin(),
120 "Calculates the minimum desired size for the item, including any space
121needed by borders.", "");
7e8f0df9 122
3ea6e0ec
RD
123 DocDeclStr(
124 void , SetDimension( wxPoint pos, wxSize size ),
125 "Set the position and size of the space allocated for this item by the
126sizer, and adjust the position and size of the item (window or
127subsizer) to be within that space taking alignment and borders into
128account.", "");
7e8f0df9 129
3ea6e0ec
RD
130
131 DocDeclStr(
132 wxSize , GetMinSize(),
133 "Get the minimum size needed for the item.", "");
7e8f0df9 134
329b045c
RD
135 DocDeclStr(
136 wxSize , GetMinSizeWithBorder() const,
137 "Get the minimum size needed for the item with space for the borders
138added, if needed.", "");
139
3ea6e0ec
RD
140 DocDeclStr(
141 void , SetInitSize( int x, int y ),
142 "", "");
7e8f0df9 143
d14a1e28 144
3ea6e0ec
RD
145 DocStr(SetRatio,
146 "Set the ratio item attribute.", "");
1b8c7ba6
RD
147 %Rename(SetRatioWH, void, SetRatio( int width, int height ));
148 %Rename(SetRatioSize, void, SetRatio( wxSize size ));
d14a1e28 149 void SetRatio( float ratio );
7e8f0df9 150
3ea6e0ec
RD
151 DocDeclStr(
152 float , GetRatio(),
153 "Set the ratio item attribute.", "");
7aada1e0
RD
154
155 DocDeclStr(
156 wxRect , GetRect(),
157 "Returns the rectangle that the sizer item should occupy", "");
7e8f0df9 158
d14a1e28 159
3ea6e0ec
RD
160 DocDeclStr(
161 bool , IsWindow(),
162 "Is this sizer item a window?", "");
7e8f0df9 163
3ea6e0ec
RD
164 DocDeclStr(
165 bool , IsSizer(),
166 "Is this sizer item a subsizer?", "");
7e8f0df9 167
3ea6e0ec
RD
168 DocDeclStr(
169 bool , IsSpacer(),
170 "Is this sizer item a spacer?", "");
7e8f0df9 171
d14a1e28 172
3ea6e0ec
RD
173 DocDeclStr(
174 void , SetProportion( int proportion ),
175 "Set the proportion value for this item.", "");
7e8f0df9 176
3ea6e0ec
RD
177 DocDeclStr(
178 int , GetProportion(),
179 "Get the proportion value for this item.", "");
7e8f0df9 180
3ea6e0ec
RD
181 %pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
182 %pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
d14a1e28 183
7e8f0df9 184
3ea6e0ec
RD
185 DocDeclStr(
186 void , SetFlag( int flag ),
187 "Set the flag value for this item.", "");
7e8f0df9 188
3ea6e0ec
RD
189 DocDeclStr(
190 int , GetFlag(),
191 "Get the flag value for this item.", "");
7e8f0df9
RD
192
193
3ea6e0ec
RD
194 DocDeclStr(
195 void , SetBorder( int border ),
196 "Set the border value for this item.", "");
7e8f0df9 197
3ea6e0ec
RD
198 DocDeclStr(
199 int , GetBorder(),
200 "Get the border value for this item.", "");
d14a1e28 201
7e8f0df9
RD
202
203
3ea6e0ec
RD
204 DocDeclStr(
205 wxWindow *, GetWindow(),
206 "Get the window (if any) that is managed by this sizer item.", "");
7e8f0df9 207
3ea6e0ec
RD
208 DocDeclStr(
209 void , SetWindow( wxWindow *window ),
210 "Set the window to be managed by this sizer item.", "");
7e8f0df9
RD
211
212
3ea6e0ec
RD
213 DocDeclStr(
214 wxSizer *, GetSizer(),
215 "Get the subsizer (if any) that is managed by this sizer item.", "");
7e8f0df9 216
3ea6e0ec
RD
217 DocDeclStr(
218 void , SetSizer( wxSizer *sizer ),
219 "Set the subsizer to be managed by this sizer item.", "");
7e8f0df9
RD
220
221
3ea6e0ec
RD
222 DocDeclStr(
223 const wxSize& , GetSpacer(),
224 "Get the size of the spacer managed by this sizer item.", "");
7e8f0df9 225
3ea6e0ec
RD
226 DocDeclStr(
227 void , SetSpacer( const wxSize &size ),
228 "Set the size of the spacer to be managed by this sizer item.", "");
7e8f0df9 229
d14a1e28 230
3ea6e0ec
RD
231 DocDeclStr(
232 void , Show( bool show ),
233 "Set the show item attribute, which sizers use to determine if the item
234is to be made part of the layout or not. If the item is tracking a
235window then it is shown or hidden as needed.", "");
7e8f0df9 236
3ea6e0ec
RD
237 DocDeclStr(
238 bool , IsShown(),
239 "Is the item to be shown in the layout?", "");
7e8f0df9 240
3ea6e0ec
RD
241
242 DocDeclStr(
243 wxPoint , GetPosition(),
244 "Returns the current position of the item, as set in the last Layout.", "");
7e8f0df9 245
d14a1e28
RD
246
247 // wxObject* GetUserData();
248 %extend {
249 // Assume that the user data is a wxPyUserData object and return the contents
3ea6e0ec
RD
250
251 DocStr(GetUserData,
252 "Returns the userData associated with this sizer item, or None if there
253isn't any.", "");
d14a1e28
RD
254 PyObject* GetUserData() {
255 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
256 if (data) {
257 Py_INCREF(data->m_obj);
258 return data->m_obj;
259 } else {
260 Py_INCREF(Py_None);
261 return Py_None;
262 }
263 }
264 }
265};
266
267
268//---------------------------------------------------------------------------
269
270%{
271// Figure out the type of the sizer item
272
273struct wxPySizerItemInfo {
274 wxPySizerItemInfo()
a72f4631
RD
275 : window(NULL), sizer(NULL), gotSize(false),
276 size(wxDefaultSize), gotPos(false), pos(-1)
d14a1e28 277 {}
7e8f0df9 278
d14a1e28
RD
279 wxWindow* window;
280 wxSizer* sizer;
281 bool gotSize;
282 wxSize size;
283 bool gotPos;
284 int pos;
285};
7e8f0df9 286
d14a1e28
RD
287static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
288
289 wxPySizerItemInfo info;
290 wxSize size;
291 wxSize* sizePtr = &size;
292
293 // Find out what the type of the item is
294 // try wxWindow
295 if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
296 PyErr_Clear();
297 info.window = NULL;
7e8f0df9 298
d14a1e28
RD
299 // try wxSizer
300 if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
301 PyErr_Clear();
302 info.sizer = NULL;
7e8f0df9 303
d14a1e28
RD
304 // try wxSize or (w,h)
305 if ( checkSize && wxSize_helper(item, &sizePtr)) {
306 info.size = *sizePtr;
a72f4631 307 info.gotSize = true;
d14a1e28
RD
308 }
309
310 // or a single int
311 if (checkIdx && PyInt_Check(item)) {
312 info.pos = PyInt_AsLong(item);
a72f4631 313 info.gotPos = true;
d14a1e28
RD
314 }
315 }
316 }
317
318 if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
319 // no expected type, figure out what kind of error message to generate
320 if ( !checkSize && !checkIdx )
321 PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected for item");
322 else if ( checkSize && !checkIdx )
323 PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) expected for item");
324 else if ( !checkSize && checkIdx)
325 PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer or int (position) expected for item");
326 else
327 // can this one happen?
328 PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) or int (position) expected for item");
329 }
330
331 return info;
332}
333%}
334
335
336
337
3ea6e0ec
RD
338DocStr(wxSizer,
339"wx.Sizer is the abstract base class used for laying out subwindows in
340a window. You cannot use wx.Sizer directly; instead, you will have to
341use one of the sizer classes derived from it such as `wx.BoxSizer`,
342`wx.StaticBoxSizer`, `wx.NotebookSizer`, `wx.GridSizer`, `wx.FlexGridSizer`
343and `wx.GridBagSizer`.
344
345The concept implemented by sizers in wxWidgets is closely related to
346layout tools in other GUI toolkits, such as Java's AWT, the GTK
347toolkit or the Qt toolkit. It is based upon the idea of the individual
348subwindows reporting their minimal required size and their ability to
349get stretched if the size of the parent window has changed. This will
350most often mean that the programmer does not set the original size of
351a dialog in the beginning, rather the dialog will assigned a sizer and
352this sizer will be queried about the recommended size. The sizer in
353turn will query its children, which can be normal windows or contorls,
354empty space or other sizers, so that a hierarchy of sizers can be
355constructed. Note that wxSizer does not derive from wxWindow and thus
356do not interfere with tab ordering and requires very little resources
357compared to a real window on screen.
358
359What makes sizers so well fitted for use in wxWidgets is the fact that
360every control reports its own minimal size and the algorithm can
361handle differences in font sizes or different window (dialog item)
362sizes on different platforms without problems. If for example the
363standard font as well as the overall design of Mac widgets requires
364more space than on Windows, then the initial size of a dialog using a
365sizer will automatically be bigger on Mac than on Windows.", "
366
367:note: If you wish to create a custom sizer class in wxPython you
368 should derive the class from `wx.PySizer` in order to get
369 Python-aware capabilities for the various virtual methods.
370
371:see: `wx.SizerItem`
372
373:todo: More dscriptive text here along with some pictures...
374
375");
376
d14a1e28
RD
377class wxSizer : public wxObject {
378public:
379 // wxSizer(); **** abstract, can't instantiate
380 // ~wxSizer();
381
382 %extend {
383 void _setOORInfo(PyObject* _self) {
a77bf68f
RD
384 if (!self->GetClientObject())
385 self->SetClientObject(new wxPyOORClientData(_self));
d14a1e28
RD
386 }
387
3ea6e0ec
RD
388 DocAStr(Add,
389 "Add(self, item, int proportion=0, int flag=0, int border=0,
7aada1e0 390 PyObject userData=None) -> wx.SizerItem",
3ea6e0ec
RD
391
392 "Appends a child item to the sizer.", "
393
394 :param item: The item can be one of three kinds of objects:
395
396 - **window**: A `wx.Window` to be managed by the sizer. Its
397 minimal size (either set explicitly by the user or
398 calculated internally when constructed with wx.DefaultSize)
399 is interpreted as the minimal size to use when laying out
400 item in the sizer. This is particularly useful in
401 connection with `wx.Window.SetSizeHints`.
402
403 - **sizer**: The (child-)sizer to be added to the sizer. This
404 allows placing a child sizer in a sizer and thus to create
405 hierarchies of sizers (typically a vertical box as the top
406 sizer and several horizontal boxes on the level beneath).
407
408 - **size**: A `wx.Size` or a 2-element sequence of integers
409 that represents the width and height of a spacer to be added
410 to the sizer. Adding spacers to sizers gives more
411 flexibility in the design of dialogs; imagine for example a
412 horizontal box with two buttons at the bottom of a dialog:
413 you might want to insert a space between the two buttons and
414 make that space stretchable using the *proportion* value and
415 the result will be that the left button will be aligned with
416 the left side of the dialog and the right button with the
417 right side - the space in between will shrink and grow with
418 the dialog.
419
420 :param proportion: Although the meaning of this parameter is
421 undefined in wx.Sizer, it is used in `wx.BoxSizer` to indicate
422 if a child of a sizer can change its size in the main
423 orientation of the wx.BoxSizer - where 0 stands for not
424 changeable and a value of more than zero is interpreted
425 relative (a proportion of the total) to the value of other
426 children of the same wx.BoxSizer. For example, you might have
427 a horizontal wx.BoxSizer with three children, two of which are
428 supposed to change their size with the sizer. Then the two
429 stretchable windows should each be given *proportion* value of
430 1 to make them grow and shrink equally with the sizer's
431 horizontal dimension. But if one of them had a *proportion*
432 value of 2 then it would get a double share of the space
433 available after the fixed size items are positioned.
434
435 :param flag: This parameter can be used to set a number of flags
436 which can be combined using the binary OR operator ``|``. Two
437 main behaviours are defined using these flags. One is the
438 border around a window: the *border* parameter determines the
439 border width whereas the flags given here determine which
440 side(s) of the item that the border will be added. The other
441 flags determine how the sizer item behaves when the space
442 allotted to the sizer changes, and is somewhat dependent on
443 the specific kind of sizer used.
444
445 +----------------------------+------------------------------------------+
446 |- wx.TOP |These flags are used to specify |
447 |- wx.BOTTOM |which side(s) of the sizer item that |
448 |- wx.LEFT |the *border* width will apply to. |
449 |- wx.RIGHT | |
450 |- wx.ALL | |
451 | | |
452 +----------------------------+------------------------------------------+
453 |- wx.EXAPAND |The item will be expanded to fill |
454 | |the space allotted to the item. |
455 +----------------------------+------------------------------------------+
456 |- wx.SHAPED |The item will be expanded as much as |
457 | |possible while also maintaining its |
458 | |aspect ratio |
459 +----------------------------+------------------------------------------+
460 |- wx.FIXED_MINSIZE |Normally wx.Sizers will use |
461 | |`wx.Window.GetMinSize` or |
462 | |`wx.Window.GetBestSize` to determine what |
463 | |the minimal size of window items should |
464 | |be, and will use that size to calculate |
465 | |the layout. This allows layouts to adjust |
466 | |when an item changes and it's best size |
467 | |becomes different. If you would rather |
468 | |have a window item stay the size it |
469 | |started with then use wx.FIXED_MINSIZE. |
470 +----------------------------+------------------------------------------+
471 |- wx.ALIGN_CENTER |The wx.ALIGN flags allow you to specify |
472 |- wx.ALIGN_LEFT |the alignment of the item within the space|
473 |- wx.ALIGN_RIGHT |allotted to it by the sizer, ajusted for |
474 |- wx.ALIGN_TOP |the border if any. |
475 |- wx.ALIGN_BOTTOM | |
476 |- wx.ALIGN_CENTER_VERTICAL | |
477 |- wx.ALIGN_CENTER_HORIZONTAL| |
478 +----------------------------+------------------------------------------+
479
480
481 :param border: Determines the border width, if the *flag*
482 parameter is set to include any border flag.
483
484 :param userData: Allows an extra object to be attached to the
485 sizer item, for use in derived classes when sizing information
486 is more complex than the *proportion* and *flag* will allow for.
487");
d14a1e28 488
7aada1e0
RD
489 wxSizerItem* Add(PyObject* item, int proportion=0, int flag=0, int border=0,
490 PyObject* userData=NULL) {
7e8f0df9 491
d14a1e28 492 wxPyUserData* data = NULL;
da32eb53 493 bool blocked = wxPyBeginBlockThreads();
a72f4631 494 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
d14a1e28
RD
495 if ( userData && (info.window || info.sizer || info.gotSize) )
496 data = new wxPyUserData(userData);
da32eb53 497 wxPyEndBlockThreads(blocked);
7e8f0df9 498
d14a1e28
RD
499 // Now call the real Add method if a valid item type was found
500 if ( info.window )
7aada1e0 501 return self->Add(info.window, proportion, flag, border, data);
d14a1e28 502 else if ( info.sizer )
7aada1e0 503 return self->Add(info.sizer, proportion, flag, border, data);
d14a1e28 504 else if (info.gotSize)
7aada1e0
RD
505 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
506 proportion, flag, border, data);
507 else
508 return NULL;
d14a1e28
RD
509 }
510
7aada1e0
RD
511// virtual wxSizerItem* AddSpacer(int size);
512// virtual wxSizerItem* AddStretchSpacer(int prop = 1);
d14a1e28 513
3ea6e0ec
RD
514 DocAStr(Insert,
515 "Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
7aada1e0 516 PyObject userData=None) -> wx.SizerItem",
3ea6e0ec
RD
517
518 "Inserts a new item into the list of items managed by this sizer before
519the item at index *before*. See `Add` for a description of the parameters.", "");
7aada1e0
RD
520 wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0,
521 int border=0, PyObject* userData=NULL) {
d14a1e28
RD
522
523 wxPyUserData* data = NULL;
da32eb53 524 bool blocked = wxPyBeginBlockThreads();
a72f4631 525 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
d14a1e28
RD
526 if ( userData && (info.window || info.sizer || info.gotSize) )
527 data = new wxPyUserData(userData);
da32eb53 528 wxPyEndBlockThreads(blocked);
7e8f0df9 529
d14a1e28
RD
530 // Now call the real Insert method if a valid item type was found
531 if ( info.window )
7aada1e0 532 return self->Insert(before, info.window, proportion, flag, border, data);
d14a1e28 533 else if ( info.sizer )
7aada1e0 534 return self->Insert(before, info.sizer, proportion, flag, border, data);
d14a1e28 535 else if (info.gotSize)
7aada1e0
RD
536 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
537 proportion, flag, border, data);
538 else
539 return NULL;
d14a1e28
RD
540 }
541
542
7aada1e0
RD
543// virtual wxSizerItem* InsertSpacer(size_t index, int size);
544// virtual wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
7e8f0df9 545
3ea6e0ec
RD
546 DocAStr(Prepend,
547 "Prepend(self, item, int proportion=0, int flag=0, int border=0,
7aada1e0 548 PyObject userData=None) -> wx.SizerItem",
d14a1e28 549
3ea6e0ec
RD
550 "Adds a new item to the begining of the list of sizer items managed by
551this sizer. See `Add` for a description of the parameters.", "");
7aada1e0
RD
552 wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
553 PyObject* userData=NULL) {
d14a1e28
RD
554
555 wxPyUserData* data = NULL;
da32eb53 556 bool blocked = wxPyBeginBlockThreads();
a72f4631 557 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
d14a1e28
RD
558 if ( userData && (info.window || info.sizer || info.gotSize) )
559 data = new wxPyUserData(userData);
da32eb53 560 wxPyEndBlockThreads(blocked);
7e8f0df9 561
d14a1e28
RD
562 // Now call the real Prepend method if a valid item type was found
563 if ( info.window )
7aada1e0 564 return self->Prepend(info.window, proportion, flag, border, data);
d14a1e28 565 else if ( info.sizer )
7aada1e0 566 return self->Prepend(info.sizer, proportion, flag, border, data);
d14a1e28 567 else if (info.gotSize)
7aada1e0
RD
568 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
569 proportion, flag, border, data);
570 else
571 return NULL;
d14a1e28
RD
572 }
573
7aada1e0
RD
574// virtual wxSizerItem* PrependSpacer(int size);
575// virtual wxSizerItem* PrependStretchSpacer(int prop = 1);
3ea6e0ec
RD
576
577 DocAStr(Remove,
578 "Remove(self, item) -> bool",
579 "Removes an item from the sizer and destroys it. This method does not
580cause any layout or resizing to take place, call `Layout` to update
581the layout on screen after removing a child from the sizer. The
582*item* parameter can be either a window, a sizer, or the zero-based
583index of an item to remove. Returns True if the child item was found
584and removed.", "
585
586:note: For historical reasons calling this method with a `wx.Window`
587 parameter is depreacted, as it will not be able to destroy the
588 window since it is owned by its parent. You should use `Detach`
589 instead.
590");
d14a1e28 591 bool Remove(PyObject* item) {
da32eb53 592 bool blocked = wxPyBeginBlockThreads();
a72f4631 593 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
da32eb53 594 wxPyEndBlockThreads(blocked);
d14a1e28
RD
595 if ( info.window )
596 return self->Remove(info.window);
597 else if ( info.sizer )
598 return self->Remove(info.sizer);
599 else if ( info.gotPos )
600 return self->Remove(info.pos);
7e8f0df9 601 else
a72f4631 602 return false;
d14a1e28
RD
603 }
604
3ea6e0ec
RD
605
606 DocAStr(Detach,
607 "Detach(self, item) -> bool",
608 "Detaches an item from the sizer without destroying it. This method
609does not cause any layout or resizing to take place, call `Layout` to
610do so. The *item* parameter can be either a window, a sizer, or the
611zero-based index of the item to be detached. Returns True if the child item
612was found and detached.", "");
60a71c29
RD
613 bool Detach(PyObject* item) {
614 bool blocked = wxPyBeginBlockThreads();
a72f4631 615 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
60a71c29
RD
616 wxPyEndBlockThreads(blocked);
617 if ( info.window )
618 return self->Detach(info.window);
619 else if ( info.sizer )
620 return self->Detach(info.sizer);
621 else if ( info.gotPos )
622 return self->Detach(info.pos);
7e8f0df9 623 else
a72f4631 624 return false;
60a71c29
RD
625 }
626
7e8f0df9 627
7aada1e0
RD
628 DocAStr(GetItem,
629 "GetItem(self, item) -> wx.SizerItem",
630 "Returns the `wx.SizerItem` which holds the *item* given. The *item*
631parameter can be either a window, a sizer, or the zero-based index of
632the item to be detached.", "");
633 wxSizerItem* GetItem(PyObject* item) {
634 bool blocked = wxPyBeginBlockThreads();
635 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
636 wxPyEndBlockThreads(blocked);
637 if ( info.window )
638 return self->GetItem(info.window);
639 else if ( info.sizer )
640 return self->GetItem(info.sizer);
641 else if ( info.gotPos )
642 return self->GetItem(info.pos);
643 else
644 return NULL;
645 }
646
7e8f0df9 647
dd9f7fea 648 void _SetItemMinSize(PyObject* item, const wxSize& size) {
da32eb53 649 bool blocked = wxPyBeginBlockThreads();
a72f4631 650 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
da32eb53 651 wxPyEndBlockThreads(blocked);
d14a1e28
RD
652 if ( info.window )
653 self->SetItemMinSize(info.window, size);
654 else if ( info.sizer )
655 self->SetItemMinSize(info.sizer, size);
656 else if ( info.gotPos )
657 self->SetItemMinSize(info.pos, size);
658 }
659 }
660
3ea6e0ec
RD
661 %pythoncode {
662 def SetItemMinSize(self, item, *args):
663 """
664 SetItemMinSize(self, item, Size size)
665
666 Sets the minimum size that will be allocated for an item in the sizer.
667 The *item* parameter can be either a window, a sizer, or the
668 zero-based index of the item. If a window or sizer is given then it
669 will be searched for recursivly in subsizers if neccessary.
670 """
671 if len(args) == 2:
672 %# for backward compatibility accept separate width,height args too
673 return self._SetItemMinSize(item, args)
674 else:
675 return self._SetItemMinSize(item, args[0])
676 }
7e8f0df9 677
3ea6e0ec 678 DocDeclAStrName(
7aada1e0 679 wxSizerItem* , Add( wxSizerItem *item ),
3ea6e0ec
RD
680 "AddItem(self, SizerItem item)",
681 "Adds a `wx.SizerItem` to the sizer.", "",
682 AddItem);
7e8f0df9 683
3ea6e0ec 684 DocDeclAStrName(
7aada1e0 685 wxSizerItem* , Insert( size_t index, wxSizerItem *item ),
3ea6e0ec
RD
686 "InsertItem(self, int index, SizerItem item)",
687 "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
688 InsertItem);
7e8f0df9 689
3ea6e0ec 690 DocDeclAStrName(
7aada1e0 691 wxSizerItem* , Prepend( wxSizerItem *item ),
3ea6e0ec
RD
692 "PrependItem(self, SizerItem item)",
693 "Prepends a `wx.SizerItem` to the sizer.", "",
694 PrependItem);
7e8f0df9 695
d14a1e28
RD
696
697
698 %pythoncode {
3ea6e0ec 699 def AddMany(self, items):
dce2bd22
RD
700 """
701 AddMany is a convenience method for adding several items
702 to a sizer at one time. Simply pass it a list of tuples,
703 where each tuple consists of the parameters that you
704 would normally pass to the `Add` method.
705 """
3ea6e0ec
RD
706 for item in items:
707 if type(item) != type(()) or (len(item) == 2 and type(item[0]) == type(1)):
708 item = (item, )
709 self.Add(*item)
d14a1e28 710
d147c724 711 %# for backwards compatibility only, please do not use in new code
7e8f0df9
RD
712 def AddWindow(self, *args, **kw):
713 """Compatibility alias for `Add`."""
714 return self.Add(*args, **kw)
715 def AddSizer(self, *args, **kw):
716 """Compatibility alias for `Add`."""
717 return self.Add(*args, **kw)
718 def AddSpacer(self, *args, **kw):
719 """Compatibility alias for `Add`."""
720 return self.Add(*args, **kw)
721
722 def PrependWindow(self, *args, **kw):
723 """Compatibility alias for `Prepend`."""
724 return self.Prepend(*args, **kw)
725 def PrependSizer(self, *args, **kw):
726 """Compatibility alias for `Prepend`."""
727 return self.Prepend(*args, **kw)
728 def PrependSpacer(self, *args, **kw):
729 """Compatibility alias for `Prepend`."""
730 return self.Prepend(*args, **kw)
731
732 def InsertWindow(self, *args, **kw):
733 """Compatibility alias for `Insert`."""
734 return self.Insert(*args, **kw)
735 def InsertSizer(self, *args, **kw):
736 """Compatibility alias for `Insert`."""
737 return self.Insert(*args, **kw)
738 def InsertSpacer(self, *args, **kw):
739 """Compatibility alias for `Insert`."""
740 return self.Insert(*args, **kw)
741
742 def RemoveWindow(self, *args, **kw):
743 """Compatibility alias for `Remove`."""
744 return self.Remove(*args, **kw)
745 def RemoveSizer(self, *args, **kw):
746 """Compatibility alias for `Remove`."""
747 return self.Remove(*args, **kw)
748 def RemovePos(self, *args, **kw):
749 """Compatibility alias for `Remove`."""
750 return self.Remove(*args, **kw)
d14a1e28 751
d14a1e28
RD
752 }
753
754
3ea6e0ec
RD
755 DocDeclStr(
756 void , SetDimension( int x, int y, int width, int height ),
757 "Call this to force the sizer to take the given dimension and thus
758force the items owned by the sizer to resize themselves according to
759the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
760methods.", "");
7e8f0df9 761
3ea6e0ec
RD
762 DocDeclStr(
763 void , SetMinSize( const wxSize &size ),
764 "Call this to give the sizer a minimal size. Normally, the sizer will
765calculate its minimal size based purely on how much space its children
766need. After calling this method `GetMinSize` will return either the
767minimal size as requested by its children or the minimal size set
768here, depending on which is bigger.", "");
7e8f0df9 769
d14a1e28 770
3ea6e0ec
RD
771 DocDeclStr(
772 wxSize , GetSize(),
773 "Returns the current size of the space managed by the sizer.", "");
7e8f0df9 774
3ea6e0ec
RD
775 DocDeclStr(
776 wxPoint , GetPosition(),
777 "Returns the current position of the sizer's managed space.", "");
7e8f0df9 778
3ea6e0ec
RD
779 DocDeclStr(
780 wxSize , GetMinSize(),
781 "Returns the minimal size of the sizer. This is either the combined
782minimal size of all the children and their borders or the minimal size
783set by SetMinSize, depending on which is bigger.", "");
7e8f0df9 784
d14a1e28
RD
785
786 %pythoncode {
787 def GetSizeTuple(self):
60a71c29 788 return self.GetSize().Get()
d14a1e28 789 def GetPositionTuple(self):
60a71c29 790 return self.GetPosition().Get()
d14a1e28 791 def GetMinSizeTuple(self):
60a71c29 792 return self.GetMinSize().Get()
d14a1e28
RD
793 }
794
3ea6e0ec
RD
795 DocDeclStr(
796 virtual void , RecalcSizes(),
797 "Using the sizes calculated by `CalcMin` reposition and resize all the
798items managed by this sizer. You should not need to call this directly as
799it is called by `Layout`.", "");
7e8f0df9 800
3ea6e0ec
RD
801 DocDeclStr(
802 virtual wxSize , CalcMin(),
803 "This method is where the sizer will do the actual calculation of its
804children's minimal sizes. You should not need to call this directly as
805it is called by `Layout`.", "");
7e8f0df9 806
3ea6e0ec
RD
807
808 DocDeclStr(
809 void , Layout(),
810 "This method will force the recalculation and layout of the items
811controlled by the sizer using the current space allocated to the
812sizer. Normally this is called automatically from the owning window's
813EVT_SIZE handler, but it is also useful to call it from user code when
814one of the items in a sizer change size, or items are added or
815removed.", "");
7e8f0df9 816
d14a1e28 817
3ea6e0ec
RD
818 DocDeclStr(
819 wxSize , Fit( wxWindow *window ),
820 "Tell the sizer to resize the *window* to match the sizer's minimal
821size. This is commonly done in the constructor of the window itself in
822order to set its initial size to match the needs of the children as
823determined by the sizer. Returns the new size.
d14a1e28 824
3ea6e0ec 825For a top level window this is the total window size, not the client size.", "");
7e8f0df9 826
3ea6e0ec
RD
827 DocDeclStr(
828 void , FitInside( wxWindow *window ),
829 "Tell the sizer to resize the *virtual size* of the *window* to match the
830sizer's minimal size. This will not alter the on screen size of the
831window, but may cause the addition/removal/alteration of scrollbars
832required to view the virtual area in windows which manage it.
833
834:see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
835", "");
7e8f0df9 836
d14a1e28 837
3ea6e0ec
RD
838 DocDeclStr(
839 void , SetSizeHints( wxWindow *window ),
840 "Tell the sizer to set (and `Fit`) the minimal size of the *window* to
841match the sizer's minimal size. This is commonly done in the
842constructor of the window itself if the window is resizable (as are
843many dialogs under Unix and frames on probably all platforms) in order
844to prevent the window from being sized smaller than the minimal size
845required by the sizer.", "");
7e8f0df9 846
3ea6e0ec
RD
847 DocDeclStr(
848 void , SetVirtualSizeHints( wxWindow *window ),
849 "Tell the sizer to set the minimal size of the window virtual area to
850match the sizer's minimal size. For windows with managed scrollbars
851this will set them appropriately.
852
853:see: `wx.ScrolledWindow.SetScrollbars`
854", "");
7e8f0df9 855
d14a1e28 856
3ea6e0ec 857 DocDeclStr(
a72f4631 858 void , Clear( bool deleteWindows=false ),
3ea6e0ec
RD
859 "Clear all items from the sizer, optionally destroying the window items
860as well.", "");
7e8f0df9 861
3ea6e0ec
RD
862 DocDeclStr(
863 void , DeleteWindows(),
864 "Destroy all windows managed by the sizer.", "");
7e8f0df9 865
d14a1e28
RD
866
867
868 // wxList& GetChildren();
869 %extend {
3ea6e0ec 870 DocAStr(GetChildren,
50ed1e35 871 "GetChildren(self) -> list",
3ea6e0ec 872 "Returns a list of all the `wx.SizerItem` objects managed by the sizer.", "");
d14a1e28
RD
873 PyObject* GetChildren() {
874 wxSizerItemList& list = self->GetChildren();
875 return wxPy_ConvertList(&list);
876 }
877 }
878
879
3ea6e0ec 880 // Manage whether individual windows or subsizers are considered
d14a1e28
RD
881 // in the layout calculations or not.
882
883 %extend {
3ea6e0ec 884 DocAStr(Show,
a72f4631 885 "Show(self, item, bool show=True, bool recursive=false) -> bool",
3ea6e0ec
RD
886 "Shows or hides an item managed by the sizer. To make a sizer item
887disappear or reappear, use Show followed by `Layout`. The *item*
888parameter can be either a window, a sizer, or the zero-based index of
8f214674
RD
889the item. Use the recursive parameter to show or hide an item in a
890subsizer. Returns True if the item was found.", "");
a72f4631 891 bool Show(PyObject* item, bool show = true, bool recursive=false) {
019fd9d3 892 bool blocked = wxPyBeginBlockThreads();
a72f4631 893 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
019fd9d3 894 wxPyEndBlockThreads(blocked);
d14a1e28 895 if ( info.window )
8f214674 896 return self->Show(info.window, show, recursive);
d14a1e28 897 else if ( info.sizer )
8f214674 898 return self->Show(info.sizer, show, recursive);
3ea6e0ec 899 else if ( info.gotPos )
8f214674 900 return self->Show(info.pos, show);
5f476690
RD
901 else
902 return false;
d14a1e28 903 }
7e8f0df9 904
3ea6e0ec
RD
905 DocAStr(IsShown,
906 "IsShown(self, item)",
907 "Determines if the item is currently shown. sizer. To make a sizer
908item disappear or reappear, use Show followed by `Layout`. The *item*
909parameter can be either a window, a sizer, or the zero-based index of
910the item.", "");
d14a1e28 911 bool IsShown(PyObject* item) {
019fd9d3 912 bool blocked = wxPyBeginBlockThreads();
a72f4631 913 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false);
019fd9d3 914 wxPyEndBlockThreads(blocked);
7e8f0df9 915 if ( info.window )
d14a1e28 916 return self->IsShown(info.window);
7e8f0df9 917 else if ( info.sizer )
d14a1e28 918 return self->IsShown(info.sizer);
3ea6e0ec
RD
919 else if ( info.gotPos )
920 return self->IsShown(info.pos);
d14a1e28 921 else
a72f4631 922 return false;
d14a1e28
RD
923 }
924 }
925
3ea6e0ec 926 %pythoncode {
41b78a7a 927 def Hide(self, item, recursive=False):
3ea6e0ec 928 """
8f214674 929 A convenience method for Show(item, False, recursive).
3ea6e0ec 930 """
9dcf02b4 931 return self.Show(item, False, recursive)
3ea6e0ec 932 }
d14a1e28 933
7e8f0df9 934
3ea6e0ec
RD
935 DocDeclStr(
936 void , ShowItems(bool show),
e2837d11 937 "Recursively call `wx.SizerItem.Show` on all sizer items.", "");
7e8f0df9 938
d14a1e28
RD
939};
940
941
942//---------------------------------------------------------------------------
943// Use this one for deriving Python classes from
944%{
7e8f0df9 945// See pyclasses.h
d14a1e28
RD
946IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
947IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
948IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
949%}
950
951
3ea6e0ec
RD
952DocStr(wxPySizer,
953"wx.PySizer is a special version of `wx.Sizer` that has been
954instrumented to allow the C++ virtual methods to be overloaded in
955Python derived classes. You would derive from this class if you are
956wanting to implement a custom sizer in Python code. Simply implement
957`CalcMin` and `RecalcSizes` in the derived class and you're all set.
958For example::
959
960 class MySizer(wx.PySizer):
961 def __init__(self):
962 wx.PySizer.__init__(self)
963
964 def CalcMin(self):
965 for item in self.GetChildren():
966 # calculate the total minimum width and height needed
967 # by all items in the sizer according to this sizer's
968 # layout algorithm.
969 ...
970 return wx.Size(width, height)
971
972 def RecalcSizes(self):
973 # find the space allotted to this sizer
974 pos = self.GetPosition()
975 size = self.GetSize()
976 for item in self.GetChildren():
977 # Recalculate (if necessary) the position and size of
978 # each item and then call item.SetDimension to do the
979 # actual positioning and sizing of the items within the
980 # space alloted to this sizer.
981 ...
982 item.SetDimension(itemPos, itemSize)
983
984
985When `Layout` is called it first calls `CalcMin` followed by
986`RecalcSizes` so you can optimize a bit by saving the results of
9283228f 987`CalcMin` and reusing them in `RecalcSizes`.
3ea6e0ec
RD
988
989:see: `wx.SizerItem`, `wx.Sizer.GetChildren`
990
991", "");
d14a1e28
RD
992class wxPySizer : public wxSizer {
993public:
2b9048c5 994 %pythonAppend wxPySizer "self._setCallbackInfo(self, PySizer);self._setOORInfo(self)"
d14a1e28 995
3ea6e0ec
RD
996 DocCtorStr(
997 wxPySizer(),
998 "Creates a wx.PySizer. Must be called from the __init__ in the derived
999class.", "");
7e8f0df9 1000
d14a1e28
RD
1001 void _setCallbackInfo(PyObject* self, PyObject* _class);
1002};
1003
1004
1005//---------------------------------------------------------------------------
1006%newgroup;
1007
3ea6e0ec
RD
1008
1009DocStr(wxBoxSizer,
1010"The basic idea behind a box sizer is that windows will most often be
1011laid out in rather simple basic geometry, typically in a row or a
1012column or nested hierarchies of either. A wx.BoxSizer will lay out
1013its items in a simple row or column, depending on the orientation
1014parameter passed to the constructor.", "
1015
1016It is the unique feature of a box sizer, that it can grow in both
1017directions (height and width) but can distribute its growth in the
1018main direction (horizontal for a row) *unevenly* among its children.
1019This is determined by the proportion parameter give to items when they
1020are added to the sizer. It is interpreted as a weight factor, i.e. it
1021can be zero, indicating that the window may not be resized at all, or
1022above zero. If several windows have a value above zero, the value is
1023interpreted relative to the sum of all weight factors of the sizer, so
1024when adding two windows with a value of 1, they will both get resized
1025equally and each will receive half of the available space after the
1026fixed size items have been sized. If the items have unequal
1027proportion settings then they will receive a coresondingly unequal
1028allotment of the free space.
1029
1030:see: `wx.StaticBoxSizer`
1031");
1032
d14a1e28
RD
1033class wxBoxSizer : public wxSizer {
1034public:
2b9048c5 1035 %pythonAppend wxBoxSizer "self._setOORInfo(self)"
d14a1e28 1036
3ea6e0ec
RD
1037 DocCtorStr(
1038 wxBoxSizer(int orient = wxHORIZONTAL),
1039 "Constructor for a wx.BoxSizer. *orient* may be one of ``wx.VERTICAL``
1040or ``wx.HORIZONTAL`` for creating either a column sizer or a row
1041sizer.", "");
d14a1e28 1042
7e8f0df9 1043
3ea6e0ec
RD
1044 DocDeclStr(
1045 int , GetOrientation(),
1046 "Returns the current orientation of the sizer.", "");
7e8f0df9 1047
3ea6e0ec
RD
1048 DocDeclStr(
1049 void , SetOrientation(int orient),
1050 "Resets the orientation of the sizer.", "");
7e8f0df9 1051
d14a1e28
RD
1052};
1053
1054//---------------------------------------------------------------------------
1055%newgroup;
1056
3ea6e0ec
RD
1057
1058DocStr(wxStaticBoxSizer,
1059"wx.StaticBoxSizer derives from and functions identically to the
1060`wx.BoxSizer` and adds a `wx.StaticBox` around the items that the sizer
1061manages. Note that this static box must be created separately and
1062passed to the sizer constructor.", "");
1063
d14a1e28
RD
1064class wxStaticBoxSizer : public wxBoxSizer {
1065public:
2b9048c5 1066 %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)"
d14a1e28 1067
3ea6e0ec
RD
1068 DocCtorStr(
1069 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL),
1070 "Constructor. It takes an associated static box and the orientation
1071*orient* as parameters - orient can be either of ``wx.VERTICAL`` or
1072``wx.HORIZONTAL``.", "");
39d160c3
RD
1073
1074 // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
7e8f0df9 1075
39d160c3
RD
1076 DocDeclStr(
1077 wxStaticBox *, GetStaticBox(),
1078 "Returns the static box associated with this sizer.", "");
7e8f0df9 1079
d14a1e28
RD
1080};
1081
1082//---------------------------------------------------------------------------
1083%newgroup;
1084
3ea6e0ec
RD
1085
1086DocStr(wxGridSizer,
1087"A grid sizer is a sizer which lays out its children in a
1088two-dimensional table with all cells having the same size. In other
1089words, the width of each cell within the grid is the width of the
1090widest item added to the sizer and the height of each grid cell is the
1091height of the tallest item. An optional vertical and/or horizontal
1092gap between items can also be specified (in pixels.)
1093
1094Items are placed in the cells of the grid in the order they are added,
1095in row-major order. In other words, the first row is filled first,
1096then the second, and so on until all items have been added. (If
1097neccessary, additional rows will be added as items are added.) If you
1098need to have greater control over the cells that items are placed in
1099then use the `wx.GridBagSizer`.
1100", "");
1101
d14a1e28
RD
1102class wxGridSizer: public wxSizer
1103{
1104public:
2b9048c5 1105 %pythonAppend wxGridSizer "self._setOORInfo(self)"
d14a1e28 1106
3ea6e0ec
RD
1107 DocCtorStr(
1108 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1109 "Constructor for a wx.GridSizer. *rows* and *cols* determine the number
1110of columns and rows in the sizer - if either of the parameters is
1111zero, it will be calculated to from the total number of children in
1112the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1113define extra space between all children.", "");
1114
1115 DocDeclStr(
1116 void , SetCols( int cols ),
1117 "Sets the number of columns in the sizer.", "");
7e8f0df9 1118
3ea6e0ec
RD
1119 DocDeclStr(
1120 void , SetRows( int rows ),
1121 "Sets the number of rows in the sizer.", "");
7e8f0df9 1122
3ea6e0ec
RD
1123 DocDeclStr(
1124 void , SetVGap( int gap ),
1125 "Sets the vertical gap (in pixels) between the cells in the sizer.", "");
7e8f0df9 1126
3ea6e0ec
RD
1127 DocDeclStr(
1128 void , SetHGap( int gap ),
1129 "Sets the horizontal gap (in pixels) between cells in the sizer", "");
7e8f0df9 1130
3ea6e0ec
RD
1131 DocDeclStr(
1132 int , GetCols(),
1133 "Returns the number of columns in the sizer.", "");
7e8f0df9 1134
3ea6e0ec
RD
1135 DocDeclStr(
1136 int , GetRows(),
1137 "Returns the number of rows in the sizer.", "");
7e8f0df9 1138
3ea6e0ec
RD
1139 DocDeclStr(
1140 int , GetVGap(),
1141 "Returns the vertical gap (in pixels) between the cells in the sizer.", "");
7e8f0df9 1142
3ea6e0ec
RD
1143 DocDeclStr(
1144 int , GetHGap(),
1145 "Returns the horizontal gap (in pixels) between cells in the sizer.", "");
7e8f0df9 1146
d14a1e28
RD
1147};
1148
1149//---------------------------------------------------------------------------
1150%newgroup;
1151
1152enum wxFlexSizerGrowMode
1153{
1154 // don't resize the cells in non-flexible direction at all
1155 wxFLEX_GROWMODE_NONE,
1156
1157 // uniformly resize only the specified ones (default)
1158 wxFLEX_GROWMODE_SPECIFIED,
1159
1160 // uniformly resize all cells
1161 wxFLEX_GROWMODE_ALL
1162};
1163
1164
3ea6e0ec
RD
1165
1166
1167
1168DocStr(wxFlexGridSizer,
1169"A flex grid sizer is a sizer which lays out its children in a
1170two-dimensional table with all table cells in one row having the same
1171height and all cells in one column having the same width, but all
1172rows or all columns are not necessarily the same height or width as in
1173the `wx.GridSizer`.
1174
1175wx.FlexGridSizer can also size items equally in one direction but
1176unequally (\"flexibly\") in the other. If the sizer is only flexible
1177in one direction (this can be changed using `SetFlexibleDirection`), it
1178needs to be decided how the sizer should grow in the other (\"non
1179flexible\") direction in order to fill the available space. The
1180`SetNonFlexibleGrowMode` method serves this purpose.
1181
1182", "");
1183
d14a1e28
RD
1184class wxFlexGridSizer: public wxGridSizer
1185{
1186public:
2b9048c5 1187 %pythonAppend wxFlexGridSizer "self._setOORInfo(self)"
d14a1e28 1188
3ea6e0ec
RD
1189 DocCtorStr(
1190 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1191 "Constructor for a wx.FlexGridSizer. *rows* and *cols* determine the
1192number of columns and rows in the sizer - if either of the parameters
1193is zero, it will be calculated to from the total number of children in
1194the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1195define extra space between all children.", "");
7e8f0df9 1196
3ea6e0ec
RD
1197
1198 DocDeclStr(
1199 void , AddGrowableRow( size_t idx, int proportion = 0 ),
1200 "Specifies that row *idx* (starting from zero) should be grown if there
1201is extra space available to the sizer.
1202
1203The *proportion* parameter has the same meaning as the stretch factor
1204for the box sizers except that if all proportions are 0, then all
1205columns are resized equally (instead of not being resized at all).", "");
7e8f0df9 1206
3ea6e0ec
RD
1207 DocDeclStr(
1208 void , RemoveGrowableRow( size_t idx ),
1209 "Specifies that row *idx* is no longer growable.", "");
7e8f0df9 1210
3ea6e0ec
RD
1211 DocDeclStr(
1212 void , AddGrowableCol( size_t idx, int proportion = 0 ),
1213 "Specifies that column *idx* (starting from zero) should be grown if
1214there is extra space available to the sizer.
1215
1216The *proportion* parameter has the same meaning as the stretch factor
1217for the box sizers except that if all proportions are 0, then all
1218columns are resized equally (instead of not being resized at all).", "");
7e8f0df9 1219
3ea6e0ec
RD
1220 DocDeclStr(
1221 void , RemoveGrowableCol( size_t idx ),
1222 "Specifies that column *idx* is no longer growable.", "");
7e8f0df9 1223
3ea6e0ec
RD
1224
1225 DocDeclStr(
1226 void , SetFlexibleDirection(int direction),
1227 "Specifies whether the sizer should flexibly resize its columns, rows,
1228or both. Argument *direction* can be one of the following values. Any
1229other value is ignored.
1230
1231 ============== =======================================
1232 wx.VERTICAL Rows are flexibly sized.
1233 wx.HORIZONTAL Columns are flexibly sized.
1234 wx.BOTH Both rows and columns are flexibly sized
1235 (this is the default value).
1236 ============== =======================================
1237
1238Note that this method does not trigger relayout.
1239", "");
7e8f0df9 1240
3ea6e0ec
RD
1241 DocDeclStr(
1242 int , GetFlexibleDirection(),
1243 "Returns a value that specifies whether the sizer
1244flexibly resizes its columns, rows, or both (default).
d14a1e28 1245
3ea6e0ec 1246:see: `SetFlexibleDirection`", "");
d14a1e28 1247
7e8f0df9 1248
d14a1e28 1249
3ea6e0ec
RD
1250 DocDeclStr(
1251 void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
1252 "Specifies how the sizer should grow in the non-flexible direction if
1253there is one (so `SetFlexibleDirection` must have been called
1254previously). Argument *mode* can be one of the following values:
1255
1256 ========================== =================================================
1257 wx.FLEX_GROWMODE_NONE Sizer doesn't grow in the non flexible direction.
1258 wx.FLEX_GROWMODE_SPECIFIED Sizer honors growable columns/rows set with
1259 `AddGrowableCol` and `AddGrowableRow`. In this
1260 case equal sizing applies to minimum sizes of
1261 columns or rows (this is the default value).
1262 wx.FLEX_GROWMODE_ALL Sizer equally stretches all columns or rows in
1263 the non flexible direction, whether they are
1264 growable or not in the flexbile direction.
1265 ========================== =================================================
1266
1267Note that this method does not trigger relayout.
1268
1269", "");
7e8f0df9 1270
3ea6e0ec
RD
1271 DocDeclStr(
1272 wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
1273 "Returns the value that specifies how the sizer grows in the
1274non-flexible direction if there is one.
d14a1e28 1275
3ea6e0ec 1276:see: `SetNonFlexibleGrowMode`", "");
7e8f0df9 1277
dd9f7fea
RD
1278
1279 // Read-only access to the row heights and col widths arrays
3ea6e0ec
RD
1280 DocDeclAStr(
1281 const wxArrayInt& , GetRowHeights() const,
1282 "GetRowHeights(self) -> list",
1283 "Returns a list of integers representing the heights of each of the
1284rows in the sizer.", "");
7e8f0df9 1285
3ea6e0ec
RD
1286 DocDeclAStr(
1287 const wxArrayInt& , GetColWidths() const,
1288 "GetColWidths(self) -> list",
1289 "Returns a list of integers representing the widths of each of the
1290columns in the sizer.", "");
7e8f0df9 1291
d14a1e28
RD
1292};
1293
9283228f
RD
1294//---------------------------------------------------------------------------
1295
1296DocStr(wxStdDialogButtonSizer,
1297"A special sizer that knows how to order and position standard buttons
1298in order to conform to the current platform's standards. You simply
1299need to add each `wx.Button` to the sizer, and be sure to create the
718903fe 1300buttons using the standard ID's. Then call `Realize` and the sizer
9283228f
RD
1301will take care of the rest.
1302", "");
1303
1304class wxStdDialogButtonSizer: public wxBoxSizer
1305{
1306public:
1307 DocCtorStr(
1308 wxStdDialogButtonSizer(),
1309 "", "");
1310
1311 DocDeclStr(
1312 void , AddButton(wxButton *button),
1313 "Use this to add the buttons to this sizer. Do not use the `Add`
1314method in the base class.", "");
7e8f0df9 1315
9283228f 1316 DocDeclStr(
718903fe 1317 void , Realize(),
9283228f
RD
1318 "This funciton needs to be called after all the buttons have been added
1319to the sizer. It will reorder them and position them in a platform
1320specifc manner.", "");
3ba93175
RD
1321
1322 void SetAffirmativeButton( wxButton *button );
1323 void SetNegativeButton( wxButton *button );
1324 void SetCancelButton( wxButton *button );
7e8f0df9 1325
9283228f
RD
1326 wxButton* GetAffirmativeButton() const;
1327 wxButton* GetApplyButton() const;
1328 wxButton* GetNegativeButton() const;
1329 wxButton* GetCancelButton() const;
1330 wxButton* GetHelpButton() const;
1331};
1332
1333
d14a1e28 1334//---------------------------------------------------------------------------