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 "The wx.SizerItem class is used to track the position, size and other
 
  26 attributes of each item managed by a `wx.Sizer`. In normal usage user
 
  27 code should never need to deal directly with a wx.SizerItem, but
 
  28 custom classes derived from `wx.PySizer` will probably need to use the
 
  29 collection of wx.SizerItems held by wx.Sizer when calculating layout.
 
  31 :see: `wx.Sizer`, `wx.GBSizerItem`", "");
 
  33 class wxSizerItem : public wxObject {
 
  37         "Constructs an empty wx.SizerItem.  Either a window, sizer or spacer
 
  38 size will need to be set before this item can be used in a Sizer.
 
  40 You will probably never need to create a wx.SizerItem directly as they
 
  41 are created automatically when the sizer's Add, Insert or Prepend
 
  44 :see: `wx.SizerItemSpacer`, `wx.SizerItemWindow`, `wx.SizerItemSizer`", "");
 
  50             wxSizerItem( wxWindow *window, int proportion, int flag,
 
  51                          int border, PyObject* userData=NULL ),
 
  52             "Constructs a `wx.SizerItem` for tracking a window.", ""); 
 
  54         %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, int flag,
 
  55                                                   int border, PyObject* userData=NULL ))
 
  57             wxPyUserData* data = NULL;
 
  59                 bool blocked = wxPyBeginBlockThreads();
 
  60                 data = new wxPyUserData(userData);
 
  61                 wxPyEndBlockThreads(blocked);
 
  63             return new wxSizerItem(window, proportion, flag, border, data);
 
  68             wxSizerItem( int width, int height, int proportion, int flag,
 
  69                          int border, PyObject* userData=NULL),
 
  70             "Constructs a `wx.SizerItem` for tracking a spacer.", "");
 
  72         %RenameCtor(SizerItemSpacer,  wxSizerItem( int width, int height, int proportion, int flag,
 
  73                                                    int border, PyObject* userData=NULL))
 
  75             wxPyUserData* data = NULL;
 
  77                 bool blocked = wxPyBeginBlockThreads();
 
  78                 data = new wxPyUserData(userData);
 
  79                 wxPyEndBlockThreads(blocked);
 
  81             return new wxSizerItem(width, height, proportion, flag, border, data);
 
  85             wxSizerItem( wxSizer *sizer, int proportion, int flag,
 
  86                          int border, PyObject* userData=NULL ),
 
  87             "Constructs a `wx.SizerItem` for tracking a subsizer", "");
 
  89         %RenameCtor(SizerItemSizer,  wxSizerItem( wxSizer *sizer, int proportion, int flag,
 
  90                                                   int border, PyObject* userData=NULL ))
 
  92             wxPyUserData* data = NULL;
 
  94                 bool blocked = wxPyBeginBlockThreads();
 
  95                 data = new wxPyUserData(userData);
 
  96                 wxPyEndBlockThreads(blocked);
 
  98             return new wxSizerItem(sizer, proportion, flag, border, data);
 
 105         void , DeleteWindows(),
 
 106         "Destroy the window or the windows in a subsizer, depending on the type
 
 110         void , DetachSizer(),
 
 111         "Enable deleting the SizerItem without destroying the contained sizer.", "");
 
 116         "Get the current size of the item, as set in the last Layout.", "");
 
 120         "Calculates the minimum desired size for the item, including any space
 
 121 needed by borders.", "");
 
 124         void , SetDimension( wxPoint pos, wxSize size ),
 
 125         "Set the position and size of the space allocated for this item by the
 
 126 sizer, and adjust the position and size of the item (window or
 
 127 subsizer) to be within that space taking alignment and borders into
 
 132         wxSize , GetMinSize(),
 
 133         "Get the minimum size needed for the item.", "");
 
 136         wxSize , GetMinSizeWithBorder() const,
 
 137         "Get the minimum size needed for the item with space for the borders
 
 138 added, if needed.", "");
 
 141         void , SetInitSize( int x, int y ),
 
 146            "Set the ratio item attribute.", "");
 
 147     %Rename(SetRatioWH, void, SetRatio( int width, int height ));
 
 148     %Rename(SetRatioSize, void, SetRatio( wxSize size ));
 
 149     void SetRatio( float ratio );
 
 153         "Set the ratio item attribute.", "");
 
 157         "Returns the rectangle that the sizer item should occupy", "");
 
 162         "Is this sizer item a window?", "");
 
 166         "Is this sizer item a subsizer?", "");
 
 170         "Is this sizer item a spacer?", "");
 
 174         void , SetProportion( int proportion ),
 
 175         "Set the proportion value for this item.", "");
 
 178         int , GetProportion(),
 
 179         "Get the proportion value for this item.", "");
 
 181     %pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
 
 182     %pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
 
 186         void , SetFlag( int flag ),
 
 187         "Set the flag value for this item.", "");
 
 191         "Get the flag value for this item.", "");
 
 195         void , SetBorder( int border ),
 
 196         "Set the border value for this item.", "");
 
 200         "Get the border value for this item.", "");
 
 205         wxWindow *, GetWindow(),
 
 206         "Get the window (if any) that is managed by this sizer item.", "");
 
 209         void , SetWindow( wxWindow *window ),
 
 210         "Set the window to be managed by this sizer item.", "");
 
 214         wxSizer *, GetSizer(),
 
 215         "Get the subsizer (if any) that is managed by this sizer item.", "");
 
 218         void , SetSizer( wxSizer *sizer ),
 
 219         "Set the subsizer to be managed by this sizer item.", "");
 
 223         const wxSize& , GetSpacer(),
 
 224         "Get the size of the spacer managed by this sizer item.", "");
 
 227         void , SetSpacer( const wxSize &size ),
 
 228         "Set the size of the spacer to be managed by this sizer item.", "");
 
 232         void , Show( bool show ),
 
 233         "Set the show item attribute, which sizers use to determine if the item
 
 234 is to be made part of the layout or not. If the item is tracking a
 
 235 window then it is shown or hidden as needed.", "");
 
 239         "Is the item to be shown in the layout?", "");
 
 243         wxPoint , GetPosition(),
 
 244         "Returns the current position of the item, as set in the last Layout.", "");
 
 247     // wxObject* GetUserData();
 
 249         // Assume that the user data is a wxPyUserData object and return the contents
 
 252                "Returns the userData associated with this sizer item, or None if there
 
 254         PyObject* GetUserData() {
 
 255             wxPyUserData* data = (wxPyUserData*)self->GetUserData();
 
 257                 Py_INCREF(data->m_obj);
 
 268 //---------------------------------------------------------------------------
 
 271 // Figure out the type of the sizer item
 
 273 struct wxPySizerItemInfo {
 
 275         : window(NULL), sizer(NULL), gotSize(false),
 
 276           size(wxDefaultSize), gotPos(false), pos(-1)
 
 287 static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
 
 289     wxPySizerItemInfo info;
 
 291     wxSize* sizePtr = &size;
 
 293     // Find out what the type of the item is
 
 295     if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
 
 300         if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
 
 304             // try wxSize or (w,h)
 
 305             if ( checkSize && wxSize_helper(item, &sizePtr)) {
 
 306                 info.size = *sizePtr;
 
 311             if (checkIdx && PyInt_Check(item)) {
 
 312                 info.pos = PyInt_AsLong(item);
 
 318     if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
 
 319         // no expected type, figure out what kind of error message to generate
 
 320         if ( !checkSize && !checkIdx )
 
 321             PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected for item");
 
 322         else if ( checkSize && !checkIdx )
 
 323             PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) expected for item");
 
 324         else if ( !checkSize && checkIdx)
 
 325             PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer or int (position) expected for item");
 
 327             // can this one happen?
 
 328             PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) or int (position) expected for item");
 
 339 "wx.Sizer is the abstract base class used for laying out subwindows in
 
 340 a window.  You cannot use wx.Sizer directly; instead, you will have to
 
 341 use one of the sizer classes derived from it such as `wx.BoxSizer`,
 
 342 `wx.StaticBoxSizer`, `wx.NotebookSizer`, `wx.GridSizer`,  `wx.FlexGridSizer`
 
 343 and `wx.GridBagSizer`.
 
 345 The concept implemented by sizers in wxWidgets is closely related to
 
 346 layout tools in other GUI toolkits, such as Java's AWT, the GTK
 
 347 toolkit or the Qt toolkit. It is based upon the idea of the individual
 
 348 subwindows reporting their minimal required size and their ability to
 
 349 get stretched if the size of the parent window has changed. This will
 
 350 most often mean that the programmer does not set the original size of
 
 351 a dialog in the beginning, rather the dialog will assigned a sizer and
 
 352 this sizer will be queried about the recommended size. The sizer in
 
 353 turn will query its children, which can be normal windows or contorls,
 
 354 empty space or other sizers, so that a hierarchy of sizers can be
 
 355 constructed. Note that wxSizer does not derive from wxWindow and thus
 
 356 do not interfere with tab ordering and requires very little resources
 
 357 compared to a real window on screen.
 
 359 What makes sizers so well fitted for use in wxWidgets is the fact that
 
 360 every control reports its own minimal size and the algorithm can
 
 361 handle differences in font sizes or different window (dialog item)
 
 362 sizes on different platforms without problems. If for example the
 
 363 standard font as well as the overall design of Mac widgets requires
 
 364 more space than on Windows, then the initial size of a dialog using a
 
 365 sizer will automatically be bigger on Mac than on Windows.", "
 
 367 :note: If you wish to create a custom sizer class in wxPython you
 
 368     should derive the class from `wx.PySizer` in order to get
 
 369     Python-aware capabilities for the various virtual methods.
 
 373 :todo: More dscriptive text here along with some pictures...
 
 377 class wxSizer : public wxObject {
 
 379     // wxSizer();      ****  abstract, can't instantiate
 
 383         void _setOORInfo(PyObject* _self) {
 
 384             if (!self->GetClientObject())
 
 385                 self->SetClientObject(new wxPyOORClientData(_self));
 
 389                 "Add(self, item, int proportion=0, int flag=0, int border=0,
 
 390     PyObject userData=None) -> wx.SizerItem",
 
 392                 "Appends a child item to the sizer.", "
 
 394     :param item:  The item can be one of three kinds of objects:
 
 396         - **window**: A `wx.Window` to be managed by the sizer. Its
 
 397           minimal size (either set explicitly by the user or
 
 398           calculated internally when constructed with wx.DefaultSize)
 
 399           is interpreted as the minimal size to use when laying out
 
 400           item in the sizer.  This is particularly useful in
 
 401           connection with `wx.Window.SetSizeHints`.
 
 403         - **sizer**: The (child-)sizer to be added to the sizer. This
 
 404           allows placing a child sizer in a sizer and thus to create
 
 405           hierarchies of sizers (typically a vertical box as the top
 
 406           sizer and several horizontal boxes on the level beneath).
 
 408         - **size**: A `wx.Size` or a 2-element sequence of integers
 
 409           that represents the width and height of a spacer to be added
 
 410           to the sizer. Adding spacers to sizers gives more
 
 411           flexibility in the design of dialogs; imagine for example a
 
 412           horizontal box with two buttons at the bottom of a dialog:
 
 413           you might want to insert a space between the two buttons and
 
 414           make that space stretchable using the *proportion* value and
 
 415           the result will be that the left button will be aligned with
 
 416           the left side of the dialog and the right button with the
 
 417           right side - the space in between will shrink and grow with
 
 420     :param proportion: Although the meaning of this parameter is
 
 421         undefined in wx.Sizer, it is used in `wx.BoxSizer` to indicate
 
 422         if a child of a sizer can change its size in the main
 
 423         orientation of the wx.BoxSizer - where 0 stands for not
 
 424         changeable and a value of more than zero is interpreted
 
 425         relative (a proportion of the total) to the value of other
 
 426         children of the same wx.BoxSizer. For example, you might have
 
 427         a horizontal wx.BoxSizer with three children, two of which are
 
 428         supposed to change their size with the sizer. Then the two
 
 429         stretchable windows should each be given *proportion* value of
 
 430         1 to make them grow and shrink equally with the sizer's
 
 431         horizontal dimension.  But if one of them had a *proportion*
 
 432         value of 2 then it would get a double share of the space
 
 433         available after the fixed size items are positioned.
 
 435     :param flag: This parameter can be used to set a number of flags
 
 436         which can be combined using the binary OR operator ``|``. Two
 
 437         main behaviours are defined using these flags. One is the
 
 438         border around a window: the *border* parameter determines the
 
 439         border width whereas the flags given here determine which
 
 440         side(s) of the item that the border will be added. The other
 
 441         flags determine how the sizer item behaves when the space
 
 442         allotted to the sizer changes, and is somewhat dependent on
 
 443         the specific kind of sizer used.
 
 445         +----------------------------+------------------------------------------+
 
 446         |- wx.TOP                    |These flags are used to specify           |
 
 447         |- wx.BOTTOM                 |which side(s) of the sizer item that      |
 
 448         |- wx.LEFT                   |the *border* width will apply to.         |
 
 452         +----------------------------+------------------------------------------+
 
 453         |- wx.EXAPAND                |The item will be expanded to fill         |
 
 454         |                            |the space allotted to the item.           |
 
 455         +----------------------------+------------------------------------------+
 
 456         |- wx.SHAPED                 |The item will be expanded as much as      |
 
 457         |                            |possible while also maintaining its       |
 
 459         +----------------------------+------------------------------------------+
 
 460         |- wx.FIXED_MINSIZE          |Normally wx.Sizers will use               |
 
 461         |                            |`wx.Window.GetMinSize` or                 |
 
 462         |                            |`wx.Window.GetBestSize` to determine what |
 
 463         |                            |the minimal size of window items should   |
 
 464         |                            |be, and will use that size to calculate   |
 
 465         |                            |the layout. This allows layouts to adjust |
 
 466         |                            |when an item changes and it's best size   |
 
 467         |                            |becomes different. If you would rather    |
 
 468         |                            |have a window item stay the size it       |
 
 469         |                            |started with then use wx.FIXED_MINSIZE.   |
 
 470         +----------------------------+------------------------------------------+
 
 471         |- wx.ALIGN_CENTER           |The wx.ALIGN flags allow you to specify   |
 
 472         |- wx.ALIGN_LEFT             |the alignment of the item within the space|
 
 473         |- wx.ALIGN_RIGHT            |allotted to it by the sizer, ajusted for  |
 
 474         |- wx.ALIGN_TOP              |the border if any.                        |
 
 475         |- wx.ALIGN_BOTTOM           |                                          |
 
 476         |- wx.ALIGN_CENTER_VERTICAL  |                                          |
 
 477         |- wx.ALIGN_CENTER_HORIZONTAL|                                          |
 
 478         +----------------------------+------------------------------------------+
 
 481     :param border: Determines the border width, if the *flag*
 
 482         parameter is set to include any border flag.
 
 484     :param userData: Allows an extra object to be attached to the
 
 485         sizer item, for use in derived classes when sizing information
 
 486         is more complex than the *proportion* and *flag* will allow for.
 
 489         wxSizerItem*  Add(PyObject* item, int proportion=0, int flag=0, int border=0,
 
 490                           PyObject* userData=NULL) {
 
 492             wxPyUserData* data = NULL;
 
 493             bool blocked = wxPyBeginBlockThreads();
 
 494             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 495             if ( userData && (info.window || info.sizer || info.gotSize) )
 
 496                 data = new wxPyUserData(userData);
 
 497             wxPyEndBlockThreads(blocked);
 
 499             // Now call the real Add method if a valid item type was found
 
 501                 return self->Add(info.window, proportion, flag, border, data);
 
 502             else if ( info.sizer )
 
 503                 return self->Add(info.sizer, proportion, flag, border, data);
 
 504             else if (info.gotSize)
 
 505                 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
 
 506                                  proportion, flag, border, data);
 
 511 //    virtual wxSizerItem* AddSpacer(int size);
 
 512 //    virtual wxSizerItem* AddStretchSpacer(int prop = 1);
 
 515                 "Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
 
 516     PyObject userData=None) -> wx.SizerItem",
 
 518                 "Inserts a new item into the list of items managed by this sizer before
 
 519 the item at index *before*.  See `Add` for a description of the parameters.", "");
 
 520         wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0,
 
 521                             int border=0, PyObject* userData=NULL) {
 
 523             wxPyUserData* data = NULL;
 
 524             bool blocked = wxPyBeginBlockThreads();
 
 525             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 526             if ( userData && (info.window || info.sizer || info.gotSize) )
 
 527                 data = new wxPyUserData(userData);
 
 528             wxPyEndBlockThreads(blocked);
 
 530             // Now call the real Insert method if a valid item type was found
 
 532                 return self->Insert(before, info.window, proportion, flag, border, data);
 
 533             else if ( info.sizer )
 
 534                 return self->Insert(before, info.sizer, proportion, flag, border, data);
 
 535             else if (info.gotSize)
 
 536                 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
 
 537                                     proportion, flag, border, data);
 
 543 //    virtual wxSizerItem* InsertSpacer(size_t index, int size);
 
 544 //    virtual wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
 
 547                 "Prepend(self, item, int proportion=0, int flag=0, int border=0,
 
 548     PyObject userData=None) -> wx.SizerItem",
 
 550                "Adds a new item to the begining of the list of sizer items managed by
 
 551 this sizer.  See `Add` for a description of the parameters.", "");
 
 552         wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
 
 553                              PyObject* userData=NULL) {
 
 555             wxPyUserData* data = NULL;
 
 556             bool blocked = wxPyBeginBlockThreads();
 
 557             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
 
 558             if ( userData && (info.window || info.sizer || info.gotSize) )
 
 559                 data = new wxPyUserData(userData);
 
 560             wxPyEndBlockThreads(blocked);
 
 562             // Now call the real Prepend method if a valid item type was found
 
 564                 return self->Prepend(info.window, proportion, flag, border, data);
 
 565             else if ( info.sizer )
 
 566                 return self->Prepend(info.sizer, proportion, flag, border, data);
 
 567             else if (info.gotSize)
 
 568                 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
 
 569                                      proportion, flag, border, data);
 
 574 //    virtual wxSizerItem* PrependSpacer(int size);
 
 575 //    virtual wxSizerItem* PrependStretchSpacer(int prop = 1);
 
 578                 "Remove(self, item) -> bool",
 
 579                 "Removes an item from the sizer and destroys it.  This method does not
 
 580 cause any layout or resizing to take place, call `Layout` to update
 
 581 the layout on screen after removing a child from the sizer.  The
 
 582 *item* parameter can be either a window, a sizer, or the zero-based
 
 583 index of an item to remove.  Returns True if the child item was found
 
 586 :note: For historical reasons calling this method with a `wx.Window`
 
 587     parameter is depreacted, as it will not be able to destroy the
 
 588     window since it is owned by its parent.  You should use `Detach`
 
 591         bool Remove(PyObject* item) {
 
 592             bool blocked = wxPyBeginBlockThreads();
 
 593             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 594             wxPyEndBlockThreads(blocked);
 
 596                 return self->Remove(info.window);
 
 597             else if ( info.sizer )
 
 598                 return self->Remove(info.sizer);
 
 599             else if ( info.gotPos )
 
 600                 return self->Remove(info.pos);
 
 607                 "Detach(self, item) -> bool",
 
 608                 "Detaches an item from the sizer without destroying it.  This method
 
 609 does not cause any layout or resizing to take place, call `Layout` to
 
 610 do so.  The *item* parameter can be either a window, a sizer, or the
 
 611 zero-based index of the item to be detached.  Returns True if the child item
 
 612 was found and detached.", "");
 
 613         bool Detach(PyObject* item) {
 
 614             bool blocked = wxPyBeginBlockThreads();
 
 615             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 616             wxPyEndBlockThreads(blocked);
 
 618                 return self->Detach(info.window);
 
 619             else if ( info.sizer )
 
 620                 return self->Detach(info.sizer);
 
 621             else if ( info.gotPos )
 
 622                 return self->Detach(info.pos);
 
 629                 "GetItem(self, item) -> wx.SizerItem",
 
 630                 "Returns the `wx.SizerItem` which holds the *item* given.  The *item*
 
 631 parameter can be either a window, a sizer, or the zero-based index of
 
 632 the item to be detached.", "");
 
 633         wxSizerItem* GetItem(PyObject* item) {
 
 634             bool blocked = wxPyBeginBlockThreads();
 
 635             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 636             wxPyEndBlockThreads(blocked);
 
 638                 return self->GetItem(info.window);
 
 639             else if ( info.sizer )
 
 640                 return self->GetItem(info.sizer);
 
 641             else if ( info.gotPos )
 
 642                 return self->GetItem(info.pos);
 
 648         void _SetItemMinSize(PyObject* item, const wxSize& size) {
 
 649             bool blocked = wxPyBeginBlockThreads();
 
 650             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 651             wxPyEndBlockThreads(blocked);
 
 653                 self->SetItemMinSize(info.window, size);
 
 654             else if ( info.sizer )
 
 655                 self->SetItemMinSize(info.sizer, size);
 
 656             else if ( info.gotPos )
 
 657                 self->SetItemMinSize(info.pos, size);
 
 662     def SetItemMinSize(self, item, *args):
 
 664         SetItemMinSize(self, item, Size size)
 
 666         Sets the minimum size that will be allocated for an item in the sizer.
 
 667         The *item* parameter can be either a window, a sizer, or the
 
 668         zero-based index of the item.  If a window or sizer is given then it
 
 669         will be searched for recursivly in subsizers if neccessary.
 
 672             %# for backward compatibility accept separate width,height args too
 
 673             return self._SetItemMinSize(item, args)
 
 675             return self._SetItemMinSize(item, args[0])
 
 679         wxSizerItem* , Add( wxSizerItem *item ),
 
 680         "AddItem(self, SizerItem item)",
 
 681         "Adds a `wx.SizerItem` to the sizer.", "",
 
 685         wxSizerItem* , Insert( size_t index, wxSizerItem *item ),
 
 686         "InsertItem(self, int index, SizerItem item)",
 
 687         "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
 
 691         wxSizerItem* , Prepend( wxSizerItem *item ),
 
 692         "PrependItem(self, SizerItem item)",
 
 693         "Prepends a `wx.SizerItem` to the sizer.", "",
 
 699     def AddMany(self, items):
 
 701         AddMany is a convenience method for adding several items
 
 702         to a sizer at one time.  Simply pass it a list of tuples,
 
 703         where each tuple consists of the parameters that you
 
 704         would normally pass to the `Add` method.
 
 707             if type(item) != type(()) or (len(item) == 2 and type(item[0]) == type(1)):
 
 711     %# for backwards compatibility only, please do not use in new code
 
 712     AddWindow     = wx._deprecated(Add, "AddWindow is deprecated, use `Add` instead.")
 
 713     AddSizer      = wx._deprecated(Add, "AddSizer is deprecated, use `Add` instead.")
 
 714     AddSpacer     = wx._deprecated(Add, "AddSpacer is deprecated, use `Add` instead.")
 
 715     PrependWindow = wx._deprecated(Prepend, "PrependWindow is deprecated, use `Prepend` instead.")
 
 716     PrependSizer  = wx._deprecated(Prepend, "PrependSizer is deprecated, use `Prepend` instead.")
 
 717     PrependSpacer = wx._deprecated(Prepend, "PrependSpacer is deprecated, use `Prepend` instead.")
 
 718     InsertWindow  = wx._deprecated(Insert, "InsertWindow is deprecated, use `Insert` instead.")
 
 719     InsertSizer   = wx._deprecated(Insert, "InsertSizer is deprecated, use `Insert` instead.")
 
 720     InsertSpacer  = wx._deprecated(Insert, "InsertSpacer is deprecated, use `Insert` instead.")
 
 721     RemoveWindow  = wx._deprecated(Remove, "RemoveWindow is deprecated, use `Remove` instead.")
 
 722     RemoveSizer   = wx._deprecated(Remove, "RemoveSizer is deprecated, use `Remove` instead.")
 
 723     RemovePos     = wx._deprecated(Remove, "RemovePos is deprecated, use `Remove` instead.")
 
 729         void , SetDimension( int x, int y, int width, int height ),
 
 730         "Call this to force the sizer to take the given dimension and thus
 
 731 force the items owned by the sizer to resize themselves according to
 
 732 the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
 
 736         void , SetMinSize( const wxSize &size ),
 
 737         "Call this to give the sizer a minimal size. Normally, the sizer will
 
 738 calculate its minimal size based purely on how much space its children
 
 739 need. After calling this method `GetMinSize` will return either the
 
 740 minimal size as requested by its children or the minimal size set
 
 741 here, depending on which is bigger.", "");
 
 746         "Returns the current size of the space managed by the sizer.", "");
 
 749         wxPoint , GetPosition(),
 
 750         "Returns the current position of the sizer's managed space.", "");
 
 753         wxSize , GetMinSize(),
 
 754         "Returns the minimal size of the sizer. This is either the combined
 
 755 minimal size of all the children and their borders or the minimal size
 
 756 set by SetMinSize, depending on which is bigger.", "");
 
 760     def GetSizeTuple(self):
 
 761         return self.GetSize().Get()
 
 762     def GetPositionTuple(self):
 
 763         return self.GetPosition().Get()
 
 764     def GetMinSizeTuple(self):
 
 765         return self.GetMinSize().Get()
 
 769         virtual void , RecalcSizes(),
 
 770         "Using the sizes calculated by `CalcMin` reposition and resize all the
 
 771 items managed by this sizer.  You should not need to call this directly as
 
 772 it is called by `Layout`.", "");
 
 775         virtual wxSize , CalcMin(),
 
 776         "This method is where the sizer will do the actual calculation of its
 
 777 children's minimal sizes.  You should not need to call this directly as
 
 778 it is called by `Layout`.", "");
 
 783         "This method will force the recalculation and layout of the items
 
 784 controlled by the sizer using the current space allocated to the
 
 785 sizer.  Normally this is called automatically from the owning window's
 
 786 EVT_SIZE handler, but it is also useful to call it from user code when
 
 787 one of the items in a sizer change size, or items are added or
 
 792         wxSize , Fit( wxWindow *window ),
 
 793         "Tell the sizer to resize the *window* to match the sizer's minimal
 
 794 size. This is commonly done in the constructor of the window itself in
 
 795 order to set its initial size to match the needs of the children as
 
 796 determined by the sizer.  Returns the new size.
 
 798 For a top level window this is the total window size, not the client size.", "");
 
 801         void , FitInside( wxWindow *window ),
 
 802         "Tell the sizer to resize the *virtual size* of the *window* to match the
 
 803 sizer's minimal size. This will not alter the on screen size of the
 
 804 window, but may cause the addition/removal/alteration of scrollbars
 
 805 required to view the virtual area in windows which manage it.
 
 807 :see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
 
 812         void , SetSizeHints( wxWindow *window ),
 
 813         "Tell the sizer to set (and `Fit`) the minimal size of the *window* to
 
 814 match the sizer's minimal size. This is commonly done in the
 
 815 constructor of the window itself if the window is resizable (as are
 
 816 many dialogs under Unix and frames on probably all platforms) in order
 
 817 to prevent the window from being sized smaller than the minimal size
 
 818 required by the sizer.", "");
 
 821         void , SetVirtualSizeHints( wxWindow *window ),
 
 822         "Tell the sizer to set the minimal size of the window virtual area to
 
 823 match the sizer's minimal size. For windows with managed scrollbars
 
 824 this will set them appropriately.
 
 826 :see: `wx.ScrolledWindow.SetScrollbars`
 
 831         void , Clear( bool deleteWindows=false ),
 
 832         "Clear all items from the sizer, optionally destroying the window items
 
 836         void , DeleteWindows(),
 
 837         "Destroy all windows managed by the sizer.", "");
 
 841     // wxList& GetChildren();
 
 844                 "GetChildren(self) -> list",
 
 845                 "Returns a list of all the `wx.SizerItem` objects managed by the sizer.", "");
 
 846         PyObject* GetChildren() {
 
 847             wxSizerItemList& list = self->GetChildren();
 
 848             return wxPy_ConvertList(&list);
 
 853     // Manage whether individual windows or subsizers are considered
 
 854     // in the layout calculations or not.
 
 858                 "Show(self, item, bool show=True, bool recursive=false) -> bool",
 
 859                 "Shows or hides an item managed by the sizer.  To make a sizer item
 
 860 disappear or reappear, use Show followed by `Layout`.  The *item*
 
 861 parameter can be either a window, a sizer, or the zero-based index of
 
 862 the item.  Use the recursive parameter to show or hide an item in a
 
 863 subsizer.  Returns True if the item was found.", "");
 
 864         bool Show(PyObject* item, bool show = true, bool recursive=false) {
 
 865             bool blocked = wxPyBeginBlockThreads();
 
 866             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
 
 867             wxPyEndBlockThreads(blocked);
 
 869                 return self->Show(info.window, show, recursive);
 
 870             else if ( info.sizer )
 
 871                 return self->Show(info.sizer, show, recursive);
 
 872             else if ( info.gotPos )
 
 873                 return self->Show(info.pos, show);
 
 879                 "IsShown(self, item)",
 
 880                 "Determines if the item is currently shown. sizer.  To make a sizer
 
 881 item disappear or reappear, use Show followed by `Layout`.  The *item*
 
 882 parameter can be either a window, a sizer, or the zero-based index of
 
 884         bool IsShown(PyObject* item) {
 
 885             bool blocked = wxPyBeginBlockThreads();
 
 886             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false);
 
 887             wxPyEndBlockThreads(blocked);
 
 889                 return self->IsShown(info.window);
 
 890             else if ( info.sizer ) 
 
 891                 return self->IsShown(info.sizer);
 
 892             else if ( info.gotPos )
 
 893                 return self->IsShown(info.pos);
 
 900     def Hide(self, item, recursive=False):
 
 902         A convenience method for Show(item, False, recursive).
 
 904         return self.Show(item, False, recursive)
 
 909         void , ShowItems(bool show),
 
 910         "Recursively call `wx.SizerItem.Show` on all sizer items.", "");
 
 915 //---------------------------------------------------------------------------
 
 916 // Use this one for deriving Python classes from
 
 919 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
 
 920 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
 
 921 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
 
 926 "wx.PySizer is a special version of `wx.Sizer` that has been
 
 927 instrumented to allow the C++ virtual methods to be overloaded in
 
 928 Python derived classes.  You would derive from this class if you are
 
 929 wanting to implement a custom sizer in Python code.  Simply implement
 
 930 `CalcMin` and `RecalcSizes` in the derived class and you're all set.
 
 933     class MySizer(wx.PySizer):
 
 935              wx.PySizer.__init__(self)
 
 938              for item in self.GetChildren():
 
 939                   # calculate the total minimum width and height needed
 
 940                   # by all items in the sizer according to this sizer's
 
 943              return wx.Size(width, height)
 
 945           def RecalcSizes(self):
 
 946               # find the space allotted to this sizer
 
 947               pos = self.GetPosition()
 
 948               size = self.GetSize()
 
 949               for item in self.GetChildren():
 
 950                   # Recalculate (if necessary) the position and size of
 
 951                   # each item and then call item.SetDimension to do the
 
 952                   # actual positioning and sizing of the items within the
 
 953                   # space alloted to this sizer.
 
 955                   item.SetDimension(itemPos, itemSize)
 
 958 When `Layout` is called it first calls `CalcMin` followed by
 
 959 `RecalcSizes` so you can optimize a bit by saving the results of
 
 960 `CalcMin` and reusing them in `RecalcSizes`.
 
 962 :see: `wx.SizerItem`, `wx.Sizer.GetChildren`
 
 965 class wxPySizer : public wxSizer {
 
 967     %pythonAppend wxPySizer "self._setCallbackInfo(self, PySizer);self._setOORInfo(self)"
 
 971         "Creates a wx.PySizer.  Must be called from the __init__ in the derived
 
 974     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 978 //---------------------------------------------------------------------------
 
 983 "The basic idea behind a box sizer is that windows will most often be
 
 984 laid out in rather simple basic geometry, typically in a row or a
 
 985 column or nested hierarchies of either.  A wx.BoxSizer will lay out
 
 986 its items in a simple row or column, depending on the orientation
 
 987 parameter passed to the constructor.", "
 
 989 It is the unique feature of a box sizer, that it can grow in both
 
 990 directions (height and width) but can distribute its growth in the
 
 991 main direction (horizontal for a row) *unevenly* among its children.
 
 992 This is determined by the proportion parameter give to items when they
 
 993 are added to the sizer. It is interpreted as a weight factor, i.e. it
 
 994 can be zero, indicating that the window may not be resized at all, or
 
 995 above zero. If several windows have a value above zero, the value is
 
 996 interpreted relative to the sum of all weight factors of the sizer, so
 
 997 when adding two windows with a value of 1, they will both get resized
 
 998 equally and each will receive half of the available space after the
 
 999 fixed size items have been sized.  If the items have unequal
 
1000 proportion settings then they will receive a coresondingly unequal
 
1001 allotment of the free space.
 
1003 :see: `wx.StaticBoxSizer`
 
1006 class  wxBoxSizer : public wxSizer {
 
1008     %pythonAppend wxBoxSizer "self._setOORInfo(self)"
 
1011         wxBoxSizer(int orient = wxHORIZONTAL),
 
1012         "Constructor for a wx.BoxSizer. *orient* may be one of ``wx.VERTICAL``
 
1013 or ``wx.HORIZONTAL`` for creating either a column sizer or a row
 
1018         int , GetOrientation(),
 
1019         "Returns the current orientation of the sizer.", "");
 
1022         void , SetOrientation(int orient),
 
1023         "Resets the orientation of the sizer.", "");
 
1027 //---------------------------------------------------------------------------
 
1031 DocStr(wxStaticBoxSizer,
 
1032 "wx.StaticBoxSizer derives from and functions identically to the
 
1033 `wx.BoxSizer` and adds a `wx.StaticBox` around the items that the sizer
 
1034 manages.  Note that this static box must be created separately and
 
1035 passed to the sizer constructor.", "");
 
1037 class  wxStaticBoxSizer : public wxBoxSizer {
 
1039     %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)"
 
1042         wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL),
 
1043         "Constructor. It takes an associated static box and the orientation
 
1044 *orient* as parameters - orient can be either of ``wx.VERTICAL`` or
 
1045 ``wx.HORIZONTAL``.", "");
 
1047     // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
 
1050         wxStaticBox *, GetStaticBox(),
 
1051         "Returns the static box associated with this sizer.", "");
 
