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 "The wx.SizerItem class is used to track the position, size and other
 
 175 attributes of each item managed by a `wx.Sizer`. It is not usually
 
 176 necessary to use this class because the sizer elements can also be
 
 177 identified by their positions or window or sizer references but
 
 178 sometimes it may be more convenient to use wx.SizerItem directly.
 
 179 Also, custom classes derived from `wx.PySizer` will probably need to
 
 180 use the collection of wx.SizerItems held by wx.Sizer when calculating
 
 183 :see: `wx.Sizer`, `wx.GBSizerItem`", "");
 
 185 class wxSizerItem : public wxObject {
 
 189         "Constructs an empty wx.SizerItem.  Either a window, sizer or spacer
 
 190 size will need to be set before this item can be used in a Sizer.
 
 192 You will probably never need to create a wx.SizerItem directly as they
 
 193 are created automatically when the sizer's Add, Insert or Prepend
 
 196 :see: `wx.SizerItemSpacer`, `wx.SizerItemWindow`, `wx.SizerItemSizer`", "");
 
 204             wxSizerItem( wxWindow *window, int proportion, int flag,
 
 205                          int border, PyObject* userData=NULL ),
 
 206             "Constructs a `wx.SizerItem` for tracking a window.", "");
 
 208         %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, int flag,
 
 209                                                   int border, PyObject* userData=NULL ))
 
 211             wxPyUserData* data = NULL;
 
 213                 wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 214                 data = new wxPyUserData(userData);
 
 215                 wxPyEndBlockThreads(blocked);
 
 217             return new wxSizerItem(window, proportion, flag, border, data);
 
 222             wxSizerItem( int width, int height, int proportion, int flag,
 
 223                          int border, PyObject* userData=NULL),
 
 224             "Constructs a `wx.SizerItem` for tracking a spacer.", "");
 
 226         %RenameCtor(SizerItemSpacer,  wxSizerItem( int width, int height, int proportion, int flag,
 
 227                                                    int border, PyObject* userData=NULL))
 
 229             wxPyUserData* data = NULL;
 
 231                 wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 232                 data = new wxPyUserData(userData);
 
 233                 wxPyEndBlockThreads(blocked);
 
 235             return new wxSizerItem(width, height, proportion, flag, border, data);
 
 239             wxSizerItem( wxSizer *sizer, int proportion, int flag,
 
 240                          int border, PyObject* userData=NULL ),
 
 241             "Constructs a `wx.SizerItem` for tracking a subsizer", "");
 
 243         %disownarg( wxSizer *sizer );
 
 244         %RenameCtor(SizerItemSizer,  wxSizerItem( wxSizer *sizer, int proportion, int flag,
 
 245                                                   int border, PyObject* userData=NULL ))
 
 247             wxPyUserData* data = NULL;
 
 249                 wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 250                 data = new wxPyUserData(userData);
 
 251                 wxPyEndBlockThreads(blocked);
 
 253             return new wxSizerItem(sizer, proportion, flag, border, data);
 
 255         %cleardisown( wxSizer *sizer );
 
 261         void , DeleteWindows(),
 
 262         "Destroy the window or the windows in a subsizer, depending on the type
 
 266         void , DetachSizer(),
 
 267         "Enable deleting the SizerItem without destroying the contained sizer.", "");
 
 272         "Get the current size of the item, as set in the last Layout.", "");
 
 276         "Calculates the minimum desired size for the item, including any space
 
 277 needed by borders.", "");
 
 280         void , SetDimension( const wxPoint& pos, const wxSize& size ),
 
 281         "Set the position and size of the space allocated for this item by the
 
 282 sizer, and adjust the position and size of the item (window or
 
 283 subsizer) to be within that space taking alignment and borders into
 
 288         wxSize , GetMinSize(),
 
 289         "Get the minimum size needed for the item.", "");
 
 292         wxSize , GetMinSizeWithBorder() const,
 
 293         "Get the minimum size needed for the item with space for the borders
 
 294 added, if needed.", "");
 
 297         void , SetInitSize( int x, int y ),
 
 302            "Set the ratio item attribute.", "");
 
 303     %Rename(SetRatioWH, void, SetRatio( int width, int height ));
 
 304     %Rename(SetRatioSize, void, SetRatio( const wxSize& size ));
 
 305     void SetRatio( float ratio );
 
 309         "Set the ratio item attribute.", "");
 
 313         "Returns the rectangle that the sizer item should occupy", "");
 
 318         "Is this sizer item a window?", "");
 
 322         "Is this sizer item a subsizer?", "");
 
 326         "Is this sizer item a spacer?", "");
 
 330         void , SetProportion( int proportion ),
 
 331         "Set the proportion value for this item.", "");
 
 334         int , GetProportion(),
 
 335         "Get the proportion value for this item.", "");
 
 337     %pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
 
 338     %pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
 
 342         void , SetFlag( int flag ),
 
 343         "Set the flag value for this item.", "");
 
 347         "Get the flag value for this item.", "");
 
 351         void , SetBorder( int border ),
 
 352         "Set the border value for this item.", "");
 
 356         "Get the border value for this item.", "");
 
 361         wxWindow *, GetWindow(),
 
 362         "Get the window (if any) that is managed by this sizer item.", "");
 
 366         wxSizer *, GetSizer(),
 
 367         "Get the subsizer (if any) that is managed by this sizer item.", "");
 
 370         wxSize , GetSpacer(),
 
 371         "Get the size of the spacer managed by this sizer item.", "");
 
 377         void , SetWindow( wxWindow *window ),
 
 378         "Set the window to be managed by this sizer item.", "");
 
 380     %disownarg( wxSizer *sizer );
 
 382         void , SetSizer( wxSizer *sizer ),
 
 383         "Set the subsizer to be managed by this sizer item.", "");
 
 384     %cleardisown( wxSizer *sizer );
 
 387         void , SetSpacer( const wxSize &size ),
 
 388         "Set the size of the spacer to be managed by this sizer item.", "");
 
 391         SetWindow = wx._deprecated(SetWindow, "Use `AssignWindow` instead.")
 
 392         SetSizer = wx._deprecated(SetSizer,   "Use `AssignSizer` instead.")
 
 393         SetSpacer = wx._deprecated(SetSpacer, "Use `AssignSpacer` instead.")
 
 399         void , AssignWindow(wxWindow *window),
 
 400         "Set the window to be managed by this sizer item.", "");
 
 403         void , AssignSizer(wxSizer *sizer),
 
 404         "Set the subsizer to be managed by this sizer item.", "");
 
 407         void , AssignSpacer(const wxSize& size),
 
 408         "Set the size of the spacer to be managed by this sizer item.", "");
 
 414         void , Show( bool show ),
 
 415         "Set the show item attribute, which sizers use to determine if the item
 
 416 is to be made part of the layout or not. If the item is tracking a
 
 417 window then it is shown or hidden as needed.", "");
 
 421         "Is the item to be shown in the layout?", "");
 
 425         wxPoint , GetPosition(),
 
 426         "Returns the current position of the item, as set in the last Layout.", "");
 
 429     // wxObject* GetUserData();
 
 431         // Assume that the user data is a wxPyUserData object and return the contents
 
 434                "Returns the userData associated with this sizer item, or None if there
 
 436         PyObject* GetUserData() {
 
 437             wxPyUserData* data = (wxPyUserData*)self->GetUserData();
 
 439                 Py_INCREF(data->m_obj);
 
 448                "Associate a Python object with this sizer item.", "");
 
 449         void SetUserData(PyObject* userData) {
 
 450             wxPyUserData* data = NULL;
 
 452                 wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 453                 data = new wxPyUserData(userData);
 
 454                 wxPyEndBlockThreads(blocked);
 
 456             self->SetUserData(data);
 
 460     %property(Border, GetBorder, SetBorder, doc="See `GetBorder` and `SetBorder`");
 
 461     %property(Flag, GetFlag, SetFlag, doc="See `GetFlag` and `SetFlag`");
 
 462     %property(MinSize, GetMinSize, doc="See `GetMinSize`");
 
 463     %property(MinSizeWithBorder, GetMinSizeWithBorder, doc="See `GetMinSizeWithBorder`");
 
 464     %property(Position, GetPosition, doc="See `GetPosition`");
 
 465     %property(Proportion, GetProportion, SetProportion, doc="See `GetProportion` and `SetProportion`");
 
 466     %property(Ratio, GetRatio, SetRatio, doc="See `GetRatio` and `SetRatio`");
 
 467     %property(Rect, GetRect, doc="See `GetRect`");
 
 468     %property(Size, GetSize, doc="See `GetSize`");
 
 469     %property(Sizer, GetSizer, AssignSizer, doc="See `GetSizer` and `AssignSizer`");
 
 470     %property(Spacer, GetSpacer, AssignSpacer, doc="See `GetSpacer` and `AssignSpacer`");
 
 471     %property(UserData, GetUserData, SetUserData, doc="See `GetUserData` and `SetUserData`");
 
 472     %property(Window, GetWindow, AssignWindow, doc="See `GetWindow` and `AssignWindow`");
 
 476 //---------------------------------------------------------------------------
 
 479 // Figure out the type of the sizer item
 
 481 struct wxPySizerItemInfo {
 
 483         : window(NULL), sizer(NULL), gotSize(false),
 
 484           size(wxDefaultSize), gotPos(false), pos(-1)
 
 495 static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
 
 497     wxPySizerItemInfo info;
 
 499     wxSize* sizePtr = &size;
 
 501     // Find out what the type of the item is
 
 503     if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
 
 508         if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
 
 512             // try wxSize or (w,h)
 
 513             if ( checkSize && wxSize_helper(item, &sizePtr)) {
 
 514                 info.size = *sizePtr;
 
 519             if (checkIdx && PyInt_Check(item)) {
 
 520                 info.pos = PyInt_AsLong(item);
 
 526     if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
 
 527         // no expected type, figure out what kind of error message to generate
 
 528         if ( !checkSize && !checkIdx )
 
 529             PyErr_SetString(PyExc_TypeError, "wx.Window or wx.Sizer expected for item");
 
 530         else if ( checkSize && !checkIdx )
 
 531             PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item");
 
 532         else if ( !checkSize && checkIdx)
 
 533             PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer or int (position) expected for item");
 
 535             // can this one happen?
 
 536             PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) or int (position) expected for item");
 
 547 "wx.Sizer is the abstract base class used for laying out subwindows in
 
 548 a window.  You cannot use wx.Sizer directly; instead, you will have to
 
 549 use one of the sizer classes derived from it such as `wx.BoxSizer`,
 
 550 `wx.StaticBoxSizer`, `wx.GridSizer`, `wx.FlexGridSizer` and
 
 553 The concept implemented by sizers in wxWidgets is closely related to
 
 554 layout tools in other GUI toolkits, such as Java's AWT, the GTK
 
 555 toolkit or the Qt toolkit. It is based upon the idea of the individual
 
 556 subwindows reporting their minimal required size and their ability to
 
 557 get stretched if the size of the parent window has changed. This will
 
 558 most often mean that the programmer does not set the original size of
 
 559 a dialog in the beginning, rather the dialog will assigned a sizer and
 
 560 this sizer will be queried about the recommended size. The sizer in
 
 561 turn will query its children, which can be normal windows or contorls,
 
 562 empty space or other sizers, so that a hierarchy of sizers can be
 
 563 constructed. Note that wxSizer does not derive from wxWindow and thus
 
 564 do not interfere with tab ordering and requires very little resources
 
 565 compared to a real window on screen.
 
 567 What makes sizers so well fitted for use in wxWidgets is the fact that
 
 568 every control reports its own minimal size and the algorithm can
 
 569 handle differences in font sizes or different window (dialog item)
 
 570 sizes on different platforms without problems. If for example the
 
 571 standard font as well as the overall design of Mac widgets requires
 
 572 more space than on Windows, then the initial size of a dialog using a
 
 573 sizer will automatically be bigger on Mac than on Windows.", "
 
 575 Sizers may also be used to control the layout of custom drawn items on
 
 576 the window.  The `Add`, `Insert`, and `Prepend` functions return a
 
 577 pointer to the newly added `wx.SizerItem`. Just add empty space of the
 
 578 desired size and attributes, and then use the `wx.SizerItem.GetRect`
 
 579 method to determine where the drawing operations should take place.
 
 581 :note: If you wish to create a custom sizer class in wxPython you
 
 582     should derive the class from `wx.PySizer` in order to get
 
 583     Python-aware capabilities for the various virtual methods.
 
 587 :todo: More dscriptive text here along with some pictures...
 
 591 class wxSizer : public wxObject {
 
 593     // wxSizer();      ****  abstract, can't instantiate
 
 598         void _setOORInfo(PyObject* _self) {
 
 599             if (!self->GetClientObject())
 
 600                 self->SetClientObject(new wxPyOORClientData(_self));
 
 604                 "Add(self, item, int proportion=0, int flag=0, int border=0,
 
 605     PyObject userData=None) -> wx.SizerItem",
 
 607                 "Appends a child item to the sizer.", "
 
 609     :param item:  The item can be one of three kinds of objects:
 
 611         - **window**: A `wx.Window` to be managed by the sizer. Its
 
 612           minimal size (either set explicitly by the user or
 
 613           calculated internally when constructed with wx.DefaultSize)
 
 614           is interpreted as the minimal size to use when laying out
 
 615           item in the sizer.  This is particularly useful in
 
 616           connection with `wx.Window.SetSizeHints`.
 
 618         - **sizer**: The (child-)sizer to be added to the sizer. This
 
 619           allows placing a child sizer in a sizer and thus to create
 
 620           hierarchies of sizers (for example a vertical box as the top
 
 621           sizer and several horizontal boxes on the level beneath).
 
 623         - **size**: A `wx.Size` or a 2-element sequence of integers
 
 624           that represents the width and height of a spacer to be added
 
 625           to the sizer. Adding spacers to sizers gives more
 
 626           flexibility in the design of dialogs; imagine for example a
 
 627           horizontal box with two buttons at the bottom of a dialog:
 
 628           you might want to insert a space between the two buttons and
 
 629           make that space stretchable using the *proportion* value and
 
 630           the result will be that the left button will be aligned with
 
 631           the left side of the dialog and the right button with the
 
 632           right side - the space in between will shrink and grow with
 
 635     :param proportion: Although the meaning of this parameter is
 
 636         undefined in wx.Sizer, it is used in `wx.BoxSizer` to indicate
 
 637         if a child of a sizer can change its size in the main
 
 638         orientation of the wx.BoxSizer - where 0 stands for not
 
 639         changeable and a value of more than zero is interpreted
 
 640         relative (a proportion of the total) to the value of other
 
 641         children of the same wx.BoxSizer. For example, you might have
 
 642         a horizontal wx.BoxSizer with three children, two of which are
 
 643         supposed to change their size with the sizer. Then the two
 
 644         stretchable windows should each be given *proportion* value of
 
 645         1 to make them grow and shrink equally with the sizer's
 
 646         horizontal dimension.  But if one of them had a *proportion*
 
 647         value of 2 then it would get a double share of the space
 
 648         available after the fixed size items are positioned.
 
 650     :param flag: This parameter can be used to set a number of flags
 
 651         which can be combined using the binary OR operator ``|``. Two
 
 652         main behaviours are defined using these flags. One is the
 
 653         border around a window: the *border* parameter determines the
 
 654         border width whereas the flags given here determine which
 
 655         side(s) of the item that the border will be added. The other
 
 656         flags determine how the sizer item behaves when the space
 
 657         allotted to the sizer changes, and is somewhat dependent on
 
 658         the specific kind of sizer used.
 
 660         +----------------------------+------------------------------------------+
 
 661         |- wx.TOP                    |These flags are used to specify           |
 
 662         |- wx.BOTTOM                 |which side(s) of the sizer item that      |
 
 663         |- wx.LEFT                   |the *border* width will apply to.         |
 
 667         +----------------------------+------------------------------------------+
 
 668         |- wx.EXPAND                 |The item will be expanded to fill         |
 
 669         |                            |the space allotted to the item.           |
 
 670         +----------------------------+------------------------------------------+
 
 671         |- wx.SHAPED                 |The item will be expanded as much as      |
 
 672         |                            |possible while also maintaining its       |
 
 674         +----------------------------+------------------------------------------+
 
 675         |- wx.FIXED_MINSIZE          |Normally wx.Sizers will use               |
 
 676         |                            |`wx.Window.GetMinSize` or                 |
 
 677         |                            |`wx.Window.GetBestSize` to determine what |
 
 678         |                            |the minimal size of window items should   |
 
 679         |                            |be, and will use that size to calculate   |
 
 680         |                            |the layout. This allows layouts to adjust |
 
 681         |                            |when an item changes and it's best size   |
 
 682         |                            |becomes different. If you would rather    |
 
 683         |                            |have a window item stay the size it       |
 
 684         |                            |started with then use wx.FIXED_MINSIZE.   |
 
 685         +----------------------------+------------------------------------------+
 
 686         |- wx.ALIGN_CENTER           |The wx.ALIGN flags allow you to specify   |
 
 687         |- wx.ALIGN_LEFT             |the alignment of the item within the space|
 
 688         |- wx.ALIGN_RIGHT            |allotted to it by the sizer, ajusted for  |
 
 689         |- wx.ALIGN_TOP              |the border if any.                        |
 
 690         |- wx.ALIGN_BOTTOM           |                                          |
 
 691         |- wx.ALIGN_CENTER_VERTICAL  |                                          |
 
 692         |- wx.ALIGN_CENTER_HORIZONTAL|                                          |
 
 693         +----------------------------+------------------------------------------+
 
 696     :param border: Determines the border width, if the *flag*
 
 697         parameter is set to include any border flag.
 
 699     :param userData: Allows an extra object to be attached to the
 
 700         sizer item, for use in derived classes when sizing information
 
 701         is more complex than the *proportion* and *flag* will allow for.
 
 704         wxSizerItem*  Add(PyObject* item, int proportion=0, int flag=0, int border=0,
 
 705                           PyObject* userData=NULL) {
 
 707             wxPyUserData* data = NULL;
 
 708             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 709             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 710             if ( userData && (info.window || info.sizer || info.gotSize) )
 
 711                 data = new wxPyUserData(userData);
 
 713                 PyObject_SetAttrString(item,"thisown",Py_False);
 
 714             wxPyEndBlockThreads(blocked);
 
 716             // Now call the real Add method if a valid item type was found
 
 718                 return self->Add(info.window, proportion, flag, border, data);
 
 719             else if ( info.sizer )
 
 720                 return self->Add(info.sizer, proportion, flag, border, data);
 
 721             else if (info.gotSize)
 
 722                 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
 
 723                                  proportion, flag, border, data);
 
 730                 "AddF(self, item, wx.SizerFlags flags) -> wx.SizerItem",
 
 731                 "Similar to `Add` but uses the `wx.SizerFlags` convenience class for
 
 732 setting the various flags, options and borders.", "");
 
 733         wxSizerItem* AddF(PyObject* item, wxSizerFlags& flags) {
 
 735             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 736             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 738                 PyObject_SetAttrString(item,"thisown",Py_False);
 
 739             wxPyEndBlockThreads(blocked);
 
 741             // Now call the real Add method if a valid item type was found
 
 743                 return self->Add(info.window, flags);
 
 744             else if ( info.sizer )
 
 745                 return self->Add(info.sizer, flags);
 
 746             else if (info.gotSize)
 
 747                 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
 
 748                                  flags.GetProportion(),
 
 750                                  flags.GetBorderInPixels());
 
 758                 "Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
 
 759     PyObject userData=None) -> wx.SizerItem",
 
 761                 "Inserts a new item into the list of items managed by this sizer before
 
 762 the item at index *before*.  See `Add` for a description of the parameters.", "");
 
 763         wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0,
 
 764                             int border=0, PyObject* userData=NULL) {
 
 766             wxPyUserData* data = NULL;
 
 767             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 768             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 769             if ( userData && (info.window || info.sizer || info.gotSize) )
 
 770                 data = new wxPyUserData(userData);
 
 772                 PyObject_SetAttrString(item,"thisown",Py_False);
 
 773             wxPyEndBlockThreads(blocked);
 
 775             // Now call the real Insert method if a valid item type was found
 
 777                 return self->Insert(before, info.window, proportion, flag, border, data);
 
 778             else if ( info.sizer )
 
 779                 return self->Insert(before, info.sizer, proportion, flag, border, data);
 
 780             else if (info.gotSize)
 
 781                 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
 
 782                                     proportion, flag, border, data);
 
 790                 "InsertF(self, int before, item, wx.SizerFlags flags) -> wx.SizerItem",
 
 791                 "Similar to `Insert`, but uses the `wx.SizerFlags` convenience class
 
 792 for setting the various flags, options and borders.", "");
 
 793         wxSizerItem* InsertF(int before, PyObject* item, wxSizerFlags& flags) {
 
 795             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 796             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 798                 PyObject_SetAttrString(item,"thisown",Py_False);
 
 799             wxPyEndBlockThreads(blocked);
 
 801             // Now call the real Insert method if a valid item type was found
 
 803                 return self->Insert(before, info.window, flags);
 
 804             else if ( info.sizer )
 
 805                 return self->Insert(before, info.sizer, flags);
 
 806             else if (info.gotSize)
 
 807                 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
 
 808                                     flags.GetProportion(),
 
 810                                     flags.GetBorderInPixels());
 
 819                 "Prepend(self, item, int proportion=0, int flag=0, int border=0,
 
 820     PyObject userData=None) -> wx.SizerItem",
 
 822                "Adds a new item to the begining of the list of sizer items managed by
 
 823 this sizer.  See `Add` for a description of the parameters.", "");
 
 824         wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
 
 825                              PyObject* userData=NULL) {
 
 827             wxPyUserData* data = NULL;
 
 828             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 829             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 830             if ( userData && (info.window || info.sizer || info.gotSize) )
 
 831                 data = new wxPyUserData(userData);
 
 833                 PyObject_SetAttrString(item,"thisown",Py_False);
 
 834             wxPyEndBlockThreads(blocked);
 
 836             // Now call the real Prepend method if a valid item type was found
 
 838                 return self->Prepend(info.window, proportion, flag, border, data);
 
 839             else if ( info.sizer )
 
 840                 return self->Prepend(info.sizer, proportion, flag, border, data);
 
 841             else if (info.gotSize)
 
 842                 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
 
 843                                      proportion, flag, border, data);
 
 851                 "PrependF(self, item, wx.SizerFlags flags) -> wx.SizerItem",
 
 852                 "Similar to `Prepend` but uses the `wx.SizerFlags` convenience class
 
 853 for setting the various flags, options and borders.", "");
 
 854         wxSizerItem* PrependF(PyObject* item, wxSizerFlags& flags) {
 
 856             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 857             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 859                 PyObject_SetAttrString(item,"thisown",Py_False);
 
 860             wxPyEndBlockThreads(blocked);
 
 862             // Now call the real Add method if a valid item type was found
 
 864                 return self->Prepend(info.window, flags);
 
 865             else if ( info.sizer )
 
 866                 return self->Prepend(info.sizer, flags);
 
 867             else if (info.gotSize)
 
 868                 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
 
 869                                      flags.GetProportion(),
 
 871                                      flags.GetBorderInPixels());
 
 879                 "Remove(self, item) -> bool",
 
 880                 "Removes an item from the sizer and destroys it.  This method does not
 
 881 cause any layout or resizing to take place, call `Layout` to update
 
 882 the layout on screen after removing a child from the sizer.  The
 
 883 *item* parameter can be either a window, a sizer, or the zero-based
 
 884 index of an item to remove.  Returns True if the child item was found
 
 887 :note: For historical reasons calling this method with a `wx.Window`
 
 888     parameter is depreacted, as it will not be able to destroy the
 
 889     window since it is owned by its parent.  You should use `Detach`
 
 892         bool Remove(PyObject* item) {
 
 893             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 894             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 895             wxPyEndBlockThreads(blocked);
 
 897                 return false; //self->Remove(info.window);
 
 898             else if ( info.sizer )
 
 899                 return self->Remove(info.sizer);
 
 900             else if ( info.gotPos )
 
 901                 return self->Remove(info.pos);
 
 908                 "Detach(self, item) -> bool",
 
 909                 "Detaches an item from the sizer without destroying it.  This method
 
 910 does not cause any layout or resizing to take place, call `Layout` to
 
 911 do so.  The *item* parameter can be either a window, a sizer, or the
 
 912 zero-based index of the item to be detached.  Returns True if the child item
 
 913 was found and detached.", "");
 
 914         bool Detach(PyObject* item) {
 
 915             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 916             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 917             wxPyEndBlockThreads(blocked);
 
 919                 return self->Detach(info.window);
 
 920             else if ( info.sizer )
 
 921                 return self->Detach(info.sizer);
 
 922             else if ( info.gotPos )
 
 923                 return self->Detach(info.pos);
 
 930                 "GetItem(self, item, recursive=False) -> wx.SizerItem",
 
 931                 "Returns the `wx.SizerItem` which holds the *item* given.  The *item*
 
 932 parameter can be either a window, a sizer, or the zero-based index of
 
 933 the item to be found.", "");
 
 934         wxSizerItem* GetItem(PyObject* item, bool recursive=false) {
 
 935             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 936             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 937             wxPyEndBlockThreads(blocked);
 
 939                 return self->GetItem(info.window, recursive);
 
 940             else if ( info.sizer )
 
 941                 return self->GetItem(info.sizer, recursive);
 
 942             else if ( info.gotPos )
 
 943                 return self->GetItem(info.pos);
 
 949         void _SetItemMinSize(PyObject* item, const wxSize& size) {
 
 950             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 951             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 952             wxPyEndBlockThreads(blocked);
 
 954                 self->SetItemMinSize(info.window, size);
 
 955             else if ( info.sizer )
 
 956                 self->SetItemMinSize(info.sizer, size);
 
 957             else if ( info.gotPos )
 
 958                 self->SetItemMinSize(info.pos, size);
 
 964             bool, Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false ));
 
 965     %Rename(_ReplaceSizer,
 
 966             bool, Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false ));
 
 967     %Rename(_ReplaceItem,
 
 968             bool, Replace( size_t index, wxSizerItem *newitem ));
 
 970         def Replace(self, olditem, item, recursive=False):
 
 972             Detaches the given ``olditem`` from the sizer and replaces it with
 
 973             ``item`` which can be a window, sizer, or `wx.SizerItem`.  The
 
 974             detached child is destroyed only if it is not a window, (because
 
 975             windows are owned by their parent, not the sizer.)  The
 
 976             ``recursive`` parameter can be used to search for the given
 
 977             element recursivly in subsizers.
 
 979             This method does not cause any layout or resizing to take place,
 
 980             call `Layout` to do so.
 
 982             Returns ``True`` if the child item was found and removed.
 
 984             if isinstance(olditem, wx.Window):
 
 985                 return self._ReplaceWin(olditem, item, recursive)
 
 986             elif isinstance(olditem, wx.Sizer):
 
 987                 return self._ReplaceSizer(olditem, item, recursive)
 
 988             elif isinstance(olditem, int):
 
 989                 return self._ReplaceItem(olditem, item)
 
 991                 raise TypeError("Expected Window, Sizer, or integer for first parameter.")
 
 996         void , SetContainingWindow(wxWindow *window),
 
 997         "Set (or unset) the window this sizer is used in.", "");
 
