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