1055 //---------------------------------------------------------------------------
 
1060 "A grid sizer is a sizer which lays out its children in a
 
1061 two-dimensional table with all cells having the same size.  In other
 
1062 words, the width of each cell within the grid is the width of the
 
1063 widest item added to the sizer and the height of each grid cell is the
 
1064 height of the tallest item.  An optional vertical and/or horizontal
 
1065 gap between items can also be specified (in pixels.)
 
1067 Items are placed in the cells of the grid in the order they are added,
 
1068 in row-major order.  In other words, the first row is filled first,
 
1069 then the second, and so on until all items have been added. (If
 
1070 neccessary, additional rows will be added as items are added.)  If you
 
1071 need to have greater control over the cells that items are placed in
 
1072 then use the `wx.GridBagSizer`.
 
1075 class wxGridSizer: public wxSizer
 
1078     %pythonAppend wxGridSizer "self._setOORInfo(self)"
 
1081         wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
 
1082         "Constructor for a wx.GridSizer. *rows* and *cols* determine the number
 
1083 of columns and rows in the sizer - if either of the parameters is
 
1084 zero, it will be calculated to from the total number of children in
 
1085 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
 
1086 define extra space between all children.", "");
 
1089         void , SetCols( int cols ),
 
1090         "Sets the number of columns in the sizer.", "");
 