1000         wxWindow *, GetContainingWindow() const,
 
1001         "Get the window this sizer is used in.", "");
 
1005     def SetItemMinSize(self, item, *args):
 
1007         SetItemMinSize(self, item, Size size)
 
1009         Sets the minimum size that will be allocated for an item in the sizer.
 
1010         The *item* parameter can be either a window, a sizer, or the
 
1011         zero-based index of the item.  If a window or sizer is given then it
 
1012         will be searched for recursivly in subsizers if neccessary.
 
1015             %# for backward compatibility accept separate width,height args too
 
1016             return self._SetItemMinSize(item, args)
 
1018             return self._SetItemMinSize(item, args[0])
 
1022     %disownarg( wxSizerItem *item ); 
 
1025         wxSizerItem* , Add( wxSizerItem *item ),
 
1026         "AddItem(self, SizerItem item)",
 
1027         "Adds a `wx.SizerItem` to the sizer.", "",
 
1031         wxSizerItem* , Insert( size_t index, wxSizerItem *item ),
 
1032         "InsertItem(self, int index, SizerItem item)",
 
1033         "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
 
1037         wxSizerItem* , Prepend( wxSizerItem *item ),
 
1038         "PrependItem(self, SizerItem item)",
 
1039         "Prepends a `wx.SizerItem` to the sizer.", "",
 
