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`. It is not usually
27 necessary to use this class because the sizer elements can also be
28 identified by their positions or window or sizer references but
29 sometimes it may be more convenient to use wx.SizerItem directly.
30 Also, custom classes derived from `wx.PySizer` will probably need to
31 use the collection of wx.SizerItems held by wx.Sizer when calculating
34 :see: `wx.Sizer`, `wx.GBSizerItem`", "");
36 class wxSizerItem : public wxObject {
40 "Constructs an empty wx.SizerItem. Either a window, sizer or spacer
41 size will need to be set before this item can be used in a Sizer.
43 You will probably never need to create a wx.SizerItem directly as they
44 are created automatically when the sizer's Add, Insert or Prepend
47 :see: `wx.SizerItemSpacer`, `wx.SizerItemWindow`, `wx.SizerItemSizer`", "");
55 wxSizerItem( wxWindow *window, int proportion, int flag,
56 int border, PyObject* userData=NULL ),
57 "Constructs a `wx.SizerItem` for tracking a window.", "");
59 %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, int flag,
60 int border, PyObject* userData=NULL ))
62 wxPyUserData* data = NULL;
64 wxPyBlock_t blocked = wxPyBeginBlockThreads();
65 data = new wxPyUserData(userData);
66 wxPyEndBlockThreads(blocked);
68 return new wxSizerItem(window, proportion, flag, border, data);
73 wxSizerItem( int width, int height, int proportion, int flag,
74 int border, PyObject* userData=NULL),
75 "Constructs a `wx.SizerItem` for tracking a spacer.", "");
77 %RenameCtor(SizerItemSpacer, wxSizerItem( int width, int height, int proportion, int flag,
78 int border, PyObject* userData=NULL))
80 wxPyUserData* data = NULL;
82 wxPyBlock_t blocked = wxPyBeginBlockThreads();
83 data = new wxPyUserData(userData);
84 wxPyEndBlockThreads(blocked);
86 return new wxSizerItem(width, height, proportion, flag, border, data);
90 wxSizerItem( wxSizer *sizer, int proportion, int flag,
91 int border, PyObject* userData=NULL ),
92 "Constructs a `wx.SizerItem` for tracking a subsizer", "");
94 %disownarg( wxSizer *sizer );
95 %RenameCtor(SizerItemSizer, wxSizerItem( wxSizer *sizer, int proportion, int flag,
96 int border, PyObject* userData=NULL ))
98 wxPyUserData* data = NULL;
100 wxPyBlock_t blocked = wxPyBeginBlockThreads();
101 data = new wxPyUserData(userData);
102 wxPyEndBlockThreads(blocked);
104 return new wxSizerItem(sizer, proportion, flag, border, data);
106 %cleardisown( wxSizer *sizer );
112 void , DeleteWindows(),
113 "Destroy the window or the windows in a subsizer, depending on the type
117 void , DetachSizer(),
118 "Enable deleting the SizerItem without destroying the contained sizer.", "");
123 "Get the current size of the item, as set in the last Layout.", "");
127 "Calculates the minimum desired size for the item, including any space
128 needed by borders.", "");
131 void , SetDimension( const wxPoint& pos, const wxSize& size ),
132 "Set the position and size of the space allocated for this item by the
133 sizer, and adjust the position and size of the item (window or
134 subsizer) to be within that space taking alignment and borders into
139 wxSize , GetMinSize(),
140 "Get the minimum size needed for the item.", "");
143 wxSize , GetMinSizeWithBorder() const,
144 "Get the minimum size needed for the item with space for the borders
145 added, if needed.", "");
148 void , SetInitSize( int x, int y ),
153 "Set the ratio item attribute.", "");
154 %Rename(SetRatioWH, void, SetRatio( int width, int height ));
155 %Rename(SetRatioSize, void, SetRatio( const wxSize& size ));
156 void SetRatio( float ratio );
160 "Set the ratio item attribute.", "");
164 "Returns the rectangle that the sizer item should occupy", "");
169 "Is this sizer item a window?", "");
173 "Is this sizer item a subsizer?", "");
177 "Is this sizer item a spacer?", "");
181 void , SetProportion( int proportion ),
182 "Set the proportion value for this item.", "");
185 int , GetProportion(),
186 "Get the proportion value for this item.", "");
188 %pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
189 %pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
193 void , SetFlag( int flag ),
194 "Set the flag value for this item.", "");
198 "Get the flag value for this item.", "");
202 void , SetBorder( int border ),
203 "Set the border value for this item.", "");
207 "Get the border value for this item.", "");
212 wxWindow *, GetWindow(),
213 "Get the window (if any) that is managed by this sizer item.", "");
216 void , SetWindow( wxWindow *window ),
217 "Set the window to be managed by this sizer item.", "");
221 wxSizer *, GetSizer(),
222 "Get the subsizer (if any) that is managed by this sizer item.", "");
224 %disownarg( wxSizer *sizer );
226 void , SetSizer( wxSizer *sizer ),
227 "Set the subsizer to be managed by this sizer item.", "");
228 %cleardisown( wxSizer *sizer );
232 wxSize , GetSpacer(),
233 "Get the size of the spacer managed by this sizer item.", "");
236 void , SetSpacer( const wxSize &size ),
237 "Set the size of the spacer to be managed by this sizer item.", "");
241 void , Show( bool show ),
242 "Set the show item attribute, which sizers use to determine if the item
243 is to be made part of the layout or not. If the item is tracking a
244 window then it is shown or hidden as needed.", "");
248 "Is the item to be shown in the layout?", "");
252 wxPoint , GetPosition(),
253 "Returns the current position of the item, as set in the last Layout.", "");
256 // wxObject* GetUserData();
258 // Assume that the user data is a wxPyUserData object and return the contents
261 "Returns the userData associated with this sizer item, or None if there
263 PyObject* GetUserData() {
264 wxPyUserData* data = (wxPyUserData*)self->GetUserData();
266 Py_INCREF(data->m_obj);
275 "Associate a Python object with this sizer item.", "");
276 void SetUserData(PyObject* userData) {
277 wxPyUserData* data = NULL;
279 wxPyBlock_t blocked = wxPyBeginBlockThreads();
280 data = new wxPyUserData(userData);
281 wxPyEndBlockThreads(blocked);
283 self->SetUserData(data);
287 %property(Border, GetBorder, SetBorder, doc="See `GetBorder` and `SetBorder`");
288 %property(Flag, GetFlag, SetFlag, doc="See `GetFlag` and `SetFlag`");
289 %property(MinSize, GetMinSize, doc="See `GetMinSize`");
290 %property(MinSizeWithBorder, GetMinSizeWithBorder, doc="See `GetMinSizeWithBorder`");
291 %property(Position, GetPosition, doc="See `GetPosition`");
292 %property(Proportion, GetProportion, SetProportion, doc="See `GetProportion` and `SetProportion`");
293 %property(Ratio, GetRatio, SetRatio, doc="See `GetRatio` and `SetRatio`");
294 %property(Rect, GetRect, doc="See `GetRect`");
295 %property(Size, GetSize, doc="See `GetSize`");
296 %property(Sizer, GetSizer, SetSizer, doc="See `GetSizer` and `SetSizer`");
297 %property(Spacer, GetSpacer, SetSpacer, doc="See `GetSpacer` and `SetSpacer`");
298 %property(UserData, GetUserData, SetUserData, doc="See `GetUserData` and `SetUserData`");
299 %property(Window, GetWindow, SetWindow, doc="See `GetWindow` and `SetWindow`");
303 //---------------------------------------------------------------------------
306 // Figure out the type of the sizer item
308 struct wxPySizerItemInfo {
310 : window(NULL), sizer(NULL), gotSize(false),
311 size(wxDefaultSize), gotPos(false), pos(-1)
322 static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
324 wxPySizerItemInfo info;
326 wxSize* sizePtr = &size;
328 // Find out what the type of the item is
330 if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
335 if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
339 // try wxSize or (w,h)
340 if ( checkSize && wxSize_helper(item, &sizePtr)) {
341 info.size = *sizePtr;
346 if (checkIdx && PyInt_Check(item)) {
347 info.pos = PyInt_AsLong(item);
353 if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
354 // no expected type, figure out what kind of error message to generate
355 if ( !checkSize && !checkIdx )
356 PyErr_SetString(PyExc_TypeError, "wx.Window or wx.Sizer expected for item");
357 else if ( checkSize && !checkIdx )
358 PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item");
359 else if ( !checkSize && checkIdx)
360 PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer or int (position) expected for item");
362 // can this one happen?
363 PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) or int (position) expected for item");
374 "wx.Sizer is the abstract base class used for laying out subwindows in
375 a window. You cannot use wx.Sizer directly; instead, you will have to
376 use one of the sizer classes derived from it such as `wx.BoxSizer`,
377 `wx.StaticBoxSizer`, `wx.GridSizer`, `wx.FlexGridSizer` and
380 The concept implemented by sizers in wxWidgets is closely related to
381 layout tools in other GUI toolkits, such as Java's AWT, the GTK
382 toolkit or the Qt toolkit. It is based upon the idea of the individual
383 subwindows reporting their minimal required size and their ability to
384 get stretched if the size of the parent window has changed. This will
385 most often mean that the programmer does not set the original size of
386 a dialog in the beginning, rather the dialog will assigned a sizer and
387 this sizer will be queried about the recommended size. The sizer in
388 turn will query its children, which can be normal windows or contorls,
389 empty space or other sizers, so that a hierarchy of sizers can be
390 constructed. Note that wxSizer does not derive from wxWindow and thus
391 do not interfere with tab ordering and requires very little resources
392 compared to a real window on screen.
394 What makes sizers so well fitted for use in wxWidgets is the fact that
395 every control reports its own minimal size and the algorithm can
396 handle differences in font sizes or different window (dialog item)
397 sizes on different platforms without problems. If for example the
398 standard font as well as the overall design of Mac widgets requires
399 more space than on Windows, then the initial size of a dialog using a
400 sizer will automatically be bigger on Mac than on Windows.", "
402 Sizers may also be used to control the layout of custom drawn items on
403 the window. The `Add`, `Insert`, and `Prepend` functions return a
404 pointer to the newly added `wx.SizerItem`. Just add empty space of the
405 desired size and attributes, and then use the `wx.SizerItem.GetRect`
406 method to determine where the drawing operations should take place.
408 :note: If you wish to create a custom sizer class in wxPython you
409 should derive the class from `wx.PySizer` in order to get
410 Python-aware capabilities for the various virtual methods.
414 :todo: More dscriptive text here along with some pictures...
418 class wxSizer : public wxObject {
420 // wxSizer(); **** abstract, can't instantiate
425 void _setOORInfo(PyObject* _self) {
426 if (!self->GetClientObject())
427 self->SetClientObject(new wxPyOORClientData(_self));
431 "Add(self, item, int proportion=0, int flag=0, int border=0,
432 PyObject userData=None) -> wx.SizerItem",
434 "Appends a child item to the sizer.", "
436 :param item: The item can be one of three kinds of objects:
438 - **window**: A `wx.Window` to be managed by the sizer. Its
439 minimal size (either set explicitly by the user or
440 calculated internally when constructed with wx.DefaultSize)
441 is interpreted as the minimal size to use when laying out
442 item in the sizer. This is particularly useful in
443 connection with `wx.Window.SetSizeHints`.
445 - **sizer**: The (child-)sizer to be added to the sizer. This
446 allows placing a child sizer in a sizer and thus to create
447 hierarchies of sizers (typically a vertical box as the top
448 sizer and several horizontal boxes on the level beneath).
450 - **size**: A `wx.Size` or a 2-element sequence of integers
451 that represents the width and height of a spacer to be added
452 to the sizer. Adding spacers to sizers gives more
453 flexibility in the design of dialogs; imagine for example a
454 horizontal box with two buttons at the bottom of a dialog:
455 you might want to insert a space between the two buttons and
456 make that space stretchable using the *proportion* value and
457 the result will be that the left button will be aligned with
458 the left side of the dialog and the right button with the
459 right side - the space in between will shrink and grow with
462 :param proportion: Although the meaning of this parameter is
463 undefined in wx.Sizer, it is used in `wx.BoxSizer` to indicate
464 if a child of a sizer can change its size in the main
465 orientation of the wx.BoxSizer - where 0 stands for not
466 changeable and a value of more than zero is interpreted
467 relative (a proportion of the total) to the value of other
468 children of the same wx.BoxSizer. For example, you might have
469 a horizontal wx.BoxSizer with three children, two of which are
470 supposed to change their size with the sizer. Then the two
471 stretchable windows should each be given *proportion* value of
472 1 to make them grow and shrink equally with the sizer's
473 horizontal dimension. But if one of them had a *proportion*
474 value of 2 then it would get a double share of the space
475 available after the fixed size items are positioned.
477 :param flag: This parameter can be used to set a number of flags
478 which can be combined using the binary OR operator ``|``. Two
479 main behaviours are defined using these flags. One is the
480 border around a window: the *border* parameter determines the
481 border width whereas the flags given here determine which
482 side(s) of the item that the border will be added. The other
483 flags determine how the sizer item behaves when the space
484 allotted to the sizer changes, and is somewhat dependent on
485 the specific kind of sizer used.
487 +----------------------------+------------------------------------------+
488 |- wx.TOP |These flags are used to specify |
489 |- wx.BOTTOM |which side(s) of the sizer item that |
490 |- wx.LEFT |the *border* width will apply to. |
494 +----------------------------+------------------------------------------+
495 |- wx.EXPAND |The item will be expanded to fill |
496 | |the space allotted to the item. |
497 +----------------------------+------------------------------------------+
498 |- wx.SHAPED |The item will be expanded as much as |
499 | |possible while also maintaining its |
501 +----------------------------+------------------------------------------+
502 |- wx.FIXED_MINSIZE |Normally wx.Sizers will use |
503 | |`wx.Window.GetMinSize` or |
504 | |`wx.Window.GetBestSize` to determine what |
505 | |the minimal size of window items should |
506 | |be, and will use that size to calculate |
507 | |the layout. This allows layouts to adjust |
508 | |when an item changes and it's best size |
509 | |becomes different. If you would rather |
510 | |have a window item stay the size it |
511 | |started with then use wx.FIXED_MINSIZE. |
512 +----------------------------+------------------------------------------+
513 |- wx.ALIGN_CENTER |The wx.ALIGN flags allow you to specify |
514 |- wx.ALIGN_LEFT |the alignment of the item within the space|
515 |- wx.ALIGN_RIGHT |allotted to it by the sizer, ajusted for |
516 |- wx.ALIGN_TOP |the border if any. |
517 |- wx.ALIGN_BOTTOM | |
518 |- wx.ALIGN_CENTER_VERTICAL | |
519 |- wx.ALIGN_CENTER_HORIZONTAL| |
520 +----------------------------+------------------------------------------+
523 :param border: Determines the border width, if the *flag*
524 parameter is set to include any border flag.
526 :param userData: Allows an extra object to be attached to the
527 sizer item, for use in derived classes when sizing information
528 is more complex than the *proportion* and *flag* will allow for.
531 wxSizerItem* Add(PyObject* item, int proportion=0, int flag=0, int border=0,
532 PyObject* userData=NULL) {
534 wxPyUserData* data = NULL;
535 wxPyBlock_t blocked = wxPyBeginBlockThreads();
536 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
537 if ( userData && (info.window || info.sizer || info.gotSize) )
538 data = new wxPyUserData(userData);
540 PyObject_SetAttrString(item,"thisown",Py_False);
541 wxPyEndBlockThreads(blocked);
543 // Now call the real Add method if a valid item type was found
545 return self->Add(info.window, proportion, flag, border, data);
546 else if ( info.sizer )
547 return self->Add(info.sizer, proportion, flag, border, data);
548 else if (info.gotSize)
549 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
550 proportion, flag, border, data);
555 // virtual wxSizerItem* AddSpacer(int size);
556 // virtual wxSizerItem* AddStretchSpacer(int prop = 1);
559 "Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
560 PyObject userData=None) -> wx.SizerItem",
562 "Inserts a new item into the list of items managed by this sizer before
563 the item at index *before*. See `Add` for a description of the parameters.", "");
564 wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0,
565 int border=0, PyObject* userData=NULL) {
567 wxPyUserData* data = NULL;
568 wxPyBlock_t blocked = wxPyBeginBlockThreads();
569 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
570 if ( userData && (info.window || info.sizer || info.gotSize) )
571 data = new wxPyUserData(userData);
573 PyObject_SetAttrString(item,"thisown",Py_False);
574 wxPyEndBlockThreads(blocked);
576 // Now call the real Insert method if a valid item type was found
578 return self->Insert(before, info.window, proportion, flag, border, data);
579 else if ( info.sizer )
580 return self->Insert(before, info.sizer, proportion, flag, border, data);
581 else if (info.gotSize)
582 return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
583 proportion, flag, border, data);
589 // virtual wxSizerItem* InsertSpacer(size_t index, int size);
590 // virtual wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
593 "Prepend(self, item, int proportion=0, int flag=0, int border=0,
594 PyObject userData=None) -> wx.SizerItem",
596 "Adds a new item to the begining of the list of sizer items managed by
597 this sizer. See `Add` for a description of the parameters.", "");
598 wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
599 PyObject* userData=NULL) {
601 wxPyUserData* data = NULL;
602 wxPyBlock_t blocked = wxPyBeginBlockThreads();
603 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
604 if ( userData && (info.window || info.sizer || info.gotSize) )
605 data = new wxPyUserData(userData);
607 PyObject_SetAttrString(item,"thisown",Py_False);
608 wxPyEndBlockThreads(blocked);
610 // Now call the real Prepend method if a valid item type was found
612 return self->Prepend(info.window, proportion, flag, border, data);
613 else if ( info.sizer )
614 return self->Prepend(info.sizer, proportion, flag, border, data);
615 else if (info.gotSize)
616 return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
617 proportion, flag, border, data);
622 // virtual wxSizerItem* PrependSpacer(int size);
623 // virtual wxSizerItem* PrependStretchSpacer(int prop = 1);
627 "Remove(self, item) -> bool",
628 "Removes an item from the sizer and destroys it. This method does not
629 cause any layout or resizing to take place, call `Layout` to update
630 the layout on screen after removing a child from the sizer. The
631 *item* parameter can be either a window, a sizer, or the zero-based
632 index of an item to remove. Returns True if the child item was found
635 :note: For historical reasons calling this method with a `wx.Window`
636 parameter is depreacted, as it will not be able to destroy the
637 window since it is owned by its parent. You should use `Detach`
640 bool Remove(PyObject* item) {
641 wxPyBlock_t blocked = wxPyBeginBlockThreads();
642 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
643 wxPyEndBlockThreads(blocked);
645 return self->Remove(info.window);
646 else if ( info.sizer )
647 return self->Remove(info.sizer);
648 else if ( info.gotPos )
649 return self->Remove(info.pos);
656 "Detach(self, item) -> bool",
657 "Detaches an item from the sizer without destroying it. This method
658 does not cause any layout or resizing to take place, call `Layout` to
659 do so. The *item* parameter can be either a window, a sizer, or the
660 zero-based index of the item to be detached. Returns True if the child item
661 was found and detached.", "");
662 bool Detach(PyObject* item) {
663 wxPyBlock_t blocked = wxPyBeginBlockThreads();
664 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
665 wxPyEndBlockThreads(blocked);
667 return self->Detach(info.window);
668 else if ( info.sizer )
669 return self->Detach(info.sizer);
670 else if ( info.gotPos )
671 return self->Detach(info.pos);
678 "GetItem(self, item) -> wx.SizerItem",
679 "Returns the `wx.SizerItem` which holds the *item* given. The *item*
680 parameter can be either a window, a sizer, or the zero-based index of
681 the item to be found.", "");
682 wxSizerItem* GetItem(PyObject* item) {
683 wxPyBlock_t blocked = wxPyBeginBlockThreads();
684 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
685 wxPyEndBlockThreads(blocked);
687 return self->GetItem(info.window);
688 else if ( info.sizer )
689 return self->GetItem(info.sizer);
690 else if ( info.gotPos )
691 return self->GetItem(info.pos);
697 void _SetItemMinSize(PyObject* item, const wxSize& size) {
698 wxPyBlock_t blocked = wxPyBeginBlockThreads();
699 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
700 wxPyEndBlockThreads(blocked);
702 self->SetItemMinSize(info.window, size);
703 else if ( info.sizer )
704 self->SetItemMinSize(info.sizer, size);
705 else if ( info.gotPos )
706 self->SetItemMinSize(info.pos, size);
712 bool, Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false ));
713 %Rename(_ReplaceSizer,
714 bool, Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false ));
715 %Rename(_ReplaceItem,
716 bool, Replace( size_t index, wxSizerItem *newitem ));
718 def Replace(self, olditem, item, recursive=False):
720 Detaches the given ``olditem`` from the sizer and replaces it with
721 ``item`` which can be a window, sizer, or `wx.SizerItem`. The
722 detached child is destroyed only if it is not a window, (because
723 windows are owned by their parent, not the sizer.) The
724 ``recursive`` parameter can be used to search for the given
725 element recursivly in subsizers.
727 This method does not cause any layout or resizing to take place,
728 call `Layout` to do so.
730 Returns ``True`` if the child item was found and removed.
732 if isinstance(olditem, wx.Window):
733 return self._ReplaceWin(olditem, item, recursive)
734 elif isinstnace(olditem, wx.Sizer):
735 return self._ReplaceSizer(olditem, item, recursive)
736 elif isinstnace(olditem, int):
737 return self._ReplaceItem(olditem, item)
739 raise TypeError("Expected Window, Sizer, or integer for first parameter.")
744 void , SetContainingWindow(wxWindow *window),
745 "Set (or unset) the window this sizer is used in.", "");
748 wxWindow *, GetContainingWindow() const,
749 "Get the window this sizer is used in.", "");
753 def SetItemMinSize(self, item, *args):
755 SetItemMinSize(self, item, Size size)
757 Sets the minimum size that will be allocated for an item in the sizer.
758 The *item* parameter can be either a window, a sizer, or the
759 zero-based index of the item. If a window or sizer is given then it
760 will be searched for recursivly in subsizers if neccessary.
763 %# for backward compatibility accept separate width,height args too
764 return self._SetItemMinSize(item, args)
766 return self._SetItemMinSize(item, args[0])
770 %disownarg( wxSizerItem *item );
773 wxSizerItem* , Add( wxSizerItem *item ),
774 "AddItem(self, SizerItem item)",
775 "Adds a `wx.SizerItem` to the sizer.", "",
779 wxSizerItem* , Insert( size_t index, wxSizerItem *item ),
780 "InsertItem(self, int index, SizerItem item)",
781 "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
785 wxSizerItem* , Prepend( wxSizerItem *item ),
786 "PrependItem(self, SizerItem item)",
787 "Prepends a `wx.SizerItem` to the sizer.", "",
790 %cleardisown( wxSizerItem *item );
794 def AddMany(self, items):
796 AddMany is a convenience method for adding several items
797 to a sizer at one time. Simply pass it a list of tuples,
798 where each tuple consists of the parameters that you
799 would normally pass to the `Add` method.
802 if type(item) != type(()) or (len(item) == 2 and type(item[0]) == type(1)):
806 def AddSpacer(self, *args, **kw):
807 """AddSpacer(int size) --> SizerItem
809 Add a spacer that is (size,size) pixels.
811 if args and type(args[0]) == int:
812 return self.Add( (args[0],args[0] ), 0)
813 else: %# otherwise stay compatible with old AddSpacer
814 return self.Add(*args, **kw)
815 def PrependSpacer(self, *args, **kw):
816 """PrependSpacer(int size) --> SizerItem
818 Prepend a spacer that is (size, size) pixels."""
819 if args and type(args[0]) == int:
820 return self.Prepend( (args[0],args[0] ), 0)
821 else: %# otherwise stay compatible with old PrependSpacer
822 return self.Prepend(*args, **kw)
823 def InsertSpacer(self, index, *args, **kw):
824 """InsertSpacer(int index, int size) --> SizerItem
826 Insert a spacer at position index that is (size, size) pixels."""
827 if args and type(args[0]) == int:
828 return self.Insert( index, (args[0],args[0] ), 0)
829 else: %# otherwise stay compatible with old InsertSpacer
830 return self.Insert(index, *args, **kw)
833 def AddStretchSpacer(self, prop=1):
834 """AddStretchSpacer(int prop=1) --> SizerItem
836 Add a stretchable spacer."""
837 return self.Add((0,0), prop)
838 def PrependStretchSpacer(self, prop=1):
839 """PrependStretchSpacer(int prop=1) --> SizerItem
841 Prepend a stretchable spacer."""
842 return self.Prepend((0,0), prop)
843 def InsertStretchSpacer(self, index, prop=1):
844 """InsertStretchSpacer(int index, int prop=1) --> SizerItem
846 Insert a stretchable spacer."""
847 return self.Insert(index, (0,0), prop)
850 %# for backwards compatibility only, please do not use in new code
851 def AddWindow(self, *args, **kw):
852 """Compatibility alias for `Add`."""
853 return self.Add(*args, **kw)
854 def AddSizer(self, *args, **kw):
855 """Compatibility alias for `Add`."""
856 return self.Add(*args, **kw)
858 def PrependWindow(self, *args, **kw):
859 """Compatibility alias for `Prepend`."""
860 return self.Prepend(*args, **kw)
861 def PrependSizer(self, *args, **kw):
862 """Compatibility alias for `Prepend`."""
863 return self.Prepend(*args, **kw)
865 def InsertWindow(self, *args, **kw):
866 """Compatibility alias for `Insert`."""
867 return self.Insert(*args, **kw)
868 def InsertSizer(self, *args, **kw):
869 """Compatibility alias for `Insert`."""
870 return self.Insert(*args, **kw)
872 def RemoveWindow(self, *args, **kw):
873 """Compatibility alias for `Remove`."""
874 return self.Remove(*args, **kw)
875 def RemoveSizer(self, *args, **kw):
876 """Compatibility alias for `Remove`."""
877 return self.Remove(*args, **kw)
878 def RemovePos(self, *args, **kw):
879 """Compatibility alias for `Remove`."""
880 return self.Remove(*args, **kw)
886 void , SetDimension( int x, int y, int width, int height ),
887 "Call this to force the sizer to take the given dimension and thus
888 force the items owned by the sizer to resize themselves according to
889 the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
893 void , SetMinSize( const wxSize &size ),
894 "Call this to give the sizer a minimal size. Normally, the sizer will
895 calculate its minimal size based purely on how much space its children
896 need. After calling this method `GetMinSize` will return either the
897 minimal size as requested by its children or the minimal size set
898 here, depending on which is bigger.", "");
903 "Returns the current size of the space managed by the sizer.", "");
906 wxPoint , GetPosition(),
907 "Returns the current position of the sizer's managed space.", "");
910 wxSize , GetMinSize(),
911 "Returns the minimal size of the sizer. This is either the combined
912 minimal size of all the children and their borders or the minimal size
913 set by SetMinSize, depending on which is bigger.", "");
917 def GetSizeTuple(self):
918 return self.GetSize().Get()
919 def GetPositionTuple(self):
920 return self.GetPosition().Get()
921 def GetMinSizeTuple(self):
922 return self.GetMinSize().Get()
926 virtual void , RecalcSizes(),
927 "Using the sizes calculated by `CalcMin` reposition and resize all the
928 items managed by this sizer. You should not need to call this directly as
929 it is called by `Layout`.", "");
932 virtual wxSize , CalcMin(),
933 "This method is where the sizer will do the actual calculation of its
934 children's minimal sizes. You should not need to call this directly as
935 it is called by `Layout`.", "");
940 "This method will force the recalculation and layout of the items
941 controlled by the sizer using the current space allocated to the
942 sizer. Normally this is called automatically from the owning window's
943 EVT_SIZE handler, but it is also useful to call it from user code when
944 one of the items in a sizer change size, or items are added or
949 wxSize , Fit( wxWindow *window ),
950 "Tell the sizer to resize the *window* to match the sizer's minimal
951 size. This is commonly done in the constructor of the window itself in
952 order to set its initial size to match the needs of the children as
953 determined by the sizer. Returns the new size.
955 For a top level window this is the total window size, not the client size.", "");
958 void , FitInside( wxWindow *window ),
959 "Tell the sizer to resize the *virtual size* of the *window* to match the
960 sizer's minimal size. This will not alter the on screen size of the
961 window, but may cause the addition/removal/alteration of scrollbars
962 required to view the virtual area in windows which manage it.
964 :see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
969 void , SetSizeHints( wxWindow *window ),
970 "Tell the sizer to set (and `Fit`) the minimal size of the *window* to
971 match the sizer's minimal size. This is commonly done in the
972 constructor of the window itself if the window is resizable (as are
973 many dialogs under Unix and frames on probably all platforms) in order
974 to prevent the window from being sized smaller than the minimal size
975 required by the sizer.", "");
978 void , SetVirtualSizeHints( wxWindow *window ),
979 "Tell the sizer to set the minimal size of the window virtual area to
980 match the sizer's minimal size. For windows with managed scrollbars
981 this will set them appropriately.
983 :see: `wx.ScrolledWindow.SetScrollbars`
988 void , Clear( bool deleteWindows=false ),
989 "Clear all items from the sizer, optionally destroying the window items
993 void , DeleteWindows(),
994 "Destroy all windows managed by the sizer.", "");
998 // wxList& GetChildren();
1000 DocAStr(GetChildren,
1001 "GetChildren(self) -> list",
1002 "Returns a list of all the `wx.SizerItem` objects managed by the sizer.", "");
1003 PyObject* GetChildren() {
1004 wxSizerItemList& list = self->GetChildren();
1005 return wxPy_ConvertList(&list);
1010 // Manage whether individual windows or subsizers are considered
1011 // in the layout calculations or not.
1015 "Show(self, item, bool show=True, bool recursive=false) -> bool",
1016 "Shows or hides an item managed by the sizer. To make a sizer item
1017 disappear or reappear, use Show followed by `Layout`. The *item*
1018 parameter can be either a window, a sizer, or the zero-based index of
1019 the item. Use the recursive parameter to show or hide an item in a
1020 subsizer. Returns True if the item was found.", "");
1021 bool Show(PyObject* item, bool show = true, bool recursive=false) {
1022 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1023 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
1024 wxPyEndBlockThreads(blocked);
1026 return self->Show(info.window, show, recursive);
1027 else if ( info.sizer )
1028 return self->Show(info.sizer, show, recursive);
1029 else if ( info.gotPos )
1030 return self->Show(info.pos, show);
1036 "IsShown(self, item)",
1037 "Determines if the item is currently shown. To make a sizer
1038 item disappear or reappear, use Show followed by `Layout`. The *item*
1039 parameter can be either a window, a sizer, or the zero-based index of
1041 bool IsShown(PyObject* item) {
1042 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1043 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false);
1044 wxPyEndBlockThreads(blocked);
1046 return self->IsShown(info.window);
1047 else if ( info.sizer )
1048 return self->IsShown(info.sizer);
1049 else if ( info.gotPos )
1050 return self->IsShown(info.pos);
1057 def Hide(self, item, recursive=False):
1059 A convenience method for `Show` (item, False, recursive).
1061 return self.Show(item, False, recursive)
1066 void , ShowItems(bool show),
1067 "Recursively call `wx.SizerItem.Show` on all sizer items.", "");
1069 %property(Children, GetChildren, doc="See `GetChildren`");
1070 %property(ContainingWindow, GetContainingWindow, SetContainingWindow, doc="See `GetContainingWindow` and `SetContainingWindow`");
1071 %property(MinSize, GetMinSize, SetMinSize, doc="See `GetMinSize` and `SetMinSize`");
1072 %property(Position, GetPosition, doc="See `GetPosition`");
1073 %property(Size, GetSize, doc="See `GetSize`");
1077 //---------------------------------------------------------------------------
1078 // Use this one for deriving Python classes from
1081 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
1082 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
1083 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
1088 "wx.PySizer is a special version of `wx.Sizer` that has been
1089 instrumented to allow the C++ virtual methods to be overloaded in
1090 Python derived classes. You would derive from this class if you are
1091 wanting to implement a custom sizer in Python code. Simply implement
1092 `CalcMin` and `RecalcSizes` in the derived class and you're all set.
1095 class MySizer(wx.PySizer):
1097 wx.PySizer.__init__(self)
1100 for item in self.GetChildren():
1101 # calculate the total minimum width and height needed
1102 # by all items in the sizer according to this sizer's
1105 return wx.Size(width, height)
1107 def RecalcSizes(self):
1108 # find the space allotted to this sizer
1109 pos = self.GetPosition()
1110 size = self.GetSize()
1111 for item in self.GetChildren():
1112 # Recalculate (if necessary) the position and size of
1113 # each item and then call item.SetDimension to do the
1114 # actual positioning and sizing of the items within the
1115 # space alloted to this sizer.
1117 item.SetDimension(itemPos, itemSize)
1120 When `Layout` is called it first calls `CalcMin` followed by
1121 `RecalcSizes` so you can optimize a bit by saving the results of
1122 `CalcMin` and reusing them in `RecalcSizes`.
1124 :see: `wx.SizerItem`, `wx.Sizer.GetChildren`
1127 class wxPySizer : public wxSizer {
1129 %pythonAppend wxPySizer "self._setCallbackInfo(self, PySizer);self._setOORInfo(self)"
1133 "Creates a wx.PySizer. Must be called from the __init__ in the derived
1136 void _setCallbackInfo(PyObject* self, PyObject* _class);
1140 //---------------------------------------------------------------------------
1145 "The basic idea behind a box sizer is that windows will most often be
1146 laid out in rather simple basic geometry, typically in a row or a
1147 column or nested hierarchies of either. A wx.BoxSizer will lay out
1148 its items in a simple row or column, depending on the orientation
1149 parameter passed to the constructor.", "
1151 It is the unique feature of a box sizer, that it can grow in both
1152 directions (height and width) but can distribute its growth in the
1153 main direction (horizontal for a row) *unevenly* among its children.
1154 This is determined by the proportion parameter give to items when they
1155 are added to the sizer. It is interpreted as a weight factor, i.e. it
1156 can be zero, indicating that the window may not be resized at all, or
1157 above zero. If several windows have a value above zero, the value is
1158 interpreted relative to the sum of all weight factors of the sizer, so
1159 when adding two windows with a value of 1, they will both get resized
1160 equally and each will receive half of the available space after the
1161 fixed size items have been sized. If the items have unequal
1162 proportion settings then they will receive a coresondingly unequal
1163 allotment of the free space.
1165 :see: `wx.StaticBoxSizer`
1168 class wxBoxSizer : public wxSizer {
1170 %pythonAppend wxBoxSizer "self._setOORInfo(self)"
1173 wxBoxSizer(int orient = wxHORIZONTAL),
1174 "Constructor for a wx.BoxSizer. *orient* may be one of ``wx.VERTICAL``
1175 or ``wx.HORIZONTAL`` for creating either a column sizer or a row
1180 int , GetOrientation(),
1181 "Returns the current orientation of the sizer.", "");
1184 void , SetOrientation(int orient),
1185 "Resets the orientation of the sizer.", "");
1187 %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
1190 //---------------------------------------------------------------------------
1194 DocStr(wxStaticBoxSizer,
1195 "wx.StaticBoxSizer derives from and functions identically to the
1196 `wx.BoxSizer` and adds a `wx.StaticBox` around the items that the sizer
1197 manages. Note that this static box must be created separately and
1198 passed to the sizer constructor.", "");
1200 class wxStaticBoxSizer : public wxBoxSizer {
1202 %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)"
1205 wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL),
1206 "Constructor. It takes an associated static box and the orientation
1207 *orient* as parameters - orient can be either of ``wx.VERTICAL`` or
1208 ``wx.HORIZONTAL``.", "");
1210 // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
1213 wxStaticBox *, GetStaticBox(),
1214 "Returns the static box associated with this sizer.", "");
1216 %property(StaticBox, GetStaticBox, doc="See `GetStaticBox`");
1219 //---------------------------------------------------------------------------
1224 "A grid sizer is a sizer which lays out its children in a
1225 two-dimensional table with all cells having the same size. In other
1226 words, the width of each cell within the grid is the width of the
1227 widest item added to the sizer and the height of each grid cell is the
1228 height of the tallest item. An optional vertical and/or horizontal
1229 gap between items can also be specified (in pixels.)
1231 Items are placed in the cells of the grid in the order they are added,
1232 in row-major order. In other words, the first row is filled first,
1233 then the second, and so on until all items have been added. (If
1234 neccessary, additional rows will be added as items are added.) If you
1235 need to have greater control over the cells that items are placed in
1236 then use the `wx.GridBagSizer`.
1239 class wxGridSizer: public wxSizer
1242 %pythonAppend wxGridSizer "self._setOORInfo(self)"
1245 wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1246 "Constructor for a wx.GridSizer. *rows* and *cols* determine the number
1247 of columns and rows in the sizer - if either of the parameters is
1248 zero, it will be calculated to from the total number of children in
1249 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1250 define extra space between all children.", "");
1253 void , SetCols( int cols ),
1254 "Sets the number of columns in the sizer.", "");
1257 void , SetRows( int rows ),
1258 "Sets the number of rows in the sizer.", "");
1261 void , SetVGap( int gap ),
1262 "Sets the vertical gap (in pixels) between the cells in the sizer.", "");
1265 void , SetHGap( int gap ),
1266 "Sets the horizontal gap (in pixels) between cells in the sizer", "");
1270 "Returns the number of columns in the sizer.", "");
1274 "Returns the number of rows in the sizer.", "");
1278 "Returns the vertical gap (in pixels) between the cells in the sizer.", "");
1282 "Returns the horizontal gap (in pixels) between cells in the sizer.", "");
1285 def CalcRowsCols(self):
1287 CalcRowsCols() -> (rows, cols)
1289 Calculates how many rows and columns will be in the sizer based
1290 on the current number of items and also the rows, cols specified
1293 nitems = len(self.GetChildren())
1294 rows = self.GetRows()
1295 cols = self.GetCols()
1296 assert rows != 0 or cols != 0, "Grid sizer must have either rows or columns fixed"
1298 rows = (nitems + cols - 1) / cols
1300 cols = (nitems + rows - 1) / rows
1304 %property(Cols, GetCols, SetCols, doc="See `GetCols` and `SetCols`");
1305 %property(HGap, GetHGap, SetHGap, doc="See `GetHGap` and `SetHGap`");
1306 %property(Rows, GetRows, SetRows, doc="See `GetRows` and `SetRows`");
1307 %property(VGap, GetVGap, SetVGap, doc="See `GetVGap` and `SetVGap`");
1310 //---------------------------------------------------------------------------
1313 enum wxFlexSizerGrowMode
1315 // don't resize the cells in non-flexible direction at all
1316 wxFLEX_GROWMODE_NONE,
1318 // uniformly resize only the specified ones (default)
1319 wxFLEX_GROWMODE_SPECIFIED,
1321 // uniformly resize all cells
1329 DocStr(wxFlexGridSizer,
1330 "A flex grid sizer is a sizer which lays out its children in a
1331 two-dimensional table with all table cells in one row having the same
1332 height and all cells in one column having the same width, but all
1333 rows or all columns are not necessarily the same height or width as in
1336 wx.FlexGridSizer can also size items equally in one direction but
1337 unequally (\"flexibly\") in the other. If the sizer is only flexible
1338 in one direction (this can be changed using `SetFlexibleDirection`), it
1339 needs to be decided how the sizer should grow in the other (\"non
1340 flexible\") direction in order to fill the available space. The
1341 `SetNonFlexibleGrowMode` method serves this purpose.
1345 class wxFlexGridSizer: public wxGridSizer
1348 %pythonAppend wxFlexGridSizer "self._setOORInfo(self)"
1351 wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ),
1352 "Constructor for a wx.FlexGridSizer. *rows* and *cols* determine the
1353 number of columns and rows in the sizer - if either of the parameters
1354 is zero, it will be calculated to from the total number of children in
1355 the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
1356 define extra space between all children.", "");
1360 void , AddGrowableRow( size_t idx, int proportion = 0 ),
1361 "Specifies that row *idx* (starting from zero) should be grown if there
1362 is extra space available to the sizer.
1364 The *proportion* parameter has the same meaning as the stretch factor
1365 for the box sizers except that if all proportions are 0, then all
1366 columns are resized equally (instead of not being resized at all).", "");
1369 void , RemoveGrowableRow( size_t idx ),
1370 "Specifies that row *idx* is no longer growable.", "");
1373 void , AddGrowableCol( size_t idx, int proportion = 0 ),
1374 "Specifies that column *idx* (starting from zero) should be grown if
1375 there is extra space available to the sizer.
1377 The *proportion* parameter has the same meaning as the stretch factor
1378 for the box sizers except that if all proportions are 0, then all
1379 columns are resized equally (instead of not being resized at all).", "");
1382 void , RemoveGrowableCol( size_t idx ),
1383 "Specifies that column *idx* is no longer growable.", "");
1387 void , SetFlexibleDirection(int direction),
1388 "Specifies whether the sizer should flexibly resize its columns, rows,
1389 or both. Argument *direction* can be one of the following values. Any
1390 other value is ignored.
1392 ============== =======================================
1393 wx.VERTICAL Rows are flexibly sized.
1394 wx.HORIZONTAL Columns are flexibly sized.
1395 wx.BOTH Both rows and columns are flexibly sized
1396 (this is the default value).
1397 ============== =======================================
1399 Note that this method does not trigger relayout.
1403 int , GetFlexibleDirection(),
1404 "Returns a value that specifies whether the sizer
1405 flexibly resizes its columns, rows, or both (default).
1407 :see: `SetFlexibleDirection`", "");
1412 void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
1413 "Specifies how the sizer should grow in the non-flexible direction if
1414 there is one (so `SetFlexibleDirection` must have been called
1415 previously). Argument *mode* can be one of the following values:
1417 ========================== =================================================
1418 wx.FLEX_GROWMODE_NONE Sizer doesn't grow in the non flexible direction.
1419 wx.FLEX_GROWMODE_SPECIFIED Sizer honors growable columns/rows set with
1420 `AddGrowableCol` and `AddGrowableRow`. In this
1421 case equal sizing applies to minimum sizes of
1422 columns or rows (this is the default value).
1423 wx.FLEX_GROWMODE_ALL Sizer equally stretches all columns or rows in
1424 the non flexible direction, whether they are
1425 growable or not in the flexbile direction.
1426 ========================== =================================================
1428 Note that this method does not trigger relayout.", "");
1431 wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
1432 "Returns the value that specifies how the sizer grows in the
1433 non-flexible direction if there is one.
1435 :see: `SetNonFlexibleGrowMode`", "");
1438 // Read-only access to the row heights and col widths arrays
1440 const wxArrayInt& , GetRowHeights() const,
1441 "GetRowHeights(self) -> list",
1442 "Returns a list of integers representing the heights of each of the
1443 rows in the sizer.", "");
1446 const wxArrayInt& , GetColWidths() const,
1447 "GetColWidths(self) -> list",
1448 "Returns a list of integers representing the widths of each of the
1449 columns in the sizer.", "");
1452 %property(ColWidths, GetColWidths, doc="See `GetColWidths`");
1453 %property(FlexibleDirection, GetFlexibleDirection, SetFlexibleDirection, doc="See `GetFlexibleDirection` and `SetFlexibleDirection`");
1454 %property(NonFlexibleGrowMode, GetNonFlexibleGrowMode, SetNonFlexibleGrowMode, doc="See `GetNonFlexibleGrowMode` and `SetNonFlexibleGrowMode`");
1455 %property(RowHeights, GetRowHeights, doc="See `GetRowHeights`");
1459 //---------------------------------------------------------------------------
1461 DocStr(wxStdDialogButtonSizer,
1462 "A special sizer that knows how to order and position standard buttons
1463 in order to conform to the current platform's standards. You simply
1464 need to add each `wx.Button` to the sizer, and be sure to create the
1465 buttons using the standard ID's. Then call `Realize` and the sizer
1466 will take care of the rest.
1469 class wxStdDialogButtonSizer: public wxBoxSizer
1473 wxStdDialogButtonSizer(),
1477 void , AddButton(wxButton *button),
1478 "Use this to add the buttons to this sizer. Do not use the `Add`
1479 method in the base class.", "");
1483 "This funciton needs to be called after all the buttons have been added
1484 to the sizer. It will reorder them and position them in a platform
1485 specifc manner.", "");
1487 void SetAffirmativeButton( wxButton *button );
1488 void SetNegativeButton( wxButton *button );
1489 void SetCancelButton( wxButton *button );
1491 wxButton* GetAffirmativeButton() const;
1492 wxButton* GetApplyButton() const;
1493 wxButton* GetNegativeButton() const;
1494 wxButton* GetCancelButton() const;
1495 wxButton* GetHelpButton() const;
1497 %property(AffirmativeButton, GetAffirmativeButton, SetAffirmativeButton, doc="See `GetAffirmativeButton` and `SetAffirmativeButton`");
1498 %property(ApplyButton, GetApplyButton, doc="See `GetApplyButton`");
1499 %property(CancelButton, GetCancelButton, SetCancelButton, doc="See `GetCancelButton` and `SetCancelButton`");
1500 %property(HelpButton, GetHelpButton, doc="See `GetHelpButton`");
1501 %property(NegativeButton, GetNegativeButton, SetNegativeButton, doc="See `GetNegativeButton` and `SetNegativeButton`");
1505 //---------------------------------------------------------------------------