1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defs for the Sizers
7 // Created: 18-Sept-1999
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
21 //---------------------------------------------------------------------------
25 "Normally, when you add an item to a sizer via `wx.Sizer.Add`, you have
26 to specify a lot of flags and parameters which can be unwieldy. This
27 is where wx.SizerFlags comes in: it allows you to specify all
28 parameters using the named methods instead. For example, instead of::
30 sizer.Add(ctrl, 0, wx.EXPAND | wx.ALL, 10)
34 sizer.AddF(ctrl, wx.SizerFlags().Expand().Border(wx.ALL, 10))
36 This is more readable and also allows you to create wx.SizerFlags
37 objects which can be reused for several sizer items.::
39 flagsExpand = wx.SizerFlags(1)
40 flagsExpand.Expand().Border(wx.ALL, 10)
41 sizer.AddF(ctrl1, flagsExpand)
42 sizer.AddF(ctrl2, flagsExpand)
44 Note that by specification, all methods of wx.SizerFlags return the
45 wx.SizerFlags object itself allowing chaining multiple method calls
46 like in the examples above.", "");
51 // construct the flags object initialized with the given proportion (0 by
54 wxSizerFlags(int proportion = 0),
55 "Constructs the flags object with the specified proportion.", "");
59 // This typemap ensures that the returned object is the same
60 // Python instance as what was passed in as `self`, instead of
61 // creating a new proxy as SWIG would normally do.
62 %typemap(out) wxSizerFlags& { $result = $self; Py_INCREF($result); }
65 wxSizerFlags& , Proportion(int proportion),
66 "Sets the item's proportion value.", "");
69 wxSizerFlags& , Align(int alignment),
70 "Sets the item's alignment", "");
73 wxSizerFlags& , Expand(),
74 "Sets the wx.EXPAND flag, which will cause the item to be expanded to
75 fill as much space as it is given by the sizer.", "");
78 wxSizerFlags& , Centre(),
79 "Same as `Center` for those with an alternate dialect of English.", "");
82 wxSizerFlags& , Center(),
83 "Sets the centering alignment flags.", "");
86 wxSizerFlags& , Left(),
87 "Aligns the object to the left, a shortcut for calling
88 Align(wx.ALIGN_LEFT)", "");
91 wxSizerFlags& , Right(),
92 "Aligns the object to the right, a shortcut for calling
93 Align(wx.ALIGN_RIGHT)", "");
96 wxSizerFlags& , Top(),
97 "Aligns the object to the top of the available space, a shortcut for
98 calling Align(wx.ALIGN_TOP)", "");
101 wxSizerFlags& , Bottom(),
102 "Aligns the object to the bottom of the available space, a shortcut for
103 calling Align(wx.ALIGN_BOTTOM)", "");
106 wxSizerFlags& , Shaped(),
107 "Sets the wx.SHAPED flag.", "");
110 wxSizerFlags& , FixedMinSize(),
111 "Sets the wx.FIXED_MINSIZE flag.", "");
117 wxSizerFlags& , Border(int direction=wxALL, int borderInPixels=-1),
118 "Sets the border of the item in the direction(s) or sides given by the
119 direction parameter. If the borderInPixels value is not given then
120 the default border size (see `GetDefaultBorder`) will be used.", "")
122 if (borderInPixels == -1)
123 return self->Border(direction);
125 return self->Border(direction, borderInPixels);
130 wxSizerFlags& , DoubleBorder(int direction = wxALL),
131 "Sets the border in the given direction to twice the default border
135 wxSizerFlags& , TripleBorder(int direction = wxALL),
136 "Sets the border in the given direction to three times the default
140 wxSizerFlags& , HorzBorder(),
141 "Sets the left and right borders to the default border size.", "");
144 wxSizerFlags& , DoubleHorzBorder(),
145 "Sets the left and right borders to twice the default border size.", "");
149 %typemap(out) wxSizerFlags& ;
154 static int , GetDefaultBorder(),
155 "Returns the default border size used by the other border methods", "");
159 int , GetProportion() const,
160 "Returns the proportion value to be used in the sizer item.", "");
163 int , GetFlags() const,
164 "Returns the flags value to be used in the sizer item.", "");
167 int , GetBorderInPixels() const,
168 "Returns the border value in pixels to be used in the sizer item.", "");
171 //---------------------------------------------------------------------------
174 wxLIST_WRAPPER( wxSizerItemList, wxSizerItem );
179 "The wx.SizerItem class is used to track the position, size and other
180 attributes of each item managed by a `wx.Sizer`. It is not usually
181 necessary to use this class because the sizer elements can also be
182 identified by their positions or window or sizer references but
183 sometimes it may be more convenient to use wx.SizerItem directly.
184 Also, custom classes derived from `wx.PySizer` will probably need to
185 use the collection of wx.SizerItems held by wx.Sizer when calculating
188 :see: `wx.Sizer`, `wx.GBSizerItem`", "");
190 class wxSizerItem : public wxObject {
194 "Constructs an empty wx.SizerItem. Either a window, sizer or spacer
195 size will need to be set before this item can be used in a Sizer.
197 You will probably never need to create a wx.SizerItem directly as they
198 are created automatically when the sizer's Add, Insert or Prepend
201 :see: `wx.SizerItemSpacer`, `wx.SizerItemWindow`, `wx.SizerItemSizer`", "");
209 wxSizerItem( wxWindow *window, int proportion, int flag,
210 int border, PyObject* userData=NULL ),
211 "Constructs a `wx.SizerItem` for tracking a window.", "");
213 %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, int flag,
214 int border, PyObject* userData=NULL ))
216 wxPyUserData* data = NULL;
218 wxPyBlock_t blocked = wxPyBeginBlockThreads();
219 data = new wxPyUserData(userData);
220 wxPyEndBlockThreads(blocked);
222 return new wxSizerItem(window, proportion, flag, border, data);
227 wxSizerItem( int width, int height, int proportion, int flag,
228 int border, PyObject* userData=NULL),
229 "Constructs a `wx.SizerItem` for tracking a spacer.", "");
231 %RenameCtor(SizerItemSpacer, wxSizerItem( int width, int height, int proportion, int flag,
232 int border, PyObject* userData=NULL))
234 wxPyUserData* data = NULL;
236 wxPyBlock_t blocked = wxPyBeginBlockThreads();
237 data = new wxPyUserData(userData);
238 wxPyEndBlockThreads(blocked);
240 return new wxSizerItem(width, height, proportion, flag, border, data);
244 wxSizerItem( wxSizer *sizer, int proportion, int flag,
245 int border, PyObject* userData=NULL ),
246 "Constructs a `wx.SizerItem` for tracking a subsizer", "");
248 %disownarg( wxSizer *sizer );
249 %RenameCtor(SizerItemSizer, wxSizerItem( wxSizer *sizer, int proportion, int flag,
250 int border, PyObject* userData=NULL ))
252 wxPyUserData* data = NULL;
254 wxPyBlock_t blocked = wxPyBeginBlockThreads();
255 data = new wxPyUserData(userData);
256 wxPyEndBlockThreads(blocked);
258 return new wxSizerItem(sizer, proportion, flag, border, data);
260 %cleardisown( wxSizer *sizer );
266 void , DeleteWindows(),
267 "Destroy the window or the windows in a subsizer, depending on the type
271 void , DetachSizer(),
272 "Enable deleting the SizerItem without destroying the contained sizer.", "");
277 "Get the current size of the item, as set in the last Layout.", "");
281 "Calculates the minimum desired size for the item, including any space
282 needed by borders.", "");
285 void , SetDimension( const wxPoint& pos, const wxSize& size ),
286 "Set the position and size of the space allocated for this item by the
287 sizer, and adjust the position and size of the item (window or
288 subsizer) to be within that space taking alignment and borders into
293 wxSize , GetMinSize(),
294 "Get the minimum size needed for the item.", "");
297 wxSize , GetMinSizeWithBorder() const,
298 "Get the minimum size needed for the item with space for the borders
299 added, if needed.", "");
302 void , SetInitSize( int x, int y ),
307 "Set the ratio item attribute.", "");
308 %Rename(SetRatioWH, void, SetRatio( int width, int height ));
309 %Rename(SetRatioSize, void, SetRatio( const wxSize& size ));
310 void SetRatio( float ratio );
314 "Set the ratio item attribute.", "");
318 "Returns the rectangle that the sizer item should occupy", "");
323 "Is this sizer item a window?", "");
327 "Is this sizer item a subsizer?", "");
331 "Is this sizer item a spacer?", "");
335 void , SetProportion( int proportion ),
336 "Set the proportion value for this item.", "");
339 int , GetProportion(),
340 "Get the proportion value for this item.", "");
342 %pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
343 %pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
347 void , SetFlag( int flag ),
348 "Set the flag value for this item.", "");
352 "Get the flag value for this item.", "");
356 void , SetBorder( int border ),
357 "Set the border value for this item.", "");
361 "Get the border value for this item.", "");
366 wxWindow *, GetWindow(),
367 "Get the window (if any) that is managed by this sizer item.", "");
371 wxSizer *, GetSizer(),
372 "Get the subsizer (if any) that is managed by this sizer item.", "");
375 wxSize , GetSpacer(),
376 "Get the size of the spacer managed by this sizer item.", "");
382 void , SetWindow( wxWindow *window ),
383 "Set the window to be managed by this sizer item.", "");
385 %disownarg( wxSizer *sizer );
387 void , SetSizer( wxSizer *sizer ),
388 "Set the subsizer to be managed by this sizer item.", "");
389 %cleardisown( wxSizer *sizer );
392 void , SetSpacer( const wxSize &size ),
393 "Set the size of the spacer to be managed by this sizer item.", "");
396 SetWindow = wx._deprecated(SetWindow, "Use `AssignWindow` instead.")
397 SetSizer = wx._deprecated(SetSizer, "Use `AssignSizer` instead.")
398 SetSpacer = wx._deprecated(SetSpacer, "Use `AssignSpacer` instead.")
404 void , AssignWindow(wxWindow *window),
405 "Set the window to be managed by this sizer item.", "");
408 void , AssignSizer(wxSizer *sizer),
409 "Set the subsizer to be managed by this sizer item.", "");
412 void , AssignSpacer(const wxSize& size),
413 "Set the size of the spacer to be managed by this sizer item.", "");
419 void , Show( bool show ),
420 "Set the show item attribute, which sizers use to determine if the item
421 is to be made part of the layout or not. If the item is tracking a
422 window then it is shown or hidden as needed.", "");
426 "Is the item to be shown in the layout?", "");
430 wxPoint , GetPosition(),
431 "Returns the current position of the item, as set in the last Layout.", "");
434 // wxObject* GetUserData();
436 // Assume that the user data is a wxPyUserData object and return the contents
439 "Returns the userData associated with this sizer item, or None if there
441 PyObject* GetUserData() {
442 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
444 Py_INCREF(data->m_obj);
453 "Associate a Python object with this sizer item.", "");
454 void SetUserData(PyObject* userData) {
455 wxPyUserData* data = NULL;
457 wxPyBlock_t blocked = wxPyBeginBlockThreads();
458 data = new wxPyUserData(userData);
459 wxPyEndBlockThreads(blocked);
461 self->SetUserData(data);
465 %property(Border, GetBorder, SetBorder, doc="See `GetBorder` and `SetBorder`");
466 %property(Flag, GetFlag, SetFlag, doc="See `GetFlag` and `SetFlag`");
467 %property(MinSize, GetMinSize, doc="See `GetMinSize`");
468 %property(MinSizeWithBorder, GetMinSizeWithBorder, doc="See `GetMinSizeWithBorder`");
469 %property(Position, GetPosition, doc="See `GetPosition`");
470 %property(Proportion, GetProportion, SetProportion, doc="See `GetProportion` and `SetProportion`");
471 %property(Ratio, GetRatio, SetRatio, doc="See `GetRatio` and `SetRatio`");
472 %property(Rect, GetRect, doc="See `GetRect`");
473 %property(Size, GetSize, doc="See `GetSize`");
474 %property(Sizer, GetSizer, AssignSizer, doc="See `GetSizer` and `AssignSizer`");
475 %property(Spacer, GetSpacer, AssignSpacer, doc="See `GetSpacer` and `AssignSpacer`");
476 %property(UserData, GetUserData, SetUserData, doc="See `GetUserData` and `SetUserData`");
477 %property(Window, GetWindow, AssignWindow, doc="See `GetWindow` and `AssignWindow`");
481 //---------------------------------------------------------------------------
484 // Figure out the type of the sizer item
486 struct wxPySizerItemInfo {
488 : window(NULL), sizer(NULL), gotSize(false),
489 size(wxDefaultSize), gotPos(false), pos(-1)
500 static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
502 wxPySizerItemInfo info;
504 wxSize* sizePtr = &size;
506 // Find out what the type of the item is
508 if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
513 if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
517 // try wxSize or (w,h)
518 if ( checkSize && wxSize_helper(item, &sizePtr)) {
519 info.size = *sizePtr;
524 if (checkIdx && PyInt_Check(item)) {
525 info.pos = PyInt_AsLong(item);
531 if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
532 // no expected type, figure out what kind of error message to generate
533 if ( !checkSize && !checkIdx )
534 PyErr_SetString(PyExc_TypeError, "wx.Window or wx.Sizer expected for item");
535 else if ( checkSize && !checkIdx )
536 PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item");
537 else if ( !checkSize && checkIdx)
538 PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer or int (position) expected for item");
540 // can this one happen?
541 PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) or int (position) expected for item");
552 "wx.Sizer is the abstract base class used for laying out subwindows in
553 a window. You cannot use wx.Sizer directly; instead, you will have to
554 use one of the sizer classes derived from it such as `wx.BoxSizer`,
555 `wx.StaticBoxSizer`, `wx.GridSizer`, `wx.FlexGridSizer` and
558 The concept implemented by sizers in wxWidgets is closely related to
559 layout tools in other GUI toolkits, such as Java's AWT, the GTK
560 toolkit or the Qt toolkit. It is based upon the idea of the individual
561 subwindows reporting their minimal required size and their ability to
562 get stretched if the size of the parent window has changed. This will
563 most often mean that the programmer does not set the original size of
564 a dialog in the beginning, rather the dialog will assigned a sizer and
565 this sizer will be queried about the recommended size. The sizer in
566 turn will query its children, which can be normal windows or contorls,
567 empty space or other sizers, so that a hierarchy of sizers can be
568 constructed. Note that wxSizer does not derive from wxWindow and thus
569 do not interfere with tab ordering and requires very little resources
570 compared to a real window on screen.
572 What makes sizers so well fitted for use in wxWidgets is the fact that
573 every control reports its own minimal size and the algorithm can
574 handle differences in font sizes or different window (dialog item)
575 sizes on different platforms without problems. If for example the
576 standard font as well as the overall design of Mac widgets requires
577 more space than on Windows, then the initial size of a dialog using a
578 sizer will automatically be bigger on Mac than on Windows.", "
580 Sizers may also be used to control the layout of custom drawn items on
581 the window. The `Add`, `Insert`, and `Prepend` functions return a
582 pointer to the newly added `wx.SizerItem`. Just add empty space of the
583 desired size and attributes, and then use the `wx.SizerItem.GetRect`
584 method to determine where the drawing operations should take place.
586 :note: If you wish to create a custom sizer class in wxPython you
587 should derive the class from `wx.PySizer` in order to get
588 Python-aware capabilities for the various virtual methods.
592 :todo: More dscriptive text here along with some pictures...
596 class wxSizer : public wxObject {
598 // wxSizer(); **** abstract, can't instantiate
603 void _setOORInfo(PyObject* _self) {
604 if (!self->GetClientObject())
605 self->SetClientObject(new wxPyOORClientData(_self));
609 "Add(self, item, int proportion=0, int flag=0, int border=0,
610 PyObject userData=None) -> wx.SizerItem",
612 "Appends a child item to the sizer.", "
614 :param item: The item can be one of three kinds of objects:
616 - **window**: A `wx.Window` to be managed by the sizer. Its
617 minimal size (either set explicitly by the user or
618 calculated internally when constructed with wx.DefaultSize)
619 is interpreted as the minimal size to use when laying out
620 item in the sizer. This is particularly useful in
621 connection with `wx.Window.SetSizeHints`.
623 - **sizer**: The (child-)sizer to be added to the sizer. This
624 allows placing a child sizer in a sizer and thus to create
625 hierarchies of sizers (for example a vertical box as the top
626 sizer and several horizontal boxes on the level beneath).
628 - **size**: A `wx.Size` or a 2-element sequence of integers
629 that represents the width and height of a spacer to be added
630 to the sizer. Adding spacers to sizers gives more
631 flexibility in the design of dialogs; imagine for example a
632 horizontal box with two buttons at the bottom of a dialog:
633 you might want to insert a space between the two buttons and
634 make that space stretchable using the *proportion* value and
635 the result will be that the left button will be aligned with
636 the left side of the dialog and the right button with the
637 right side - the space in between will shrink and grow with
640 :param proportion: Although the meaning of this parameter is
641 undefined in wx.Sizer, it is used in `wx.BoxSizer` to indicate
642 if a child of a sizer can change its size in the main
643 orientation of the wx.BoxSizer - where 0 stands for not
644 changeable and a value of more than zero is interpreted
645 relative (a proportion of the total) to the value of other
646 children of the same wx.BoxSizer. For example, you might have
647 a horizontal wx.BoxSizer with three children, two of which are
648 supposed to change their size with the sizer. Then the two
649 stretchable windows should each be given *proportion* value of
650 1 to make them grow and shrink equally with the sizer's
651 horizontal dimension. But if one of them had a *proportion*
652 value of 2 then it would get a double share of the space
653 available after the fixed size items are positioned.
655 :param flag: This parameter can be used to set a number of flags
656 which can be combined using the binary OR operator ``|``. Two
657 main behaviours are defined using these flags. One is the
658 border around a window: the *border* parameter determines the
659 border width whereas the flags given here determine which
660 side(s) of the item that the border will be added. The other
661 flags determine how the sizer item behaves when the space
662 allotted to the sizer changes, and is somewhat dependent on
663 the specific kind of sizer used.
665 +----------------------------+------------------------------------------+
666 |- wx.TOP |These flags are used to specify |
667 |- wx.BOTTOM |which side(s) of the sizer item that |
668 |- wx.LEFT |the *border* width will apply to. |
672 +----------------------------+------------------------------------------+
673 |- wx.EXPAND |The item will be expanded to fill |
674 | |the space allotted to the item. |
675 +----------------------------+------------------------------------------+
676 |- wx.SHAPED |The item will be expanded as much as |
677 | |possible while also maintaining its |
679 +----------------------------+------------------------------------------+
680 |- wx.FIXED_MINSIZE |Normally wx.Sizers will use |
681 | |`wx.Window.GetMinSize` or |
682 | |`wx.Window.GetBestSize` to determine what |
683 | |the minimal size of window items should |
684 | |be, and will use that size to calculate |
685 | |the layout. This allows layouts to adjust |
686 | |when an item changes and it's best size |
687 | |becomes different. If you would rather |
688 | |have a window item stay the size it |
689 | |started with then use wx.FIXED_MINSIZE. |
690 +----------------------------+------------------------------------------+
691 |- wx.ALIGN_CENTER |The wx.ALIGN flags allow you to specify |
692 |- wx.ALIGN_LEFT |the alignment of the item within the space|
693 |- wx.ALIGN_RIGHT |allotted to it by the sizer, ajusted for |
694 |- wx.ALIGN_TOP |the border if any. |
695 |- wx.ALIGN_BOTTOM | |
696 |- wx.ALIGN_CENTER_VERTICAL | |
697 |- wx.ALIGN_CENTER_HORIZONTAL| |
698 +----------------------------+------------------------------------------+
701 :param border: Determines the border width, if the *flag*
702 parameter is set to include any border flag.
704 :param userData: Allows an extra object to be attached to the
705 sizer item, for use in derived classes when sizing information
706 is more complex than the *proportion* and *flag* will allow for.
709 wxSizerItem* Add(PyObject* item, int proportion=0, int flag=0, int border=0,
710 PyObject* userData=NULL) {
712 wxPyUserData* data = NULL;
713 wxPyBlock_t blocked = wxPyBeginBlockThreads();
714 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
715 if ( userData && (info.window || info.sizer || info.gotSize) )
716 data = new wxPyUserData(userData);
718 PyObject_SetAttrString(item,"thisown",Py_False);
719 wxPyEndBlockThreads(blocked);
721 // Now call the real Add method if a valid item type was found
723 return self->Add(info.window, proportion, flag, border, data);
724 else if ( info.sizer )
725 return self->Add(info.sizer, proportion, flag, border, data);
726 else if (info.gotSize)
727 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
728 proportion, flag, border, data);
735 "AddF(self, item, wx.SizerFlags flags) -> wx.SizerItem",
736 "Similar to `Add` but uses the `wx.SizerFlags` convenience class for
737 setting the various flags, options and borders.", "");
738 wxSizerItem* AddF(PyObject* item, wxSizerFlags& flags) {
740 wxPyBlock_t blocked = wxPyBeginBlockThreads();
741 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
743 PyObject_SetAttrString(item,"thisown",Py_False);
744 wxPyEndBlockThreads(blocked);
746 // Now call the real Add method if a valid item type was found
748 return self->Add(info.window, flags);
749 else if ( info.sizer )
750 return self->Add(info.sizer, flags);
751 else if (info.gotSize)
752 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
753 flags.GetProportion(),
755 flags.GetBorderInPixels());
763 "Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
764 PyObject userData=None) -> wx.SizerItem",
766 "Inserts a new item into the list of items managed by this sizer before
767 the item at index *before*. See `Add` for a description of the parameters.", "");
768 wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0,
769 int border=0, PyObject* userData=NULL) {
771 wxPyUserData* data = NULL;
772 wxPyBlock_t blocked = wxPyBeginBlockThreads();
773 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
774 if ( userData && (info.window || info.sizer || info.gotSize) )
775 data = new wxPyUserData(userData);
777 PyObject_SetAttrString(item,"thisown",Py_False);
778 wxPyEndBlockThreads(blocked);
780 // Now call the real Insert method if a valid item type was found
782 return self->Insert(before, info.window, proportion, flag, border, data);
783 else if ( info.sizer )
784 return self->Insert(before, info.sizer, proportion, flag, border, data);
785 else if (info.gotSize)
786 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
787 proportion, flag, border, data);
795 "InsertF(self, int before, item, wx.SizerFlags flags) -> wx.SizerItem",
796 "Similar to `Insert`, but uses the `wx.SizerFlags` convenience class
797 for setting the various flags, options and borders.", "");
798 wxSizerItem* InsertF(int before, PyObject* item, wxSizerFlags& flags) {
800 wxPyBlock_t blocked = wxPyBeginBlockThreads();
801 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
803 PyObject_SetAttrString(item,"thisown",Py_False);
804 wxPyEndBlockThreads(blocked);
806 // Now call the real Insert method if a valid item type was found
808 return self->Insert(before, info.window, flags);
809 else if ( info.sizer )
810 return self->Insert(before, info.sizer, flags);
811 else if (info.gotSize)
812 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
813 flags.GetProportion(),
815 flags.GetBorderInPixels());
824 "Prepend(self, item, int proportion=0, int flag=0, int border=0,
825 PyObject userData=None) -> wx.SizerItem",
827 "Adds a new item to the begining of the list of sizer items managed by
828 this sizer. See `Add` for a description of the parameters.", "");
829 wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
830 PyObject* userData=NULL) {
832 wxPyUserData* data = NULL;
833 wxPyBlock_t blocked = wxPyBeginBlockThreads();
834 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
835 if ( userData && (info.window || info.sizer || info.gotSize) )
836 data = new wxPyUserData(userData);
838 PyObject_SetAttrString(item,"thisown",Py_False);
839 wxPyEndBlockThreads(blocked);
841 // Now call the real Prepend method if a valid item type was found
843 return self->Prepend(info.window, proportion, flag, border, data);
844 else if ( info.sizer )
845 return self->Prepend(info.sizer, proportion, flag, border, data);
846 else if (info.gotSize)
847 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
848 proportion, flag, border, data);
856 "PrependF(self, item, wx.SizerFlags flags) -> wx.SizerItem",
857 "Similar to `Prepend` but uses the `wx.SizerFlags` convenience class
858 for setting the various flags, options and borders.", "");
859 wxSizerItem* PrependF(PyObject* item, wxSizerFlags& flags) {
861 wxPyBlock_t blocked = wxPyBeginBlockThreads();
862 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
864 PyObject_SetAttrString(item,"thisown",Py_False);
865 wxPyEndBlockThreads(blocked);
867 // Now call the real Add method if a valid item type was found
869 return self->Prepend(info.window, flags);
870 else if ( info.sizer )
871 return self->Prepend(info.sizer, flags);
872 else if (info.gotSize)
873 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
874 flags.GetProportion(),
876 flags.GetBorderInPixels());
884 "Remove(self, item) -> bool",
885 "Removes an item from the sizer and destroys it. This method does not
886 cause any layout or resizing to take place, call `Layout` to update
887 the layout on screen after removing a child from the sizer. The
888 *item* parameter can be either a window, a sizer, or the zero-based
889 index of an item to remove. Returns True if the child item was found
892 :note: For historical reasons calling this method with a `wx.Window`
893 parameter is depreacted, as it will not be able to destroy the
894 window since it is owned by its parent. You should use `Detach`
897 bool Remove(PyObject* item) {
898 wxPyBlock_t blocked = wxPyBeginBlockThreads();
899 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
900 wxPyEndBlockThreads(blocked);
902 return false; //self->Remove(info.window);
903 else if ( info.sizer )
904 return self->Remove(info.sizer);
905 else if ( info.gotPos )
906 return self->Remove(info.pos);
913 "Detach(self, item) -> bool",
914 "Detaches an item from the sizer without destroying it. This method
915 does not cause any layout or resizing to take place, call `Layout` to
916 do so. The *item* parameter can be either a window, a sizer, or the
917 zero-based index of the item to be detached. Returns True if the child item
918 was found and detached.", "");
919 bool Detach(PyObject* item) {
920 wxPyBlock_t blocked = wxPyBeginBlockThreads();
921 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
922 wxPyEndBlockThreads(blocked);
924 return self->Detach(info.window);
925 else if ( info.sizer )
926 return self->Detach(info.sizer);
927 else if ( info.gotPos )
928 return self->Detach(info.pos);
935 "GetItem(self, item, recursive=False) -> wx.SizerItem",
936 "Returns the `wx.SizerItem` which holds the *item* given. The *item*
937 parameter can be either a window, a sizer, or the zero-based index of
938 the item to be found.", "");
939 wxSizerItem* GetItem(PyObject* item, bool recursive=false) {
940 wxPyBlock_t blocked = wxPyBeginBlockThreads();
941 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
942 wxPyEndBlockThreads(blocked);
944 return self->GetItem(info.window, recursive);
945 else if ( info.sizer )
946 return self->GetItem(info.sizer, recursive);
947 else if ( info.gotPos )
948 return self->GetItem(info.pos);
954 void _SetItemMinSize(PyObject* item, const wxSize& size) {
955 wxPyBlock_t blocked = wxPyBeginBlockThreads();
956 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
957 wxPyEndBlockThreads(blocked);
959 self->SetItemMinSize(info.window, size);
960 else if ( info.sizer )
961 self->SetItemMinSize(info.sizer, size);
962 else if ( info.gotPos )
963 self->SetItemMinSize(info.pos, size);
969 bool, Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false ));
970 %Rename(_ReplaceSizer,
971 bool, Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false ));
972 %Rename(_ReplaceItem,
973 bool, Replace( size_t index, wxSizerItem *newitem ));
975 def Replace(self, olditem, item, recursive=False):
977 Detaches the given ``olditem`` from the sizer and replaces it with
978 ``item`` which can be a window, sizer, or `wx.SizerItem`. The
979 detached child is destroyed only if it is not a window, (because
980 windows are owned by their parent, not the sizer.) The
981 ``recursive`` parameter can be used to search for the given
982 element recursivly in subsizers.
984 This method does not cause any layout or resizing to take place,
985 call `Layout` to do so.
987 Returns ``True`` if the child item was found and removed.
989 if isinstance(olditem, wx.Window):
990 return self._ReplaceWin(olditem, item, recursive)
991 elif isinstance(olditem, wx.Sizer):
992 return self._ReplaceSizer(olditem, item, recursive)
993 elif isinstance(olditem, int):
994 return self._ReplaceItem(olditem, item)
996 raise TypeError("Expected Window, Sizer, or integer for first parameter.")
1001 void , SetContainingWindow(wxWindow *window),
1002 "Set (or unset) the window this sizer is used in.", "");
1005 wxWindow *, GetContainingWindow() const,
1006 "Get the window this sizer is used in.", "");
1010 def SetItemMinSize(self, item, *args):
1012 SetItemMinSize(self, item, Size size)
1014 Sets the minimum size that will be allocated for an item in the sizer.
1015 The *item* parameter can be either a window, a sizer, or the
1016 zero-based index of the item. If a window or sizer is given then it
1017 will be searched for recursivly in subsizers if neccessary.
1020 %# for backward compatibility accept separate width,height args too
1021 return self._SetItemMinSize(item, args)
1023 return self._SetItemMinSize(item, args[0])
1027 %disownarg( wxSizerItem *item );
1030 wxSizerItem* , Add( wxSizerItem *item ),
1031 "AddItem(self, SizerItem item)",
1032 "Adds a `wx.SizerItem` to the sizer.", "",
1036 wxSizerItem* , Insert( size_t index, wxSizerItem *item ),
1037 "InsertItem(self, int index, SizerItem item)",
1038 "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
1042 wxSizerItem* , Prepend( wxSizerItem *item ),
1043 "PrependItem(self, SizerItem item)",
1044 "Prepends a `wx.SizerItem` to the sizer.", "",
1047 %cleardisown( wxSizerItem *item );
1051 def AddMany(self, items):
1053 AddMany is a convenience method for adding several items
1054 to a sizer at one time. Simply pass it a list of tuples,
1055 where each tuple consists of the parameters that you
1056 would normally pass to the `Add` method.
1059 if type(item) != type(()) or (len(item) == 2 and type(item[0]) == type(1)):
1063 def AddSpacer(self, *args, **kw):
1064 """AddSpacer(int size) --> SizerItem
1066 Add a spacer that is (size,size) pixels.
1068 if args and type(args[0]) == int:
1069 return self.Add( (args[0],args[0] ), 0)
1070 else: %# otherwise stay compatible with old AddSpacer
1071 return self.Add(*args, **kw)
1072 def PrependSpacer(self, *args, **kw):
1073 """PrependSpacer(int size) --> SizerItem
1075 Prepend a spacer that is (size, size) pixels."""
1076 if args and type(args[0]) == int:
1077 return self.Prepend( (args[0],args[0] ), 0)
1078 else: %# otherwise stay compatible with old PrependSpacer
1079 return self.Prepend(*args, **kw)
1080 def InsertSpacer(self, index, *args, **kw):
1081 """InsertSpacer(int index, int size) --> SizerItem
1083 Insert a spacer at position index that is (size, size) pixels."""
1084 if args and type(args[0]) == int:
1085 return self.Insert( index, (args[0],args[0] ), 0)
1086 else: %# otherwise stay compatible with old InsertSpacer
1087 return self.Insert(index, *args, **kw)
1090 def AddStretchSpacer(self, prop=1):
1091 """AddStretchSpacer(int prop=1) --> SizerItem
1093 Add a stretchable spacer."""
1094 return self.Add((0,0), prop)
1095 def PrependStretchSpacer(self, prop=1):
1096 """PrependStretchSpacer(int prop=1) --> SizerItem
1098 Prepend a stretchable spacer."""
1099 return self.Prepend((0,0), prop)
1100 def InsertStretchSpacer(self, index, prop=1):
1101 """InsertStretchSpacer(int index, int prop=1) --> SizerItem
1103 Insert a stretchable spacer."""
1104 return self.Insert(index, (0,0), prop)
1107 %# for backwards compatibility only, please do not use in new code
1108 def AddWindow(self, *args, **kw):
1109 """Compatibility alias for `Add`."""
1110 return self.Add(*args, **kw)
1111 def AddSizer(self, *args, **kw):
1112 """Compatibility alias for `Add`."""
1113 return self.Add(*args, **kw)
1115 def PrependWindow(self, *args, **kw):
1116 """Compatibility alias for `Prepend`."""
1117 return self.Prepend(*args, **kw)
1118 def PrependSizer(self, *args, **kw):
1119 """Compatibility alias for `Prepend`."""
1120 return self.Prepend(*args, **kw)
1122 def InsertWindow(self, *args, **kw):
1123 """Compatibility alias for `Insert`."""
1124 return self.Insert(*args, **kw)
1125 def InsertSizer(self, *args, **kw):
1126 """Compatibility alias for `Insert`."""
1127 return self.Insert(*args, **kw)
1129 def RemoveWindow(self, *args, **kw):
1130 """Compatibility alias for `Remove`."""
1131 return self.Remove(*args, **kw)
1132 def RemoveSizer(self, *args, **kw):
1133 """Compatibility alias for `Remove`."""
1134 return self.Remove(*args, **kw)
1135 def RemovePos(self, *args, **kw):
1136 """Compatibility alias for `Remove`."""
1137 return self.Remove(*args, **kw)
1143 void , SetDimension( int x, int y, int width, int height ),
1144 "Call this to force the sizer to take the given dimension and thus
1145 force the items owned by the sizer to resize themselves according to
1146 the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
1150 void , SetMinSize( const wxSize &size ),
1151 "Call this to give the sizer a minimal size. Normally, the sizer will
1152 calculate its minimal size based purely on how much space its children
1153 need. After calling this method `GetMinSize` will return either the
1154 minimal size as requested by its children or the minimal size set
1155 here, depending on which is bigger.", "");
1160 "Returns the current size of the space managed by the sizer.", "");
1163 wxPoint , GetPosition(),
1164 "Returns the current position of the sizer's managed space.", "");
1167 wxSize , GetMinSize(),
1168 "Returns the minimal size of the sizer. This is either the combined
1169 minimal size of all the children and their borders or the minimal size
1170 set by SetMinSize, depending on which is bigger.", "");
1174 def GetSizeTuple(self):
1175 return self.GetSize().Get()
1176 def GetPositionTuple(self):
1177 return self.GetPosition().Get()
1178 def GetMinSizeTuple(self):
1179 return self.GetMinSize().Get()
1183 virtual void , RecalcSizes(),
1184 "Using the sizes calculated by `CalcMin` reposition and resize all the
1185 items managed by this sizer. You should not need to call this directly as
1186 it is called by `Layout`.", "");
1189 virtual wxSize , CalcMin(),
1190 "This method is where the sizer will do the actual calculation of its
1191 children's minimal sizes. You should not need to call this directly as
1192 it is called by `Layout`.", "");
1197 "This method will force the recalculation and layout of the items
1198 controlled by the sizer using the current space allocated to the
1199 sizer. Normally this is called automatically from the owning window's
1200 EVT_SIZE handler, but it is also useful to call it from user code when
1201 one of the items in a sizer change size, or items are added or
1206 wxSize , Fit( wxWindow *window ),
1207 "Tell the sizer to resize the *window* to match the sizer's minimal
1208 size. This is commonly done in the constructor of the window itself in
1209 order to set its initial size to match the needs of the children as
1210 determined by the sizer. Returns the new size.
1212 For a top level window this is the total window size, not the client size.", "");
1215 void , FitInside( wxWindow *window ),
1216 "Tell the sizer to resize the *virtual size* of the *window* to match the
1217 sizer's minimal size. This will not alter the on screen size of the
1218 window, but may cause the addition/removal/alteration of scrollbars
1219 required to view the virtual area in windows which manage it.
1221 :see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
1226 void , SetSizeHints( wxWindow *window ),
1227 "Tell the sizer to set (and `Fit`) the minimal size of the *window* to
1228 match the sizer's minimal size. This is commonly done in the
1229 constructor of the window itself if the window is resizable (as are
1230 many dialogs under Unix and frames on probably all platforms) in order
1231 to prevent the window from being sized smaller than the minimal size
1232 required by the sizer.", "");
1235 void , SetVirtualSizeHints( wxWindow *window ),
1236 "Tell the sizer to set the minimal size of the window virtual area to
1237 match the sizer's minimal size. For windows with managed scrollbars
1238 this will set them appropriately.
1240 :see: `wx.ScrolledWindow.SetScrollbars`
1245 void , Clear( bool deleteWindows=false ),
1246 "Clear all items from the sizer, optionally destroying the window items
1250 void , DeleteWindows(),
1251 "Destroy all windows managed by the sizer.", "");
1256 "Returns all of the `wx.SizerItem` objects managed by the sizer in a
1257 list-like object.", "");
1258 wxSizerItemList& GetChildren();
1263 "Show(self, item, bool show=True, bool recursive=false) -> bool",
1264 "Shows or hides an item managed by the sizer. To make a sizer item
1265 disappear or reappear, use Show followed by `Layout`. The *item*
1266 parameter can be either a window, a sizer, or the zero-based index of
1267 the item. Use the recursive parameter to show or hide an item in a
1268 subsizer. Returns True if the item was found.", "");
1269 bool Show(PyObject* item, bool show = true, bool recursive=false) {
1270 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1271 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
1272 wxPyEndBlockThreads(blocked);
1274 return self->Show(info.window, show, recursive);
1275 else if ( info.sizer )
1276 return self->Show(info.sizer, show, recursive);
1277 else if ( info.gotPos )
1278 return self->Show(info.pos, show);
1284 "IsShown(self, item)",
1285 "Determines if the item is currently shown. To make a sizer
1286 item disappear or reappear, use Show followed by `Layout`. The *item*
1287 parameter can be either a window, a sizer, or the zero-based index of
1289 bool IsShown(PyObject* item) {
1290 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1291 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false);
1292 wxPyEndBlockThreads(blocked);
1294 return self->IsShown(info.window);
1295 else if ( info.sizer )
1296 return self->IsShown(info.sizer);
1297 else if ( info.gotPos )
1298 return self->IsShown(info.pos);
1305 def Hide(self, item, recursive=False):
1307 A convenience method for `Show` (item, False, recursive).
1309 return self.Show(item, False, recursive)
1314 void , ShowItems(bool show),
1315 "Recursively call `wx.SizerItem.Show` on all sizer items.", "");
1317 %property(Children, GetChildren, doc="See `GetChildren`");
1318 %property(ContainingWindow, GetContainingWindow, SetContainingWindow, doc="See `GetContainingWindow` and `SetContainingWindow`");
1319 %property(MinSize, GetMinSize, SetMinSize, doc="See `GetMinSize` and `SetMinSize`");
1320 %property(Position, GetPosition, doc="See `GetPosition`");
1321 %property(Size, GetSize, doc="See `GetSize`");
1325 //---------------------------------------------------------------------------
1326 // Use this one for deriving Python classes from
1329 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
1330 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
1331 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
1336 "wx.PySizer is a special version of `wx.Sizer` that has been
1337 instrumented to allow the C++ virtual methods to be overloaded in
1338 Python derived classes. You would derive from this class if you are
1339 wanting to implement a custom sizer in Python code. Simply implement
1340 `CalcMin` and `RecalcSizes` in the derived class and you're all set.
1343 class MySizer(wx.PySizer):
1345 wx.PySizer.__init__(self)
1348 for item in self.GetChildren():
1349 # calculate the total minimum width and height needed
1350 # by all items in the sizer according to this sizer's
1353 return wx.Size(width, height)
1355 def RecalcSizes(self):
1356 # find the space allotted to this sizer
1357 pos = self.GetPosition()
1358 size = self.GetSize()
1359 for item in self.GetChildren():
1360 # Recalculate (if necessary) the position and size of
1361 # each item and then call item.SetDimension to do the
1362 # actual positioning and sizing of the items within the
1363 # space alloted to this sizer.
1365 item.SetDimension(itemPos, itemSize)
1368 When `Layout` is called it first calls `CalcMin` followed by
1369 `RecalcSizes` so you can optimize a bit by saving the results of
1370 `CalcMin` and reusing them in `RecalcSizes`.
1372 :see: `wx.SizerItem`, `wx.Sizer.GetChildren`
1375 class wxPySizer : public wxSizer {
1377 %pythonAppend wxPySizer "self._setOORInfo(self);" setCallbackInfo(PySizer)
1381 "Creates a wx.PySizer. Must be called from the __init__ in the derived
1384 void _setCallbackInfo(PyObject* self, PyObject* _class);
1388 //---------------------------------------------------------------------------
1393 "The basic idea behind a box sizer is that windows will most often be
1394 laid out in rather simple basic geometry, typically in a row or a
1395 column or nested hierarchies of either. A wx.BoxSizer will lay out
1396 its items in a simple row or column, depending on the orientation
1397 parameter passed to the constructor.", "
1399 It is the unique feature of a box sizer, that it can grow in both
1400 directions (height and width) but can distribute its growth in the
1401 main direction (horizontal for a row) *unevenly* among its children.
1402 This is determined by the proportion parameter give to items when they
1403 are added to the sizer. It is interpreted as a weight factor, i.e. it
1404 can be zero, indicating that the window may not be resized at all, or
1405 above zero. If several windows have a value above zero, the value is
1406 interpreted relative to the sum of all weight factors of the sizer, so
1407 when adding two windows with a value of 1, they will both get resized
1408 equally and each will receive half of the available space after the
1409 fixed size items have been sized. If the items have unequal
1410 proportion settings then they will receive a coresondingly unequal
1411 allotment of the free space.
1413 :see: `wx.StaticBoxSizer`
1416 class wxBoxSizer : public wxSizer {
1418 %pythonAppend wxBoxSizer "self._setOORInfo(self)"
1421 wxBoxSizer(int orient = wxHORIZONTAL),
1422 "Constructor for a wx.BoxSizer. *orient* may be one of ``wx.VERTICAL``
1423 or ``wx.HORIZONTAL`` for creating either a column sizer or a row
1428 int , GetOrientation(),
1429 "Returns the current orientation of the sizer.", "");
1432 void , SetOrientation(int orient),
1433 "Resets the orientation of the sizer.", "");
1435 bool IsVertical() const;
1437 %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
1440 //---------------------------------------------------------------------------
1444 DocStr(wxStaticBoxSizer,
1445 "wx.StaticBoxSizer derives from and functions identically to the
1446 `wx.BoxSizer` and adds a `wx.StaticBox` around the items that the sizer
1447 manages. Note that this static box must be created separately and
1448 passed to the sizer constructor.", "");
1450 class wxStaticBoxSizer : public wxBoxSizer {
1452 %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)"
1455 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL),
1456 "Constructor. It takes an associated static box and the orientation
1457 *orient* as parameters - orient can be either of ``wx.VERTICAL`` or
1458 ``wx.HORIZONTAL``.", "");
1460 // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
1463 wxStaticBox *, GetStaticBox(),
1464 "Returns the static box associated with this sizer.", "");
1466 %property(StaticBox, GetStaticBox, doc="See `GetStaticBox`");
1469 //---------------------------------------------------------------------------
1474 "A grid sizer is a sizer which lays out its children in a
1475 two-dimensional table with all cells having the same size. In other
1476 words, the width of each cell within the grid is the width of the
1477 widest item added to the sizer and the height of each grid cell is the
1478 height of the tallest item. An optional vertical and/or horizontal
1479 gap between items can also be specified (in pixels.)
1481 Items are placed in the cells of the grid in the order they are added,
1482 in row-major order. In other words, the first row is filled first,
1483 then the second, and so on until all items have been added. (If
1484 neccessary, additional rows will be added as items are added.) If you
1485 need to have greater control over the cells that items are placed in
1486 then use the `wx.GridBagSizer`.
1489 class wxGridSizer: public wxSizer
1492 %pythonAppend wxGridSizer "self._setOORInfo(self)"
1495 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1496 "Constructor for a wx.GridSizer. *rows* and *cols* determine the number
1497 of columns and rows in the sizer - if either of the parameters is
1498 zero, it will be calculated to from the total number of children in
1499 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1500 define extra space between all children.", "");
1503 void , SetCols( int cols ),
1504 "Sets the number of columns in the sizer.", "");
1507 void , SetRows( int rows ),
1508 "Sets the number of rows in the sizer.", "");
1511 void , SetVGap( int gap ),
1512 "Sets the vertical gap (in pixels) between the cells in the sizer.", "");
1515 void , SetHGap( int gap ),
1516 "Sets the horizontal gap (in pixels) between cells in the sizer", "");
1520 "Returns the number of columns in the sizer.", "");
1524 "Returns the number of rows in the sizer.", "");
1528 "Returns the vertical gap (in pixels) between the cells in the sizer.", "");
1532 "Returns the horizontal gap (in pixels) between cells in the sizer.", "");
1535 def CalcRowsCols(self):
1537 CalcRowsCols() -> (rows, cols)
1539 Calculates how many rows and columns will be in the sizer based
1540 on the current number of items and also the rows, cols specified
1543 nitems = len(self.GetChildren())
1544 rows = self.GetRows()
1545 cols = self.GetCols()
1546 assert rows != 0 or cols != 0, "Grid sizer must have either rows or columns fixed"
1548 rows = (nitems + cols - 1) / cols
1550 cols = (nitems + rows - 1) / rows
1554 %property(Cols, GetCols, SetCols, doc="See `GetCols` and `SetCols`");
1555 %property(HGap, GetHGap, SetHGap, doc="See `GetHGap` and `SetHGap`");
1556 %property(Rows, GetRows, SetRows, doc="See `GetRows` and `SetRows`");
1557 %property(VGap, GetVGap, SetVGap, doc="See `GetVGap` and `SetVGap`");
1560 //---------------------------------------------------------------------------
1563 enum wxFlexSizerGrowMode
1565 // don't resize the cells in non-flexible direction at all
1566 wxFLEX_GROWMODE_NONE,
1568 // uniformly resize only the specified ones (default)
1569 wxFLEX_GROWMODE_SPECIFIED,
1571 // uniformly resize all cells
1579 DocStr(wxFlexGridSizer,
1580 "A flex grid sizer is a sizer which lays out its children in a
1581 two-dimensional table with all table cells in one row having the same
1582 height and all cells in one column having the same width, but all
1583 rows or all columns are not necessarily the same height or width as in
1586 wx.FlexGridSizer can also size items equally in one direction but
1587 unequally (\"flexibly\") in the other. If the sizer is only flexible
1588 in one direction (this can be changed using `SetFlexibleDirection`), it
1589 needs to be decided how the sizer should grow in the other (\"non
1590 flexible\") direction in order to fill the available space. The
1591 `SetNonFlexibleGrowMode` method serves this purpose.
1595 class wxFlexGridSizer: public wxGridSizer
1598 %pythonAppend wxFlexGridSizer "self._setOORInfo(self)"
1601 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1602 "Constructor for a wx.FlexGridSizer. *rows* and *cols* determine the
1603 number of columns and rows in the sizer - if either of the parameters
1604 is zero, it will be calculated to from the total number of children in
1605 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1606 define extra space between all children.", "");
1610 void , AddGrowableRow( size_t idx, int proportion = 0 ),
1611 "Specifies that row *idx* (starting from zero) should be grown if there
1612 is extra space available to the sizer.
1614 The *proportion* parameter has the same meaning as the stretch factor
1615 for the box sizers except that if all proportions are 0, then all
1616 columns are resized equally (instead of not being resized at all).", "");
1619 void , RemoveGrowableRow( size_t idx ),
1620 "Specifies that row *idx* is no longer growable.", "");
1623 void , AddGrowableCol( size_t idx, int proportion = 0 ),
1624 "Specifies that column *idx* (starting from zero) should be grown if
1625 there is extra space available to the sizer.
1627 The *proportion* parameter has the same meaning as the stretch factor
1628 for the box sizers except that if all proportions are 0, then all
1629 columns are resized equally (instead of not being resized at all).", "");
1632 void , RemoveGrowableCol( size_t idx ),
1633 "Specifies that column *idx* is no longer growable.", "");
1637 void , SetFlexibleDirection(int direction),
1638 "Specifies whether the sizer should flexibly resize its columns, rows,
1639 or both. Argument *direction* can be one of the following values. Any
1640 other value is ignored.
1642 ============== =======================================
1643 wx.VERTICAL Rows are flexibly sized.
1644 wx.HORIZONTAL Columns are flexibly sized.
1645 wx.BOTH Both rows and columns are flexibly sized
1646 (this is the default value).
1647 ============== =======================================
1649 Note that this method does not trigger relayout.
1653 int , GetFlexibleDirection(),
1654 "Returns a value that specifies whether the sizer
1655 flexibly resizes its columns, rows, or both (default).
1657 :see: `SetFlexibleDirection`", "");
1662 void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
1663 "Specifies how the sizer should grow in the non-flexible direction if
1664 there is one (so `SetFlexibleDirection` must have been called
1665 previously). Argument *mode* can be one of the following values:
1667 ========================== =================================================
1668 wx.FLEX_GROWMODE_NONE Sizer doesn't grow in the non flexible direction.
1669 wx.FLEX_GROWMODE_SPECIFIED Sizer honors growable columns/rows set with
1670 `AddGrowableCol` and `AddGrowableRow`. In this
1671 case equal sizing applies to minimum sizes of
1672 columns or rows (this is the default value).
1673 wx.FLEX_GROWMODE_ALL Sizer equally stretches all columns or rows in
1674 the non flexible direction, whether they are
1675 growable or not in the flexbile direction.
1676 ========================== =================================================
1678 Note that this method does not trigger relayout.", "");
1681 wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
1682 "Returns the value that specifies how the sizer grows in the
1683 non-flexible direction if there is one.
1685 :see: `SetNonFlexibleGrowMode`", "");
1688 // Read-only access to the row heights and col widths arrays
1690 const wxArrayInt& , GetRowHeights() const,
1691 "GetRowHeights(self) -> list",
1692 "Returns a list of integers representing the heights of each of the
1693 rows in the sizer.", "");
1696 const wxArrayInt& , GetColWidths() const,
1697 "GetColWidths(self) -> list",
1698 "Returns a list of integers representing the widths of each of the
1699 columns in the sizer.", "");
1702 %property(ColWidths, GetColWidths, doc="See `GetColWidths`");
1703 %property(FlexibleDirection, GetFlexibleDirection, SetFlexibleDirection, doc="See `GetFlexibleDirection` and `SetFlexibleDirection`");
1704 %property(NonFlexibleGrowMode, GetNonFlexibleGrowMode, SetNonFlexibleGrowMode, doc="See `GetNonFlexibleGrowMode` and `SetNonFlexibleGrowMode`");
1705 %property(RowHeights, GetRowHeights, doc="See `GetRowHeights`");
1709 //---------------------------------------------------------------------------
1711 DocStr(wxStdDialogButtonSizer,
1712 "A special sizer that knows how to order and position standard buttons
1713 in order to conform to the current platform's standards. You simply
1714 need to add each `wx.Button` to the sizer, and be sure to create the
1715 buttons using the standard ID's. Then call `Realize` and the sizer
1716 will take care of the rest.
1719 class wxStdDialogButtonSizer: public wxBoxSizer
1723 wxStdDialogButtonSizer(),
1727 void , AddButton(wxButton *button),
1728 "Use this to add the buttons to this sizer. Do not use the `Add`
1729 method in the base class.", "");
1733 "This funciton needs to be called after all the buttons have been added
1734 to the sizer. It will reorder them and position them in a platform
1735 specifc manner.", "");
1737 void SetAffirmativeButton( wxButton *button );
1738 void SetNegativeButton( wxButton *button );
1739 void SetCancelButton( wxButton *button );
1741 wxButton* GetAffirmativeButton() const;
1742 wxButton* GetApplyButton() const;
1743 wxButton* GetNegativeButton() const;
1744 wxButton* GetCancelButton() const;
1745 wxButton* GetHelpButton() const;
1747 %property(AffirmativeButton, GetAffirmativeButton, SetAffirmativeButton, doc="See `GetAffirmativeButton` and `SetAffirmativeButton`");
1748 %property(ApplyButton, GetApplyButton, doc="See `GetApplyButton`");
1749 %property(CancelButton, GetCancelButton, SetCancelButton, doc="See `GetCancelButton` and `SetCancelButton`");
1750 %property(HelpButton, GetHelpButton, doc="See `GetHelpButton`");
1751 %property(NegativeButton, GetNegativeButton, SetNegativeButton, doc="See `GetNegativeButton` and `SetNegativeButton`");
1755 //---------------------------------------------------------------------------