1042     %cleardisown( wxSizerItem *item );
 
1046     def AddMany(self, items):
 
1048         AddMany is a convenience method for adding several items
 
1049         to a sizer at one time.  Simply pass it a list of tuples,
 
1050         where each tuple consists of the parameters that you
 
1051         would normally pass to the `Add` method.
 
1054             if type(item) != type(()) or (len(item) == 2 and type(item[0]) == type(1)):
 
1058     def AddSpacer(self, *args, **kw):
 
1059         """AddSpacer(int size) --> SizerItem
 
1061         Add a spacer that is (size,size) pixels.
 
1063         if args and type(args[0]) == int:
 
1064             return self.Add( (args[0],args[0] ), 0)
 
1065         else: %# otherwise stay compatible with old AddSpacer
 
1066             return self.Add(*args, **kw)
 
1067     def PrependSpacer(self, *args, **kw):
 
1068         """PrependSpacer(int size) --> SizerItem
 
1070         Prepend a spacer that is (size, size) pixels."""
 
1071         if args and type(args[0]) == int:
 
1072             return self.Prepend( (args[0],args[0] ), 0)
 
1073         else: %# otherwise stay compatible with old PrependSpacer
 
1074             return self.Prepend(*args, **kw)
 
1075     def InsertSpacer(self, index, *args, **kw):
 
1076         """InsertSpacer(int index, int size) --> SizerItem
 
