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