1093         void , SetRows( int rows ),
 
1094         "Sets the number of rows in the sizer.", "");
 
1097         void , SetVGap( int gap ),
 
1098         "Sets the vertical gap (in pixels) between the cells in the sizer.", "");
 
1101         void , SetHGap( int gap ),
 
1102         "Sets the horizontal gap (in pixels) between cells in the sizer", "");
 
1106         "Returns the number of columns in the sizer.", "");
 
1110         "Returns the number of rows in the sizer.", "");
 
1114         "Returns the vertical gap (in pixels) between the cells in the sizer.", "");
 
1118         "Returns the horizontal gap (in pixels) between cells in the sizer.", "");
 
1122 //---------------------------------------------------------------------------
 
1125 enum wxFlexSizerGrowMode
 
1127     // don't resize the cells in non-flexible direction at all
 
1128     wxFLEX_GROWMODE_NONE,
 
1130     // uniformly resize only the specified ones (default)
 
1131     wxFLEX_GROWMODE_SPECIFIED,
 
1133     // uniformly resize all cells
 
1141 DocStr(wxFlexGridSizer,
 
1142 "A flex grid sizer is a sizer which lays out its children in a
 
1143 two-dimensional table with all table cells in one row having the same
 
1144 height and all cells in one column having the same width, but all
 
1145 rows or all columns are not necessarily the same height or width as in
 
1148 wx.FlexGridSizer can also size items equally in one direction but
 
1149 unequally (\"flexibly\") in the other. If the sizer is only flexible
 
1150 in one direction (this can be changed using `SetFlexibleDirection`), it
 
1151 needs to be decided how the sizer should grow in the other (\"non
 
1152 flexible\") direction in order to fill the available space. The
 
1153 `SetNonFlexibleGrowMode` method serves this purpose.
 
1157 class wxFlexGridSizer: public wxGridSizer
 
1160     %pythonAppend wxFlexGridSizer "self._setOORInfo(self)"
 
1163         wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
 
1164         "Constructor for a wx.FlexGridSizer. *rows* and *cols* determine the
 
1165 number of columns and rows in the sizer - if either of the parameters
 
1166 is zero, it will be calculated to from the total number of children in
 
1167 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
 
1168 define extra space between all children.", "");
 
1172         void , AddGrowableRow( size_t idx, int proportion = 0  ),
 
1173         "Specifies that row *idx* (starting from zero) should be grown if there
 
1174 is extra space available to the sizer.
 
1176 The *proportion* parameter has the same meaning as the stretch factor
 
1177 for the box sizers except that if all proportions are 0, then all
 
1178 columns are resized equally (instead of not being resized at all).", "");
 
1181         void , RemoveGrowableRow( size_t idx ),
 
1182         "Specifies that row *idx* is no longer growable.", "");
 
1185         void , AddGrowableCol( size_t idx, int proportion = 0  ),
 
1186         "Specifies that column *idx* (starting from zero) should be grown if
 
1187 there is extra space available to the sizer.
 
1189 The *proportion* parameter has the same meaning as the stretch factor
 
1190 for the box sizers except that if all proportions are 0, then all
 
1191 columns are resized equally (instead of not being resized at all).", "");
 
1194         void , RemoveGrowableCol( size_t idx ),
 
1195         "Specifies that column *idx* is no longer growable.", "");
 
1199         void , SetFlexibleDirection(int direction),
 
1200         "Specifies whether the sizer should flexibly resize its columns, rows,
 
1201 or both. Argument *direction* can be one of the following values.  Any
 
1202 other value is ignored.
 
1204     ==============    =======================================
 
1205     wx.VERTICAL       Rows are flexibly sized.
 
1206     wx.HORIZONTAL     Columns are flexibly sized.
 
1207     wx.BOTH           Both rows and columns are flexibly sized
 
1208                       (this is the default value).
 
1209     ==============    =======================================
 
1211 Note that this method does not trigger relayout.
 
1215         int , GetFlexibleDirection(),
 
1216         "Returns a value that specifies whether the sizer
 
1217 flexibly resizes its columns, rows, or both (default).
 
1219 :see: `SetFlexibleDirection`", "");
 
1224         void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
 
1225         "Specifies how the sizer should grow in the non-flexible direction if
 
1226 there is one (so `SetFlexibleDirection` must have been called
 
1227 previously). Argument *mode* can be one of the following values:
 
1229     ==========================  =================================================
 
1230     wx.FLEX_GROWMODE_NONE       Sizer doesn't grow in the non flexible direction.
 
1231     wx.FLEX_GROWMODE_SPECIFIED  Sizer honors growable columns/rows set with
 
1232                                 `AddGrowableCol` and `AddGrowableRow`. In this
 
1233                                 case equal sizing applies to minimum sizes of
 
1234                                 columns or rows (this is the default value).
 
1235     wx.FLEX_GROWMODE_ALL        Sizer equally stretches all columns or rows in
 
1236                                 the non flexible direction, whether they are
 
1237                                 growable or not in the flexbile direction.
 
1238     ==========================  =================================================
 
1240 Note that this method does not trigger relayout.
 
1245         wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
 
1246         "Returns the value that specifies how the sizer grows in the
 
1247 non-flexible direction if there is one.
 
1249 :see: `SetNonFlexibleGrowMode`", "");
 
1252     // Read-only access to the row heights and col widths arrays
 
1254         const wxArrayInt& , GetRowHeights() const,
 
1255         "GetRowHeights(self) -> list",
 
1256         "Returns a list of integers representing the heights of each of the
 
1257 rows in the sizer.", "");
 
1260         const wxArrayInt& , GetColWidths() const,
 
1261         "GetColWidths(self) -> list",
 
1262         "Returns a list of integers representing the widths of each of the
 
1263 columns in the sizer.", "");
 
1267 //---------------------------------------------------------------------------
 
1269 DocStr(wxStdDialogButtonSizer,
 
1270 "A special sizer that knows how to order and position standard buttons
 
1271 in order to conform to the current platform's standards.  You simply
 
1272 need to add each `wx.Button` to the sizer, and be sure to create the
 
1273 buttons using the standard ID's.  Then call `Finalize` and the sizer
 
1274 will take care of the rest.
 
1277 class wxStdDialogButtonSizer: public wxBoxSizer
 
1281         wxStdDialogButtonSizer(),
 
1285         void , AddButton(wxButton *button),
 
1286         "Use this to add the buttons to this sizer.  Do not use the `Add`
 
1287 method in the base class.", "");
 
1291         "This funciton needs to be called after all the buttons have been added
 
1292 to the sizer.  It will reorder them and position them in a platform
 
1293 specifc manner.", "");
 
1295     void SetAffirmativeButton( wxButton *button );
 
1296     void SetNegativeButton( wxButton *button );
 
1297     void SetCancelButton( wxButton *button );
 
1299     wxButton* GetAffirmativeButton() const;
 
1300     wxButton* GetApplyButton() const;
 
1301     wxButton* GetNegativeButton() const;
 
1302     wxButton* GetCancelButton() const;
 
1303     wxButton* GetHelpButton() const;
 
1307 //---------------------------------------------------------------------------