1078         Insert a spacer at position index that is (size, size) pixels."""
 
1079         if args and type(args[0]) == int:
 
1080             return self.Insert( index, (args[0],args[0] ), 0)
 
1081         else: %# otherwise stay compatible with old InsertSpacer
 
1082             return self.Insert(index, *args, **kw)
 
1085     def AddStretchSpacer(self, prop=1):
 
1086         """AddStretchSpacer(int prop=1) --> SizerItem
 
1088         Add a stretchable spacer."""
 
1089         return self.Add((0,0), prop)
 
1090     def PrependStretchSpacer(self, prop=1):
 
1091         """PrependStretchSpacer(int prop=1) --> SizerItem
 
1093         Prepend a stretchable spacer."""
 
1094         return self.Prepend((0,0), prop)
 
1095     def InsertStretchSpacer(self, index, prop=1):
 
1096         """InsertStretchSpacer(int index, int prop=1) --> SizerItem
 
1098         Insert a stretchable spacer."""
 
1099         return self.Insert(index, (0,0), prop)
 
1102     %# for backwards compatibility only, please do not use in new code
 
1103     def AddWindow(self, *args, **kw):
 
1104         """Compatibility alias for `Add`."""
 
1105         return self.Add(*args, **kw)
 
1106     def AddSizer(self, *args, **kw):
 
1107         """Compatibility alias for `Add`."""
 
1108         return self.Add(*args, **kw)
 
1110     def PrependWindow(self, *args, **kw):
 
1111         """Compatibility alias for `Prepend`."""
 
1112         return self.Prepend(*args, **kw)
 
1113     def PrependSizer(self, *args, **kw):
 
1114         """Compatibility alias for `Prepend`."""
 
1115         return self.Prepend(*args, **kw)
 
1117     def InsertWindow(self, *args, **kw):
 
1118         """Compatibility alias for `Insert`."""
 
1119         return self.Insert(*args, **kw)
 
1120     def InsertSizer(self, *args, **kw):
 
1121         """Compatibility alias for `Insert`."""
 
1122         return self.Insert(*args, **kw)
 
1124     def RemoveWindow(self, *args, **kw):
 
1125         """Compatibility alias for `Remove`."""
 
1126         return self.Remove(*args, **kw)
 
1127     def RemoveSizer(self, *args, **kw):
 
1128         """Compatibility alias for `Remove`."""
 
1129         return self.Remove(*args, **kw)
 
1130     def RemovePos(self, *args, **kw):
 
1131         """Compatibility alias for `Remove`."""
 
1132         return self.Remove(*args, **kw)
 
1138         void , SetDimension( int x, int y, int width, int height ),
 
1139         "Call this to force the sizer to take the given dimension and thus
 
1140 force the items owned by the sizer to resize themselves according to
 
1141 the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
 
1145         void , SetMinSize( const wxSize &size ),
 
1146         "Call this to give the sizer a minimal size. Normally, the sizer will
 
1147 calculate its minimal size based purely on how much space its children
 
1148 need. After calling this method `GetMinSize` will return either the
 
1149 minimal size as requested by its children or the minimal size set
 
1150 here, depending on which is bigger.", "");
 
1155         "Returns the current size of the space managed by the sizer.", "");
 
1158         wxPoint , GetPosition(),
 
1159         "Returns the current position of the sizer's managed space.", "");
 
1162         wxSize , GetMinSize(),
 
1163         "Returns the minimal size of the sizer. This is either the combined
 
1164 minimal size of all the children and their borders or the minimal size
 
1165 set by SetMinSize, depending on which is bigger.", "");
 
1169     def GetSizeTuple(self):
 
1170         return self.GetSize().Get()
 
1171     def GetPositionTuple(self):
 
1172         return self.GetPosition().Get()
 
1173     def GetMinSizeTuple(self):
 
1174         return self.GetMinSize().Get()
 
1178         virtual void , RecalcSizes(),
 
1179         "Using the sizes calculated by `CalcMin` reposition and resize all the
 
1180 items managed by this sizer.  You should not need to call this directly as
 
1181 it is called by `Layout`.", "");
 
1184         virtual wxSize , CalcMin(),
 
1185         "This method is where the sizer will do the actual calculation of its
 
1186 children's minimal sizes.  You should not need to call this directly as
 
1187 it is called by `Layout`.", "");
 
1192         "This method will force the recalculation and layout of the items
 
1193 controlled by the sizer using the current space allocated to the
 
1194 sizer.  Normally this is called automatically from the owning window's
 
1195 EVT_SIZE handler, but it is also useful to call it from user code when
 
1196 one of the items in a sizer change size, or items are added or
 
1201         wxSize , Fit( wxWindow *window ),
 
1202         "Tell the sizer to resize the *window* to match the sizer's minimal
 
1203 size. This is commonly done in the constructor of the window itself in
 
1204 order to set its initial size to match the needs of the children as
 
1205 determined by the sizer.  Returns the new size.
 
1207 For a top level window this is the total window size, not the client size.", "");
 
1210         void , FitInside( wxWindow *window ),
 
1211         "Tell the sizer to resize the *virtual size* of the *window* to match the
 
1212 sizer's minimal size. This will not alter the on screen size of the
 
1213 window, but may cause the addition/removal/alteration of scrollbars
 
1214 required to view the virtual area in windows which manage it.
 
1216 :see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
 
1221         void , SetSizeHints( wxWindow *window ),
 
1222         "Tell the sizer to set (and `Fit`) the minimal size of the *window* to
 
1223 match the sizer's minimal size. This is commonly done in the
 
1224 constructor of the window itself if the window is resizable (as are
 
1225 many dialogs under Unix and frames on probably all platforms) in order
 
1226 to prevent the window from being sized smaller than the minimal size
 
1227 required by the sizer.", "");
 
1230         void , SetVirtualSizeHints( wxWindow *window ),
 
1231         "Tell the sizer to set the minimal size of the window virtual area to
 
1232 match the sizer's minimal size. For windows with managed scrollbars
 
1233 this will set them appropriately.
 
1235 :see: `wx.ScrolledWindow.SetScrollbars`
 
1240         void , Clear( bool deleteWindows=false ),
 
1241         "Clear all items from the sizer, optionally destroying the window items
 
1245         void , DeleteWindows(),
 
1246         "Destroy all windows managed by the sizer.", "");
 
1250     // wxList& GetChildren();
 
1252         DocAStr(GetChildren,
 
1253                 "GetChildren(self) -> list",
 
1254                 "Returns a list of all the `wx.SizerItem` objects managed by the sizer.", "");
 
1255         PyObject* GetChildren() {
 
1256             wxSizerItemList& list = self->GetChildren();
 
1257             return wxPy_ConvertList(&list);
 
1262     // Manage whether individual windows or subsizers are considered
 
1263     // in the layout calculations or not.
 
1267                 "Show(self, item, bool show=True, bool recursive=false) -> bool",
 
1268                 "Shows or hides an item managed by the sizer.  To make a sizer item
 
1269 disappear or reappear, use Show followed by `Layout`.  The *item*
 
1270 parameter can be either a window, a sizer, or the zero-based index of
 
1271 the item.  Use the recursive parameter to show or hide an item in a
 
1272 subsizer.  Returns True if the item was found.", "");
 
1273         bool Show(PyObject* item, bool show = true, bool recursive=false) {
 
1274             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1275             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
1276             wxPyEndBlockThreads(blocked);
 
1278                 return self->Show(info.window, show, recursive);
 
1279             else if ( info.sizer )
 
1280                 return self->Show(info.sizer, show, recursive);
 
1281             else if ( info.gotPos )
 
1282                 return self->Show(info.pos, show);
 
1288                 "IsShown(self, item)",
 
1289                 "Determines if the item is currently shown. To make a sizer
 
1290 item disappear or reappear, use Show followed by `Layout`.  The *item*
 
1291 parameter can be either a window, a sizer, or the zero-based index of
 
1293         bool IsShown(PyObject* item) {
 
1294             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1295             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false);
 
1296             wxPyEndBlockThreads(blocked);
 
1298                 return self->IsShown(info.window);
 
1299             else if ( info.sizer )
 
1300                 return self->IsShown(info.sizer);
 
1301             else if ( info.gotPos )
 
1302                 return self->IsShown(info.pos);
 
1309     def Hide(self, item, recursive=False):
 
1311         A convenience method for `Show` (item, False, recursive).
 
1313         return self.Show(item, False, recursive)
 
1318         void , ShowItems(bool show),
 
1319         "Recursively call `wx.SizerItem.Show` on all sizer items.", "");
 
1321     %property(Children, GetChildren, doc="See `GetChildren`");
 
1322     %property(ContainingWindow, GetContainingWindow, SetContainingWindow, doc="See `GetContainingWindow` and `SetContainingWindow`");
 
1323     %property(MinSize, GetMinSize, SetMinSize, doc="See `GetMinSize` and `SetMinSize`");
 
1324     %property(Position, GetPosition, doc="See `GetPosition`");
 
1325     %property(Size, GetSize, doc="See `GetSize`");
 
1329 //---------------------------------------------------------------------------
 
1330 // Use this one for deriving Python classes from
 
1333 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
 
1334 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
 
1335 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
 
1340 "wx.PySizer is a special version of `wx.Sizer` that has been
 
1341 instrumented to allow the C++ virtual methods to be overloaded in
 
1342 Python derived classes.  You would derive from this class if you are
 
1343 wanting to implement a custom sizer in Python code.  Simply implement
 
1344 `CalcMin` and `RecalcSizes` in the derived class and you're all set.
 
1347     class MySizer(wx.PySizer):
 
1349              wx.PySizer.__init__(self)
 
1352              for item in self.GetChildren():
 
1353                   # calculate the total minimum width and height needed
 
1354                   # by all items in the sizer according to this sizer's
 
1357              return wx.Size(width, height)
 
1359           def RecalcSizes(self):
 
1360               # find the space allotted to this sizer
 
1361               pos = self.GetPosition()
 
1362               size = self.GetSize()
 
1363               for item in self.GetChildren():
 
1364                   # Recalculate (if necessary) the position and size of
 
1365                   # each item and then call item.SetDimension to do the
 
1366                   # actual positioning and sizing of the items within the
 
1367                   # space alloted to this sizer.
 
1369                   item.SetDimension(itemPos, itemSize)
 
1372 When `Layout` is called it first calls `CalcMin` followed by
 
1373 `RecalcSizes` so you can optimize a bit by saving the results of
 
1374 `CalcMin` and reusing them in `RecalcSizes`.
 
1376 :see: `wx.SizerItem`, `wx.Sizer.GetChildren`
 
1379 class wxPySizer : public wxSizer {
 
1381     %pythonAppend wxPySizer "self._setOORInfo(self);" setCallbackInfo(PySizer)
 
1385         "Creates a wx.PySizer.  Must be called from the __init__ in the derived
 
1388     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1392 //---------------------------------------------------------------------------
 
1397 "The basic idea behind a box sizer is that windows will most often be
 
1398 laid out in rather simple basic geometry, typically in a row or a
 
1399 column or nested hierarchies of either.  A wx.BoxSizer will lay out
 
1400 its items in a simple row or column, depending on the orientation
 
1401 parameter passed to the constructor.", "
 
1403 It is the unique feature of a box sizer, that it can grow in both
 
1404 directions (height and width) but can distribute its growth in the
 
1405 main direction (horizontal for a row) *unevenly* among its children.
 
1406 This is determined by the proportion parameter give to items when they
 
1407 are added to the sizer. It is interpreted as a weight factor, i.e. it
 
1408 can be zero, indicating that the window may not be resized at all, or
 
1409 above zero. If several windows have a value above zero, the value is
 
1410 interpreted relative to the sum of all weight factors of the sizer, so
 
1411 when adding two windows with a value of 1, they will both get resized
 
1412 equally and each will receive half of the available space after the
 
1413 fixed size items have been sized.  If the items have unequal
 
1414 proportion settings then they will receive a coresondingly unequal
 
1415 allotment of the free space.
 
1417 :see: `wx.StaticBoxSizer`
 
1420 class  wxBoxSizer : public wxSizer {
 
1422     %pythonAppend wxBoxSizer "self._setOORInfo(self)"
 
1425         wxBoxSizer(int orient = wxHORIZONTAL),
 
1426         "Constructor for a wx.BoxSizer. *orient* may be one of ``wx.VERTICAL``
 
1427 or ``wx.HORIZONTAL`` for creating either a column sizer or a row
 
1432         int , GetOrientation(),
 
1433         "Returns the current orientation of the sizer.", "");
 
1436         void , SetOrientation(int orient),
 
1437         "Resets the orientation of the sizer.", "");
 
1439     bool IsVertical() const;
 
1441     %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
 
1444 //---------------------------------------------------------------------------
 
1448 DocStr(wxStaticBoxSizer,
 
1449 "wx.StaticBoxSizer derives from and functions identically to the
 
1450 `wx.BoxSizer` and adds a `wx.StaticBox` around the items that the sizer
 
1451 manages.  Note that this static box must be created separately and
 
1452 passed to the sizer constructor.", "");
 
1454 class  wxStaticBoxSizer : public wxBoxSizer {
 
1456     %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)"
 
1459         wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL),
 
1460         "Constructor. It takes an associated static box and the orientation
 
1461 *orient* as parameters - orient can be either of ``wx.VERTICAL`` or
 
1462 ``wx.HORIZONTAL``.", "");
 
1464     // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
 
1467         wxStaticBox *, GetStaticBox(),
 
1468         "Returns the static box associated with this sizer.", "");
 
1470     %property(StaticBox, GetStaticBox, doc="See `GetStaticBox`");
 
1473 //---------------------------------------------------------------------------
 
1478 "A grid sizer is a sizer which lays out its children in a
 
1479 two-dimensional table with all cells having the same size.  In other
 
1480 words, the width of each cell within the grid is the width of the
 
1481 widest item added to the sizer and the height of each grid cell is the
 
1482 height of the tallest item.  An optional vertical and/or horizontal
 
1483 gap between items can also be specified (in pixels.)
 
1485 Items are placed in the cells of the grid in the order they are added,
 
1486 in row-major order.  In other words, the first row is filled first,
 
1487 then the second, and so on until all items have been added. (If
 
1488 neccessary, additional rows will be added as items are added.)  If you
 
1489 need to have greater control over the cells that items are placed in
 
1490 then use the `wx.GridBagSizer`.
 
1493 class wxGridSizer: public wxSizer
 
1496     %pythonAppend wxGridSizer "self._setOORInfo(self)"
 
1499         wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
 
1500         "Constructor for a wx.GridSizer. *rows* and *cols* determine the number
 
1501 of columns and rows in the sizer - if either of the parameters is
 
1502 zero, it will be calculated to from the total number of children in
 
1503 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
 
1504 define extra space between all children.", "");
 
1507         void , SetCols( int cols ),
 
1508         "Sets the number of columns in the sizer.", "");
 
1511         void , SetRows( int rows ),
 
1512         "Sets the number of rows in the sizer.", "");
 
1515         void , SetVGap( int gap ),
 
1516         "Sets the vertical gap (in pixels) between the cells in the sizer.", "");
 
1519         void , SetHGap( int gap ),
 
1520         "Sets the horizontal gap (in pixels) between cells in the sizer", "");
 
1524         "Returns the number of columns in the sizer.", "");
 
1528         "Returns the number of rows in the sizer.", "");
 
1532         "Returns the vertical gap (in pixels) between the cells in the sizer.", "");
 
1536         "Returns the horizontal gap (in pixels) between cells in the sizer.", "");
 
1539         def CalcRowsCols(self):
 
1541             CalcRowsCols() -> (rows, cols)
 
1543             Calculates how many rows and columns will be in the sizer based
 
1544             on the current number of items and also the rows, cols specified
 
1547             nitems = len(self.GetChildren())
 
1548             rows = self.GetRows()
 
1549             cols = self.GetCols()
 
1550             assert rows != 0 or cols != 0, "Grid sizer must have either rows or columns fixed"
 
1552                 rows = (nitems + cols - 1) / cols
 
1554                 cols = (nitems + rows - 1) / rows
 
1558     %property(Cols, GetCols, SetCols, doc="See `GetCols` and `SetCols`");
 
1559     %property(HGap, GetHGap, SetHGap, doc="See `GetHGap` and `SetHGap`");
 
1560     %property(Rows, GetRows, SetRows, doc="See `GetRows` and `SetRows`");
 
1561     %property(VGap, GetVGap, SetVGap, doc="See `GetVGap` and `SetVGap`");
 
1564 //---------------------------------------------------------------------------
 
1567 enum wxFlexSizerGrowMode
 
1569     // don't resize the cells in non-flexible direction at all
 
1570     wxFLEX_GROWMODE_NONE,
 
1572     // uniformly resize only the specified ones (default)
 
1573     wxFLEX_GROWMODE_SPECIFIED,
 
1575     // uniformly resize all cells
 
1583 DocStr(wxFlexGridSizer,
 
1584 "A flex grid sizer is a sizer which lays out its children in a
 
1585 two-dimensional table with all table cells in one row having the same
 
1586 height and all cells in one column having the same width, but all
 
1587 rows or all columns are not necessarily the same height or width as in
 
1590 wx.FlexGridSizer can also size items equally in one direction but
 
1591 unequally (\"flexibly\") in the other. If the sizer is only flexible
 
1592 in one direction (this can be changed using `SetFlexibleDirection`), it
 
1593 needs to be decided how the sizer should grow in the other (\"non
 
1594 flexible\") direction in order to fill the available space. The
 
1595 `SetNonFlexibleGrowMode` method serves this purpose.
 
1599 class wxFlexGridSizer: public wxGridSizer
 
1602     %pythonAppend wxFlexGridSizer "self._setOORInfo(self)"
 
1605         wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
 
1606         "Constructor for a wx.FlexGridSizer. *rows* and *cols* determine the
 
1607 number of columns and rows in the sizer - if either of the parameters
 
1608 is zero, it will be calculated to from the total number of children in
 
1609 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
 
1610 define extra space between all children.", "");
 
1614         void , AddGrowableRow( size_t idx, int proportion = 0  ),
 
1615         "Specifies that row *idx* (starting from zero) should be grown if there
 
1616 is extra space available to the sizer.
 
1618 The *proportion* parameter has the same meaning as the stretch factor
 
1619 for the box sizers except that if all proportions are 0, then all
 
1620 columns are resized equally (instead of not being resized at all).", "");
 
1623         void , RemoveGrowableRow( size_t idx ),
 
1624         "Specifies that row *idx* is no longer growable.", "");
 
1627         void , AddGrowableCol( size_t idx, int proportion = 0  ),
 
1628         "Specifies that column *idx* (starting from zero) should be grown if
 
1629 there is extra space available to the sizer.
 
1631 The *proportion* parameter has the same meaning as the stretch factor
 
1632 for the box sizers except that if all proportions are 0, then all
 
1633 columns are resized equally (instead of not being resized at all).", "");
 
1636         void , RemoveGrowableCol( size_t idx ),
 
1637         "Specifies that column *idx* is no longer growable.", "");
 
1641         void , SetFlexibleDirection(int direction),
 
1642         "Specifies whether the sizer should flexibly resize its columns, rows,
 
1643 or both. Argument *direction* can be one of the following values.  Any
 
1644 other value is ignored.
 
1646     ==============    =======================================
 
1647     wx.VERTICAL       Rows are flexibly sized.
 
1648     wx.HORIZONTAL     Columns are flexibly sized.
 
1649     wx.BOTH           Both rows and columns are flexibly sized
 
1650                       (this is the default value).
 
1651     ==============    =======================================
 
1653 Note that this method does not trigger relayout.
 
1657         int , GetFlexibleDirection(),
 
1658         "Returns a value that specifies whether the sizer
 
1659 flexibly resizes its columns, rows, or both (default).
 
1661 :see: `SetFlexibleDirection`", "");
 
1666         void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
 
1667         "Specifies how the sizer should grow in the non-flexible direction if
 
1668 there is one (so `SetFlexibleDirection` must have been called
 
1669 previously). Argument *mode* can be one of the following values:
 
1671     ==========================  =================================================
 
1672     wx.FLEX_GROWMODE_NONE       Sizer doesn't grow in the non flexible direction.
 
1673     wx.FLEX_GROWMODE_SPECIFIED  Sizer honors growable columns/rows set with
 
1674                                 `AddGrowableCol` and `AddGrowableRow`. In this
 
1675                                 case equal sizing applies to minimum sizes of
 
1676                                 columns or rows (this is the default value).
 
1677     wx.FLEX_GROWMODE_ALL        Sizer equally stretches all columns or rows in
 
1678                                 the non flexible direction, whether they are
 
1679                                 growable or not in the flexbile direction.
 
1680     ==========================  =================================================
 
1682 Note that this method does not trigger relayout.", "");
 
1685         wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
 
1686         "Returns the value that specifies how the sizer grows in the
 
1687 non-flexible direction if there is one.
 
1689 :see: `SetNonFlexibleGrowMode`", "");
 
1692     // Read-only access to the row heights and col widths arrays
 
1694         const wxArrayInt& , GetRowHeights() const,
 
1695         "GetRowHeights(self) -> list",
 
1696         "Returns a list of integers representing the heights of each of the
 
1697 rows in the sizer.", "");
 
1700         const wxArrayInt& , GetColWidths() const,
 
1701         "GetColWidths(self) -> list",
 
1702         "Returns a list of integers representing the widths of each of the
 
1703 columns in the sizer.", "");
 
1706     %property(ColWidths, GetColWidths, doc="See `GetColWidths`");
 
1707     %property(FlexibleDirection, GetFlexibleDirection, SetFlexibleDirection, doc="See `GetFlexibleDirection` and `SetFlexibleDirection`");
 
1708     %property(NonFlexibleGrowMode, GetNonFlexibleGrowMode, SetNonFlexibleGrowMode, doc="See `GetNonFlexibleGrowMode` and `SetNonFlexibleGrowMode`");
 
1709     %property(RowHeights, GetRowHeights, doc="See `GetRowHeights`");
 
1713 //---------------------------------------------------------------------------
 
1715 DocStr(wxStdDialogButtonSizer,
 
1716 "A special sizer that knows how to order and position standard buttons
 
1717 in order to conform to the current platform's standards.  You simply
 
1718 need to add each `wx.Button` to the sizer, and be sure to create the
 
1719 buttons using the standard ID's.  Then call `Realize` and the sizer
 
1720 will take care of the rest.
 
1723 class wxStdDialogButtonSizer: public wxBoxSizer
 
1727         wxStdDialogButtonSizer(),
 
1731         void , AddButton(wxButton *button),
 
1732         "Use this to add the buttons to this sizer.  Do not use the `Add`
 
1733 method in the base class.", "");
 
1737         "This funciton needs to be called after all the buttons have been added
 
1738 to the sizer.  It will reorder them and position them in a platform
 
1739 specifc manner.", "");
 
1741     void SetAffirmativeButton( wxButton *button );
 
1742     void SetNegativeButton( wxButton *button );
 
1743     void SetCancelButton( wxButton *button );
 
1745     wxButton* GetAffirmativeButton() const;
 
1746     wxButton* GetApplyButton() const;
 
1747     wxButton* GetNegativeButton() const;
 
1748     wxButton* GetCancelButton() const;
 
1749     wxButton* GetHelpButton() const;
 
1751     %property(AffirmativeButton, GetAffirmativeButton, SetAffirmativeButton, doc="See `GetAffirmativeButton` and `SetAffirmativeButton`");
 
1752     %property(ApplyButton, GetApplyButton, doc="See `GetApplyButton`");
 
1753     %property(CancelButton, GetCancelButton, SetCancelButton, doc="See `GetCancelButton` and `SetCancelButton`");
 
1754     %property(HelpButton, GetHelpButton, doc="See `GetHelpButton`");
 
1755     %property(NegativeButton, GetNegativeButton, SetNegativeButton, doc="See `GetNegativeButton` and `SetNegativeButton`");
 
1759 //---------------------------------------------------------------------------