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