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