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