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 %name(SizerItemWindow) wxSizerItem( wxWindow *window, int proportion, int flag,
55 int border, PyObject* userData=NULL ) {
56 wxPyUserData* data = NULL;
58 bool blocked = wxPyBeginBlockThreads();
59 data = new wxPyUserData(userData);
60 wxPyEndBlockThreads(blocked);
62 return new wxSizerItem(window, proportion, flag, border, data);
67 wxSizerItem( int width, int height, int proportion, int flag,
68 int border, PyObject* userData=NULL),
69 "Constructs a `wx.SizerItem` for tracking a spacer.", "");
70 %name(SizerItemSpacer) wxSizerItem( int width, int height, int proportion, int flag,
71 int border, PyObject* userData=NULL) {
72 wxPyUserData* data = NULL;
74 bool blocked = wxPyBeginBlockThreads();
75 data = new wxPyUserData(userData);
76 wxPyEndBlockThreads(blocked);
78 return new wxSizerItem(width, height, proportion, flag, border, data);
82 wxSizerItem( wxSizer *sizer, int proportion, int flag,
83 int border, PyObject* userData=NULL ),
84 "Constructs a `wx.SizerItem` for tracking a subsizer", "");
85 %name(SizerItemSizer) wxSizerItem( wxSizer *sizer, int proportion, int flag,
86 int border, PyObject* userData=NULL ) {
87 wxPyUserData* data = NULL;
89 bool blocked = wxPyBeginBlockThreads();
90 data = new wxPyUserData(userData);
91 wxPyEndBlockThreads(blocked);
93 return new wxSizerItem(sizer, proportion, flag, border, data);
100 void , DeleteWindows(),
101 "Destroy the window or the windows in a subsizer, depending on the type
105 void , DetachSizer(),
106 "Enable deleting the SizerItem without destroying the contained sizer.", "");
111 "Get the current size of the item, as set in the last Layout.", "");
115 "Calculates the minimum desired size for the item, including any space
116 needed by borders.", "");
119 void , SetDimension( wxPoint pos, wxSize size ),
120 "Set the position and size of the space allocated for this item by the
121 sizer, and adjust the position and size of the item (window or
122 subsizer) to be within that space taking alignment and borders into
127 wxSize , GetMinSize(),
128 "Get the minimum size needed for the item.", "");
131 wxSize , GetMinSizeWithBorder() const,
132 "Get the minimum size needed for the item with space for the borders
133 added, if needed.", "");
136 void , SetInitSize( int x, int y ),
141 "Set the ratio item attribute.", "");
142 %name(SetRatioWH) void SetRatio( int width, int height );
143 %name(SetRatioSize) void SetRatio( wxSize size );
144 void SetRatio( float ratio );
148 "Set the ratio item attribute.", "");
153 "Is this sizer item a window?", "");
157 "Is this sizer item a subsizer?", "");
161 "Is this sizer item a spacer?", "");
165 void , SetProportion( int proportion ),
166 "Set the proportion value for this item.", "");
169 int , GetProportion(),
170 "Get the proportion value for this item.", "");
172 %pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
173 %pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
177 void , SetFlag( int flag ),
178 "Set the flag value for this item.", "");
182 "Get the flag value for this item.", "");
186 void , SetBorder( int border ),
187 "Set the border value for this item.", "");
191 "Get the border value for this item.", "");
196 wxWindow *, GetWindow(),
197 "Get the window (if any) that is managed by this sizer item.", "");
200 void , SetWindow( wxWindow *window ),
201 "Set the window to be managed by this sizer item.", "");
205 wxSizer *, GetSizer(),
206 "Get the subsizer (if any) that is managed by this sizer item.", "");
209 void , SetSizer( wxSizer *sizer ),
210 "Set the subsizer to be managed by this sizer item.", "");
214 const wxSize& , GetSpacer(),
215 "Get the size of the spacer managed by this sizer item.", "");
218 void , SetSpacer( const wxSize &size ),
219 "Set the size of the spacer to be managed by this sizer item.", "");
223 void , Show( bool show ),
224 "Set the show item attribute, which sizers use to determine if the item
225 is to be made part of the layout or not. If the item is tracking a
226 window then it is shown or hidden as needed.", "");
230 "Is the item to be shown in the layout?", "");
234 wxPoint , GetPosition(),
235 "Returns the current position of the item, as set in the last Layout.", "");
238 // wxObject* GetUserData();
240 // Assume that the user data is a wxPyUserData object and return the contents
243 "Returns the userData associated with this sizer item, or None if there
245 PyObject* GetUserData() {
246 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
248 Py_INCREF(data->m_obj);
259 //---------------------------------------------------------------------------
262 // Figure out the type of the sizer item
264 struct wxPySizerItemInfo {
266 : window(NULL), sizer(NULL), gotSize(False),
267 size(wxDefaultSize), gotPos(False), pos(-1)
278 static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
280 wxPySizerItemInfo info;
282 wxSize* sizePtr = &size;
284 // Find out what the type of the item is
286 if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
291 if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
295 // try wxSize or (w,h)
296 if ( checkSize && wxSize_helper(item, &sizePtr)) {
297 info.size = *sizePtr;
302 if (checkIdx && PyInt_Check(item)) {
303 info.pos = PyInt_AsLong(item);
309 if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
310 // no expected type, figure out what kind of error message to generate
311 if ( !checkSize && !checkIdx )
312 PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected for item");
313 else if ( checkSize && !checkIdx )
314 PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) expected for item");
315 else if ( !checkSize && checkIdx)
316 PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer or int (position) expected for item");
318 // can this one happen?
319 PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) or int (position) expected for item");
330 "wx.Sizer is the abstract base class used for laying out subwindows in
331 a window. You cannot use wx.Sizer directly; instead, you will have to
332 use one of the sizer classes derived from it such as `wx.BoxSizer`,
333 `wx.StaticBoxSizer`, `wx.NotebookSizer`, `wx.GridSizer`, `wx.FlexGridSizer`
334 and `wx.GridBagSizer`.
336 The concept implemented by sizers in wxWidgets is closely related to
337 layout tools in other GUI toolkits, such as Java's AWT, the GTK
338 toolkit or the Qt toolkit. It is based upon the idea of the individual
339 subwindows reporting their minimal required size and their ability to
340 get stretched if the size of the parent window has changed. This will
341 most often mean that the programmer does not set the original size of
342 a dialog in the beginning, rather the dialog will assigned a sizer and
343 this sizer will be queried about the recommended size. The sizer in
344 turn will query its children, which can be normal windows or contorls,
345 empty space or other sizers, so that a hierarchy of sizers can be
346 constructed. Note that wxSizer does not derive from wxWindow and thus
347 do not interfere with tab ordering and requires very little resources
348 compared to a real window on screen.
350 What makes sizers so well fitted for use in wxWidgets is the fact that
351 every control reports its own minimal size and the algorithm can
352 handle differences in font sizes or different window (dialog item)
353 sizes on different platforms without problems. If for example the
354 standard font as well as the overall design of Mac widgets requires
355 more space than on Windows, then the initial size of a dialog using a
356 sizer will automatically be bigger on Mac than on Windows.", "
358 :note: If you wish to create a custom sizer class in wxPython you
359 should derive the class from `wx.PySizer` in order to get
360 Python-aware capabilities for the various virtual methods.
364 :todo: More dscriptive text here along with some pictures...
368 class wxSizer : public wxObject {
370 // wxSizer(); **** abstract, can't instantiate
374 void _setOORInfo(PyObject* _self) {
375 if (!self->GetClientObject())
376 self->SetClientObject(new wxPyOORClientData(_self));
380 "Add(self, item, int proportion=0, int flag=0, int border=0,
381 PyObject userData=None)",
383 "Appends a child item to the sizer.", "
385 :param item: The item can be one of three kinds of objects:
387 - **window**: A `wx.Window` to be managed by the sizer. Its
388 minimal size (either set explicitly by the user or
389 calculated internally when constructed with wx.DefaultSize)
390 is interpreted as the minimal size to use when laying out
391 item in the sizer. This is particularly useful in
392 connection with `wx.Window.SetSizeHints`.
394 - **sizer**: The (child-)sizer to be added to the sizer. This
395 allows placing a child sizer in a sizer and thus to create
396 hierarchies of sizers (typically a vertical box as the top
397 sizer and several horizontal boxes on the level beneath).
399 - **size**: A `wx.Size` or a 2-element sequence of integers
400 that represents the width and height of a spacer to be added
401 to the sizer. Adding spacers to sizers gives more
402 flexibility in the design of dialogs; imagine for example a
403 horizontal box with two buttons at the bottom of a dialog:
404 you might want to insert a space between the two buttons and
405 make that space stretchable using the *proportion* value and
406 the result will be that the left button will be aligned with
407 the left side of the dialog and the right button with the
408 right side - the space in between will shrink and grow with
411 :param proportion: Although the meaning of this parameter is
412 undefined in wx.Sizer, it is used in `wx.BoxSizer` to indicate
413 if a child of a sizer can change its size in the main
414 orientation of the wx.BoxSizer - where 0 stands for not
415 changeable and a value of more than zero is interpreted
416 relative (a proportion of the total) to the value of other
417 children of the same wx.BoxSizer. For example, you might have
418 a horizontal wx.BoxSizer with three children, two of which are
419 supposed to change their size with the sizer. Then the two
420 stretchable windows should each be given *proportion* value of
421 1 to make them grow and shrink equally with the sizer's
422 horizontal dimension. But if one of them had a *proportion*
423 value of 2 then it would get a double share of the space
424 available after the fixed size items are positioned.
426 :param flag: This parameter can be used to set a number of flags
427 which can be combined using the binary OR operator ``|``. Two
428 main behaviours are defined using these flags. One is the
429 border around a window: the *border* parameter determines the
430 border width whereas the flags given here determine which
431 side(s) of the item that the border will be added. The other
432 flags determine how the sizer item behaves when the space
433 allotted to the sizer changes, and is somewhat dependent on
434 the specific kind of sizer used.
436 +----------------------------+------------------------------------------+
437 |- wx.TOP |These flags are used to specify |
438 |- wx.BOTTOM |which side(s) of the sizer item that |
439 |- wx.LEFT |the *border* width will apply to. |
443 +----------------------------+------------------------------------------+
444 |- wx.EXAPAND |The item will be expanded to fill |
445 | |the space allotted to the item. |
446 +----------------------------+------------------------------------------+
447 |- wx.SHAPED |The item will be expanded as much as |
448 | |possible while also maintaining its |
450 +----------------------------+------------------------------------------+
451 |- wx.FIXED_MINSIZE |Normally wx.Sizers will use |
452 | |`wx.Window.GetMinSize` or |
453 | |`wx.Window.GetBestSize` to determine what |
454 | |the minimal size of window items should |
455 | |be, and will use that size to calculate |
456 | |the layout. This allows layouts to adjust |
457 | |when an item changes and it's best size |
458 | |becomes different. If you would rather |
459 | |have a window item stay the size it |
460 | |started with then use wx.FIXED_MINSIZE. |
461 +----------------------------+------------------------------------------+
462 |- wx.ALIGN_CENTER |The wx.ALIGN flags allow you to specify |
463 |- wx.ALIGN_LEFT |the alignment of the item within the space|
464 |- wx.ALIGN_RIGHT |allotted to it by the sizer, ajusted for |
465 |- wx.ALIGN_TOP |the border if any. |
466 |- wx.ALIGN_BOTTOM | |
467 |- wx.ALIGN_CENTER_VERTICAL | |
468 |- wx.ALIGN_CENTER_HORIZONTAL| |
469 +----------------------------+------------------------------------------+
472 :param border: Determines the border width, if the *flag*
473 parameter is set to include any border flag.
475 :param userData: Allows an extra object to be attached to the
476 sizer item, for use in derived classes when sizing information
477 is more complex than the *proportion* and *flag* will allow for.
480 void Add(PyObject* item, int proportion=0, int flag=0, int border=0,
481 PyObject* userData=NULL) {
483 wxPyUserData* data = NULL;
484 bool blocked = wxPyBeginBlockThreads();
485 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
486 if ( userData && (info.window || info.sizer || info.gotSize) )
487 data = new wxPyUserData(userData);
488 wxPyEndBlockThreads(blocked);
490 // Now call the real Add method if a valid item type was found
492 self->Add(info.window, proportion, flag, border, data);
493 else if ( info.sizer )
494 self->Add(info.sizer, proportion, flag, border, data);
495 else if (info.gotSize)
496 self->Add(info.size.GetWidth(), info.size.GetHeight(),
497 proportion, flag, border, data);
502 "Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
503 PyObject userData=None)",
505 "Inserts a new item into the list of items managed by this sizer before
506 the item at index *before*. See `Add` for a description of the parameters.", "");
507 void Insert(int before, PyObject* item, int proportion=0, int flag=0,
508 int border=0, PyObject* userData=NULL) {
510 wxPyUserData* data = NULL;
511 bool blocked = wxPyBeginBlockThreads();
512 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
513 if ( userData && (info.window || info.sizer || info.gotSize) )
514 data = new wxPyUserData(userData);
515 wxPyEndBlockThreads(blocked);
517 // Now call the real Insert method if a valid item type was found
519 self->Insert(before, info.window, proportion, flag, border, data);
520 else if ( info.sizer )
521 self->Insert(before, info.sizer, proportion, flag, border, data);
522 else if (info.gotSize)
523 self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
524 proportion, flag, border, data);
530 "Prepend(self, item, int proportion=0, int flag=0, int border=0,
531 PyObject userData=None)",
533 "Adds a new item to the begining of the list of sizer items managed by
534 this sizer. See `Add` for a description of the parameters.", "");
535 void Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
536 PyObject* userData=NULL) {
538 wxPyUserData* data = NULL;
539 bool blocked = wxPyBeginBlockThreads();
540 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
541 if ( userData && (info.window || info.sizer || info.gotSize) )
542 data = new wxPyUserData(userData);
543 wxPyEndBlockThreads(blocked);
545 // Now call the real Prepend method if a valid item type was found
547 self->Prepend(info.window, proportion, flag, border, data);
548 else if ( info.sizer )
549 self->Prepend(info.sizer, proportion, flag, border, data);
550 else if (info.gotSize)
551 self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
552 proportion, flag, border, data);
557 "Remove(self, item) -> bool",
558 "Removes an item from the sizer and destroys it. This method does not
559 cause any layout or resizing to take place, call `Layout` to update
560 the layout on screen after removing a child from the sizer. The
561 *item* parameter can be either a window, a sizer, or the zero-based
562 index of an item to remove. Returns True if the child item was found
565 :note: For historical reasons calling this method with a `wx.Window`
566 parameter is depreacted, as it will not be able to destroy the
567 window since it is owned by its parent. You should use `Detach`
570 bool Remove(PyObject* item) {
571 bool blocked = wxPyBeginBlockThreads();
572 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
573 wxPyEndBlockThreads(blocked);
575 return self->Remove(info.window);
576 else if ( info.sizer )
577 return self->Remove(info.sizer);
578 else if ( info.gotPos )
579 return self->Remove(info.pos);
586 "Detach(self, item) -> bool",
587 "Detaches an item from the sizer without destroying it. This method
588 does not cause any layout or resizing to take place, call `Layout` to
589 do so. The *item* parameter can be either a window, a sizer, or the
590 zero-based index of the item to be detached. Returns True if the child item
591 was found and detached.", "");
592 bool Detach(PyObject* item) {
593 bool blocked = wxPyBeginBlockThreads();
594 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
595 wxPyEndBlockThreads(blocked);
597 return self->Detach(info.window);
598 else if ( info.sizer )
599 return self->Detach(info.sizer);
600 else if ( info.gotPos )
601 return self->Detach(info.pos);
607 void _SetItemMinSize(PyObject* item, const wxSize& size) {
608 bool blocked = wxPyBeginBlockThreads();
609 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
610 wxPyEndBlockThreads(blocked);
612 self->SetItemMinSize(info.window, size);
613 else if ( info.sizer )
614 self->SetItemMinSize(info.sizer, size);
615 else if ( info.gotPos )
616 self->SetItemMinSize(info.pos, size);
621 def SetItemMinSize(self, item, *args):
623 SetItemMinSize(self, item, Size size)
625 Sets the minimum size that will be allocated for an item in the sizer.
626 The *item* parameter can be either a window, a sizer, or the
627 zero-based index of the item. If a window or sizer is given then it
628 will be searched for recursivly in subsizers if neccessary.
631 %# for backward compatibility accept separate width,height args too
632 return self._SetItemMinSize(item, args)
634 return self._SetItemMinSize(item, args[0])
638 void , Add( wxSizerItem *item ),
639 "AddItem(self, SizerItem item)",
640 "Adds a `wx.SizerItem` to the sizer.", "",
644 void , Insert( size_t index, wxSizerItem *item ),
645 "InsertItem(self, int index, SizerItem item)",
646 "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
650 void , Prepend( wxSizerItem *item ),
651 "PrependItem(self, SizerItem item)",
652 "Prepends a `wx.SizerItem` to the sizer.", "",
658 def AddMany(self, items):
660 AddMany is a convenience method for adding several items
661 to a sizer at one time. Simply pass it a list of tuples,
662 where each tuple consists of the parameters that you
663 would normally pass to the `Add` method.
666 if type(item) != type(()) or (len(item) == 2 and type(item[0]) == type(1)):
670 %# for backwards compatibility only, please do not use in new code
671 AddWindow = wx._deprecated(Add, "AddWindow is deprecated, use `Add` instead.")
672 AddSizer = wx._deprecated(Add, "AddSizer is deprecated, use `Add` instead.")
673 AddSpacer = wx._deprecated(Add, "AddSpacer is deprecated, use `Add` instead.")
674 PrependWindow = wx._deprecated(Prepend, "PrependWindow is deprecated, use `Prepend` instead.")
675 PrependSizer = wx._deprecated(Prepend, "PrependSizer is deprecated, use `Prepend` instead.")
676 PrependSpacer = wx._deprecated(Prepend, "PrependSpacer is deprecated, use `Prepend` instead.")
677 InsertWindow = wx._deprecated(Insert, "InsertWindow is deprecated, use `Insert` instead.")
678 InsertSizer = wx._deprecated(Insert, "InsertSizer is deprecated, use `Insert` instead.")
679 InsertSpacer = wx._deprecated(Insert, "InsertSpacer is deprecated, use `Insert` instead.")
680 RemoveWindow = wx._deprecated(Remove, "RemoveWindow is deprecated, use `Remove` instead.")
681 RemoveSizer = wx._deprecated(Remove, "RemoveSizer is deprecated, use `Remove` instead.")
682 RemovePos = wx._deprecated(Remove, "RemovePos is deprecated, use `Remove` instead.")
688 void , SetDimension( int x, int y, int width, int height ),
689 "Call this to force the sizer to take the given dimension and thus
690 force the items owned by the sizer to resize themselves according to
691 the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
695 void , SetMinSize( const wxSize &size ),
696 "Call this to give the sizer a minimal size. Normally, the sizer will
697 calculate its minimal size based purely on how much space its children
698 need. After calling this method `GetMinSize` will return either the
699 minimal size as requested by its children or the minimal size set
700 here, depending on which is bigger.", "");
705 "Returns the current size of the space managed by the sizer.", "");
708 wxPoint , GetPosition(),
709 "Returns the current position of the sizer's managed space.", "");
712 wxSize , GetMinSize(),
713 "Returns the minimal size of the sizer. This is either the combined
714 minimal size of all the children and their borders or the minimal size
715 set by SetMinSize, depending on which is bigger.", "");
719 def GetSizeTuple(self):
720 return self.GetSize().Get()
721 def GetPositionTuple(self):
722 return self.GetPosition().Get()
723 def GetMinSizeTuple(self):
724 return self.GetMinSize().Get()
728 virtual void , RecalcSizes(),
729 "Using the sizes calculated by `CalcMin` reposition and resize all the
730 items managed by this sizer. You should not need to call this directly as
731 it is called by `Layout`.", "");
734 virtual wxSize , CalcMin(),
735 "This method is where the sizer will do the actual calculation of its
736 children's minimal sizes. You should not need to call this directly as
737 it is called by `Layout`.", "");
742 "This method will force the recalculation and layout of the items
743 controlled by the sizer using the current space allocated to the
744 sizer. Normally this is called automatically from the owning window's
745 EVT_SIZE handler, but it is also useful to call it from user code when
746 one of the items in a sizer change size, or items are added or
751 wxSize , Fit( wxWindow *window ),
752 "Tell the sizer to resize the *window* to match the sizer's minimal
753 size. This is commonly done in the constructor of the window itself in
754 order to set its initial size to match the needs of the children as
755 determined by the sizer. Returns the new size.
757 For a top level window this is the total window size, not the client size.", "");
760 void , FitInside( wxWindow *window ),
761 "Tell the sizer to resize the *virtual size* of the *window* to match the
762 sizer's minimal size. This will not alter the on screen size of the
763 window, but may cause the addition/removal/alteration of scrollbars
764 required to view the virtual area in windows which manage it.
766 :see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
771 void , SetSizeHints( wxWindow *window ),
772 "Tell the sizer to set (and `Fit`) the minimal size of the *window* to
773 match the sizer's minimal size. This is commonly done in the
774 constructor of the window itself if the window is resizable (as are
775 many dialogs under Unix and frames on probably all platforms) in order
776 to prevent the window from being sized smaller than the minimal size
777 required by the sizer.", "");
780 void , SetVirtualSizeHints( wxWindow *window ),
781 "Tell the sizer to set the minimal size of the window virtual area to
782 match the sizer's minimal size. For windows with managed scrollbars
783 this will set them appropriately.
785 :see: `wx.ScrolledWindow.SetScrollbars`
790 void , Clear( bool deleteWindows=False ),
791 "Clear all items from the sizer, optionally destroying the window items
795 void , DeleteWindows(),
796 "Destroy all windows managed by the sizer.", "");
800 // wxList& GetChildren();
803 "GetChildren(sefl) -> list",
804 "Returns a list of all the `wx.SizerItem` objects managed by the sizer.", "");
805 PyObject* GetChildren() {
806 wxSizerItemList& list = self->GetChildren();
807 return wxPy_ConvertList(&list);
812 // Manage whether individual windows or subsizers are considered
813 // in the layout calculations or not.
817 "Show(self, item, bool show=True)",
818 "Shows or hides an item managed by the sizer. To make a sizer item
819 disappear or reappear, use Show followed by `Layout`. The *item*
820 parameter can be either a window, a sizer, or the zero-based index of
822 void Show(PyObject* item, bool show = True) {
823 bool blocked = wxPyBeginBlockThreads();
824 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
825 wxPyEndBlockThreads(blocked);
827 self->Show(info.window, show);
828 else if ( info.sizer )
829 self->Show(info.sizer, show);
830 else if ( info.gotPos )
831 self->Show(info.pos, show);
835 "IsShown(self, item)",
836 "Determines if the item is currently shown. sizer. To make a sizer
837 item disappear or reappear, use Show followed by `Layout`. The *item*
838 parameter can be either a window, a sizer, or the zero-based index of
840 bool IsShown(PyObject* item) {
841 bool blocked = wxPyBeginBlockThreads();
842 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, False);
843 wxPyEndBlockThreads(blocked);
845 return self->IsShown(info.window);
846 else if ( info.sizer )
847 return self->IsShown(info.sizer);
848 else if ( info.gotPos )
849 return self->IsShown(info.pos);
856 def Hide(self, item):
858 A convenience method for Show(item, False).
860 self.Show(item, False)
865 void , ShowItems(bool show),
866 "Recursively call `wx.Window.Show` on all sizer items.", "");
871 //---------------------------------------------------------------------------
872 // Use this one for deriving Python classes from
875 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
876 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
877 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
882 "wx.PySizer is a special version of `wx.Sizer` that has been
883 instrumented to allow the C++ virtual methods to be overloaded in
884 Python derived classes. You would derive from this class if you are
885 wanting to implement a custom sizer in Python code. Simply implement
886 `CalcMin` and `RecalcSizes` in the derived class and you're all set.
889 class MySizer(wx.PySizer):
891 wx.PySizer.__init__(self)
894 for item in self.GetChildren():
895 # calculate the total minimum width and height needed
896 # by all items in the sizer according to this sizer's
899 return wx.Size(width, height)
901 def RecalcSizes(self):
902 # find the space allotted to this sizer
903 pos = self.GetPosition()
904 size = self.GetSize()
905 for item in self.GetChildren():
906 # Recalculate (if necessary) the position and size of
907 # each item and then call item.SetDimension to do the
908 # actual positioning and sizing of the items within the
909 # space alloted to this sizer.
911 item.SetDimension(itemPos, itemSize)
914 When `Layout` is called it first calls `CalcMin` followed by
915 `RecalcSizes` so you can optimize a bit by saving the results of
916 `CalcMin` and resuing them in `RecalcSizes`.
918 :see: `wx.SizerItem`, `wx.Sizer.GetChildren`
921 class wxPySizer : public wxSizer {
923 %pythonAppend wxPySizer "self._setCallbackInfo(self, PySizer);self._setOORInfo(self)"
927 "Creates a wx.PySizer. Must be called from the __init__ in the derived
930 void _setCallbackInfo(PyObject* self, PyObject* _class);
934 //---------------------------------------------------------------------------
939 "The basic idea behind a box sizer is that windows will most often be
940 laid out in rather simple basic geometry, typically in a row or a
941 column or nested hierarchies of either. A wx.BoxSizer will lay out
942 its items in a simple row or column, depending on the orientation
943 parameter passed to the constructor.", "
945 It is the unique feature of a box sizer, that it can grow in both
946 directions (height and width) but can distribute its growth in the
947 main direction (horizontal for a row) *unevenly* among its children.
948 This is determined by the proportion parameter give to items when they
949 are added to the sizer. It is interpreted as a weight factor, i.e. it
950 can be zero, indicating that the window may not be resized at all, or
951 above zero. If several windows have a value above zero, the value is
952 interpreted relative to the sum of all weight factors of the sizer, so
953 when adding two windows with a value of 1, they will both get resized
954 equally and each will receive half of the available space after the
955 fixed size items have been sized. If the items have unequal
956 proportion settings then they will receive a coresondingly unequal
957 allotment of the free space.
959 :see: `wx.StaticBoxSizer`
962 class wxBoxSizer : public wxSizer {
964 %pythonAppend wxBoxSizer "self._setOORInfo(self)"
967 wxBoxSizer(int orient = wxHORIZONTAL),
968 "Constructor for a wx.BoxSizer. *orient* may be one of ``wx.VERTICAL``
969 or ``wx.HORIZONTAL`` for creating either a column sizer or a row
974 int , GetOrientation(),
975 "Returns the current orientation of the sizer.", "");
978 void , SetOrientation(int orient),
979 "Resets the orientation of the sizer.", "");
983 //---------------------------------------------------------------------------
987 DocStr(wxStaticBoxSizer,
988 "wx.StaticBoxSizer derives from and functions identically to the
989 `wx.BoxSizer` and adds a `wx.StaticBox` around the items that the sizer
990 manages. Note that this static box must be created separately and
991 passed to the sizer constructor.", "");
993 class wxStaticBoxSizer : public wxBoxSizer {
995 %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)"
998 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL),
999 "Constructor. It takes an associated static box and the orientation
1000 *orient* as parameters - orient can be either of ``wx.VERTICAL`` or
1001 ``wx.HORIZONTAL``.", "");
1004 wxStaticBox *, GetStaticBox(),
1005 "Returns the static box associated with this sizer.", "");
1009 //---------------------------------------------------------------------------
1014 "A grid sizer is a sizer which lays out its children in a
1015 two-dimensional table with all cells having the same size. In other
1016 words, the width of each cell within the grid is the width of the
1017 widest item added to the sizer and the height of each grid cell is the
1018 height of the tallest item. An optional vertical and/or horizontal
1019 gap between items can also be specified (in pixels.)
1021 Items are placed in the cells of the grid in the order they are added,
1022 in row-major order. In other words, the first row is filled first,
1023 then the second, and so on until all items have been added. (If
1024 neccessary, additional rows will be added as items are added.) If you
1025 need to have greater control over the cells that items are placed in
1026 then use the `wx.GridBagSizer`.
1029 class wxGridSizer: public wxSizer
1032 %pythonAppend wxGridSizer "self._setOORInfo(self)"
1035 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1036 "Constructor for a wx.GridSizer. *rows* and *cols* determine the number
1037 of columns and rows in the sizer - if either of the parameters is
1038 zero, it will be calculated to from the total number of children in
1039 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1040 define extra space between all children.", "");
1043 void , SetCols( int cols ),
1044 "Sets the number of columns in the sizer.", "");
1047 void , SetRows( int rows ),
1048 "Sets the number of rows in the sizer.", "");
1051 void , SetVGap( int gap ),
1052 "Sets the vertical gap (in pixels) between the cells in the sizer.", "");
1055 void , SetHGap( int gap ),
1056 "Sets the horizontal gap (in pixels) between cells in the sizer", "");
1060 "Returns the number of columns in the sizer.", "");
1064 "Returns the number of rows in the sizer.", "");
1068 "Returns the vertical gap (in pixels) between the cells in the sizer.", "");
1072 "Returns the horizontal gap (in pixels) between cells in the sizer.", "");
1076 //---------------------------------------------------------------------------
1079 enum wxFlexSizerGrowMode
1081 // don't resize the cells in non-flexible direction at all
1082 wxFLEX_GROWMODE_NONE,
1084 // uniformly resize only the specified ones (default)
1085 wxFLEX_GROWMODE_SPECIFIED,
1087 // uniformly resize all cells
1095 DocStr(wxFlexGridSizer,
1096 "A flex grid sizer is a sizer which lays out its children in a
1097 two-dimensional table with all table cells in one row having the same
1098 height and all cells in one column having the same width, but all
1099 rows or all columns are not necessarily the same height or width as in
1102 wx.FlexGridSizer can also size items equally in one direction but
1103 unequally (\"flexibly\") in the other. If the sizer is only flexible
1104 in one direction (this can be changed using `SetFlexibleDirection`), it
1105 needs to be decided how the sizer should grow in the other (\"non
1106 flexible\") direction in order to fill the available space. The
1107 `SetNonFlexibleGrowMode` method serves this purpose.
1111 class wxFlexGridSizer: public wxGridSizer
1114 %pythonAppend wxFlexGridSizer "self._setOORInfo(self)"
1117 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1118 "Constructor for a wx.FlexGridSizer. *rows* and *cols* determine the
1119 number of columns and rows in the sizer - if either of the parameters
1120 is zero, it will be calculated to from the total number of children in
1121 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1122 define extra space between all children.", "");
1126 void , AddGrowableRow( size_t idx, int proportion = 0 ),
1127 "Specifies that row *idx* (starting from zero) should be grown if there
1128 is extra space available to the sizer.
1130 The *proportion* parameter has the same meaning as the stretch factor
1131 for the box sizers except that if all proportions are 0, then all
1132 columns are resized equally (instead of not being resized at all).", "");
1135 void , RemoveGrowableRow( size_t idx ),
1136 "Specifies that row *idx* is no longer growable.", "");
1139 void , AddGrowableCol( size_t idx, int proportion = 0 ),
1140 "Specifies that column *idx* (starting from zero) should be grown if
1141 there is extra space available to the sizer.
1143 The *proportion* parameter has the same meaning as the stretch factor
1144 for the box sizers except that if all proportions are 0, then all
1145 columns are resized equally (instead of not being resized at all).", "");
1148 void , RemoveGrowableCol( size_t idx ),
1149 "Specifies that column *idx* is no longer growable.", "");
1153 void , SetFlexibleDirection(int direction),
1154 "Specifies whether the sizer should flexibly resize its columns, rows,
1155 or both. Argument *direction* can be one of the following values. Any
1156 other value is ignored.
1158 ============== =======================================
1159 wx.VERTICAL Rows are flexibly sized.
1160 wx.HORIZONTAL Columns are flexibly sized.
1161 wx.BOTH Both rows and columns are flexibly sized
1162 (this is the default value).
1163 ============== =======================================
1165 Note that this method does not trigger relayout.
1169 int , GetFlexibleDirection(),
1170 "Returns a value that specifies whether the sizer
1171 flexibly resizes its columns, rows, or both (default).
1173 :see: `SetFlexibleDirection`", "");
1178 void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
1179 "Specifies how the sizer should grow in the non-flexible direction if
1180 there is one (so `SetFlexibleDirection` must have been called
1181 previously). Argument *mode* can be one of the following values:
1183 ========================== =================================================
1184 wx.FLEX_GROWMODE_NONE Sizer doesn't grow in the non flexible direction.
1185 wx.FLEX_GROWMODE_SPECIFIED Sizer honors growable columns/rows set with
1186 `AddGrowableCol` and `AddGrowableRow`. In this
1187 case equal sizing applies to minimum sizes of
1188 columns or rows (this is the default value).
1189 wx.FLEX_GROWMODE_ALL Sizer equally stretches all columns or rows in
1190 the non flexible direction, whether they are
1191 growable or not in the flexbile direction.
1192 ========================== =================================================
1194 Note that this method does not trigger relayout.
1199 wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
1200 "Returns the value that specifies how the sizer grows in the
1201 non-flexible direction if there is one.
1203 :see: `SetNonFlexibleGrowMode`", "");
1206 // Read-only access to the row heights and col widths arrays
1208 const wxArrayInt& , GetRowHeights() const,
1209 "GetRowHeights(self) -> list",
1210 "Returns a list of integers representing the heights of each of the
1211 rows in the sizer.", "");
1214 const wxArrayInt& , GetColWidths() const,
1215 "GetColWidths(self) -> list",
1216 "Returns a list of integers representing the widths of each of the
1217 columns in the sizer.", "");
1221 //---------------------------------------------------------------------------