X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f81114dcd7b12f1fb965b8a8f57bd872028de20b..1b7751aaa9a86d76a850b9267bc0c201e3cea30f:/interface/wx/sizer.h diff --git a/interface/wx/sizer.h b/interface/wx/sizer.h index f2e1d57a5e..8cc1117c74 100644 --- a/interface/wx/sizer.h +++ b/interface/wx/sizer.h @@ -3,7 +3,7 @@ // Purpose: interface of wxStdDialogButtonSizer // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -49,12 +49,6 @@ window, the library wouldn't be able to delete such an orphan sizer and in this, and only this, case it should be deleted explicitly. - @beginWxPythonOnly - If you wish to create a sizer class in wxPython you should - derive the class from @c wxPySizer in order to get Python-aware - capabilities for the various virtual methods. - @endWxPythonOnly - @section wxsizer_flags wxSizer flags The "flag" argument accepted by wxSizeItem constructors and other @@ -88,7 +82,7 @@ @c wxFIXED_MINSIZE.} @itemdef{wxRESERVE_SPACE_EVEN_IF_HIDDEN, Normally wxSizers don't allocate space for hidden windows or other - items. This flag overrides this behavior so that sufficient space + items. This flag overrides this behaviour so that sufficient space is allocated for the window even if it isn't visible. This makes it possible to dynamically show and hide controls without resizing parent dialog, for example. (Available since 2.8.8.)} @@ -168,7 +162,7 @@ public: to make them grow and shrink equally with the sizer's horizontal dimension. @param flag - OR-combination of flags affecting sizer's behavior. See + OR-combination of flags affecting sizer's behaviour. See @ref wxsizer_flags "wxSizer flags list" for details. @param border Determines the border width, if the flag parameter is set to @@ -226,7 +220,7 @@ public: to make them grow and shrink equally with the sizer's horizontal dimension. @param flag - OR-combination of flags affecting sizer's behavior. See + OR-combination of flags affecting sizer's behaviour. See @ref wxsizer_flags "wxSizer flags list" for details. @param border Determines the border width, if the flag parameter is set to @@ -274,7 +268,7 @@ public: to make them grow and shrink equally with the sizer's horizontal dimension. @param flag - OR-combination of flags affecting sizer's behavior. See + OR-combination of flags affecting sizer's behaviour. See @ref wxsizer_flags "wxSizer flags list" for details. @param border Determines the border width, if the flag parameter is set to @@ -289,15 +283,32 @@ public: int flag = 0, int border = 0, wxObject* userData = NULL); + + /** + Appends a spacer child to the sizer. + + @param width + Width of the spacer. + @param height + Height of the spacer. + @param flags + A wxSizerFlags object that enables you to specify most of the other + parameters more conveniently. + */ + wxSizerItem* Add( int width, int height, const wxSizerFlags& flags); + wxSizerItem* Add(wxSizerItem* item); + /** - Adds non-stretchable space to the sizer. + This base function adds non-stretchable space to both the horizontal + and vertical orientation of the sizer. More readable way of calling: @code wxSizer::Add(size, size, 0). @endcode + @see wxBoxSizer::AddSpacer() */ - wxSizerItem* AddSpacer(int size); + virtual wxSizerItem *AddSpacer(int size); /** Adds stretchable space to the sizer. @@ -404,6 +415,14 @@ public: */ void FitInside(wxWindow* window); + /** + Inform sizer about the first direction that has been decided (by + parent item). Returns true if it made use of the information (and + recalculated min size). + */ + virtual bool InformFirstDirection(int direction, int size, int availableOtherDir); + + //@{ /** Returns the list of the items in this sizer. @@ -420,6 +439,11 @@ public: */ wxWindow* GetContainingWindow() const; + /** + Set the window this sizer is used in. + */ + void SetContainingWindow(wxWindow *window); + /** Returns the number of items in the sizer. @@ -565,7 +589,18 @@ public: int flag = 0, int border = 0, wxObject* userData = NULL); + /** + Insert a child into the sizer before any existing item at @a index. + + See Add() for the meaning of the other parameters. + */ + wxSizerItem* Insert(size_t index, + int width, + int height, + const wxSizerFlags& flags); + wxSizerItem* Insert(size_t index, wxSizerItem* item); + /** Inserts non-stretchable space to the sizer. More readable way of calling wxSizer::Insert(index, size, size). @@ -607,7 +642,7 @@ public: bool IsShown(size_t index) const; /** - Call this to force layout of the children anew, e.g. after having added a child + Call this to force layout of the children anew, e.g.\ after having added a child to or removed a child (window, other sizer or space) from the sizer while keeping the current dimension. */ @@ -654,6 +689,14 @@ public: int border = 0, wxObject* userData = NULL); + /** + Same as Add(), but prepends the items to the beginning of the + list of items (windows, subsizers or spaces) owned by this sizer. + */ + wxSizerItem* Prepend(int width, int height, const wxSizerFlags& flags); + + wxSizerItem* Prepend(wxSizerItem* item); + /** Prepends non-stretchable space to the sizer. More readable way of calling wxSizer::Prepend(size, size, 0). @@ -783,35 +826,28 @@ public: /** Set an item's minimum size by window, sizer, or position. - The item will be found recursively in the sizer's descendants. This function enables an application to set the size of an item after initial creation. + The @a window or @a sizer will be found recursively in the sizer's + descendants. + @see wxSizerItem::SetMinSize() + + @return + @true if the minimal size was successfully set or @false if the + item was not found. */ + //@{ bool SetItemMinSize(wxWindow* window, int width, int height); + bool SetItemMinSize(wxWindow* window, const wxSize& size); - /** - Set an item's minimum size by window, sizer, or position. - - The item will be found recursively in the sizer's descendants. - This function enables an application to set the size of an item after - initial creation. - - @see wxSizerItem::SetMinSize() - */ bool SetItemMinSize(wxSizer* sizer, int width, int height); + bool SetItemMinSize(wxSizer* sizer, const wxSize& size); - /** - Set an item's minimum size by window, sizer, or position. - - The item will be found recursively in the sizer's descendants. - This function enables an application to set the size of an item after - initial creation. - - @see wxSizerItem::SetMinSize() - */ bool SetItemMinSize(size_t index, int width, int height); + bool SetItemMinSize(size_t index, const wxSize& size); + //@} /** Call this to give the sizer a minimal size. @@ -848,7 +884,8 @@ public: the sizer's minimal size. For windows with managed scrollbars this will set them appropriately. - @deprecated @todo provide deprecation description + @deprecated This is exactly the same as FitInside() in wxWidgets 2.9 + and later, please replace calls to it with FitInside(). @see wxScrolled::SetScrollbars() */ @@ -889,6 +926,13 @@ public: @see Hide(), IsShown() */ bool Show(size_t index, bool show = true); + + + /** + Show or hide all items managed by the sizer. + */ + virtual void ShowItems(bool show); + }; @@ -971,6 +1015,9 @@ public: outlined above. */ void SetNegativeButton(wxButton* button); + + virtual void RecalcSizes(); + virtual wxSize CalcMin(); }; @@ -994,27 +1041,27 @@ public: /** Construct a sizer item for tracking a spacer. */ - wxSizerItem(int width, int height, int proportion, int flag, - int border, wxObject* userData); + wxSizerItem(int width, int height, int proportion=0, int flag=0, + int border=0, wxObject* userData=NULL); //@{ /** Construct a sizer item for tracking a window. */ wxSizerItem(wxWindow* window, const wxSizerFlags& flags); - wxSizerItem(wxWindow* window, int proportion, int flag, - int border, - wxObject* userData); + wxSizerItem(wxWindow* window, int proportion=0, int flag=0, + int border=0, + wxObject* userData=NULL); //@} //@{ /** Construct a sizer item for tracking a subsizer. */ - wxSizerItem(wxSizer* window, const wxSizerFlags& flags); - wxSizerItem(wxSizer* sizer, int proportion, int flag, - int border, - wxObject* userData); + wxSizerItem(wxSizer* sizer, const wxSizerFlags& flags); + wxSizerItem(wxSizer* sizer, int proportion=0, int flag=0, + int border=0, + wxObject* userData=NULL); //@} /** @@ -1022,6 +1069,30 @@ public: */ virtual ~wxSizerItem(); + /** + Set the window to be tracked by this item. + + The old window isn't deleted as it is now owned by the sizer item. + */ + void AssignWindow(wxWindow *window); + + /** + Set the sizer tracked by this item. + + Old sizer, if any, is deleted. + */ + void AssignSizer(wxSizer *sizer); + + //@{ + /** + Set the size of the spacer tracked by this item. + + Old spacer, if any, is deleted. + */ + void AssignSpacer(const wxSize& size); + void AssignSpacer(int w, int h); + //@} + /** Calculates the minimum desired size for the item, including any space needed by borders. @@ -1191,16 +1262,22 @@ public: /** Set the sizer tracked by this item. - @deprecated @todo provide deprecation description + + @deprecated This function does not free the old sizer which may result + in memory leaks, use AssignSizer() which does free it instead. */ void SetSizer(wxSizer* sizer); /** Set the size of the spacer tracked by this item. - @deprecated @todo provide deprecation description + + @deprecated This function does not free the old spacer which may result + in memory leaks, use AssignSpacer() which does free it instead. */ void SetSpacer(const wxSize& size); + void SetUserData(wxObject* userData); + /** Set the window to be tracked by this item. @deprecated @todo provide deprecation description @@ -1338,7 +1415,7 @@ public: /** Set the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag. Normally wxSizers don't allocate space for hidden windows or other items. This flag - overrides this behavior so that sufficient space is allocated for the + overrides this behaviour so that sufficient space is allocated for the window even if it isn't visible. This makes it possible to dynamically show and hide controls without resizing parent dialog, for example. @@ -1437,17 +1514,7 @@ public: /** wxFlexGridSizer constructors. - Usually only the number of columns in the flex grid sizer needs to be - specified using @a cols argument. The number of rows will be deduced - automatically depending on the number of the elements added to the - sizer. If the number of @a rows is explicitly specified (and not zero), - the sizer will check that it no more than @code cols*rows @endcode - elements are added to it. - - The @a gap (or @a vgap and @a hgap, which correspond to the height and - width of the wxSize object) argument defines the size of the padding - between the rows (its vertical component, or @a vgap) and columns - (its horizontal component, or @a hgap), in pixels. + Please see wxGridSizer::wxGridSizer documentation. @since 2.9.1 (except for the four argument overload) */ @@ -1567,6 +1634,10 @@ public: Note that this method does not trigger relayout. */ void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode); + + virtual void RecalcSizes(); + virtual wxSize CalcMin(); + }; @@ -1590,18 +1661,27 @@ public: /** wxGridSizer constructors. - Usually only the number of columns in the grid sizer needs to be + Usually only the number of columns in the flex grid sizer needs to be specified using @a cols argument. The number of rows will be deduced automatically depending on the number of the elements added to the - sizer. If the number of @a rows is explicitly specified (and not zero), - the sizer will check that it no more than @code cols*rows @endcode - elements are added to it. + sizer. - The @a gap (or @a vgap and @a hgap, which correspond to @c y and @c x - fields of the wxSize object) argument defines the size of the padding - between the grid rows (its vertical component, or @a vgap) and columns + If a constructor form with @a rows parameter is used (and the value of + @a rows argument is not zero, meaning "unspecified") the sizer will + check that no more than @c cols*rows elements are added to it, i.e. + that no more than the given number of @a rows is used. Adding less than + maximally allowed number of items is not an error however. + + Finally, it is also possible to specify the number of rows and use 0 + for @a cols. In this case, the sizer will use the given fixed number of + rows and as many columns as necessary. + + The @a gap (or @a vgap and @a hgap, which correspond to the height and + width of the wxSize object) argument defines the size of the padding + between the rows (its vertical component, or @a vgap) and columns (its horizontal component, or @a hgap), in pixels. + @since 2.9.1 (except for the four argument overload) */ wxGridSizer( int cols, int vgap, int hgap ); @@ -1612,19 +1692,49 @@ public: //@} /** - Returns the number of columns in the sizer. + Returns the number of columns that has been specified for the + sizer. + + Returns zero if the sizer is automatically adjusting the number of + columns depending on number of its children. To get the effective + number of columns or rows being currently used, see GetEffectiveColsCount() */ int GetCols() const; + + /** + Returns the number of rows that has been specified for the + sizer. + + Returns zero if the sizer is automatically adjusting the number of + rows depending on number of its children. To get the effective + number of columns or rows being currently used, see GetEffectiveRowsCount(). + */ + int GetRows() const; /** - Returns the horizontal gap (in pixels) between cells in the sizer. + Returns the number of columns currently used by the sizer. + + This will depend on the number of children the sizer has if + the sizer is automatically adjusting the number of columns/rows. + + @since 2.9.1 */ - int GetHGap() const; + int GetEffectiveColsCount() const; + + /** + Returns the number of rows currently used by the sizer. + + This will depend on the number of children the sizer has if + the sizer is automatically adjusting the number of columns/rows. + + @since 2.9.1 + */ + int GetEffectiveRowsCount() const; /** - Returns the number of rows in the sizer. + Returns the horizontal gap (in pixels) between cells in the sizer. */ - int GetRows() const; + int GetHGap() const; /** Returns the vertical gap (in pixels) between the cells in the sizer. @@ -1650,6 +1760,9 @@ public: Sets the vertical gap (in pixels) between the cells in the sizer. */ void SetVGap(int gap); + + virtual wxSize CalcMin(); + virtual void RecalcSizes(); }; @@ -1710,6 +1823,9 @@ public: Returns the static box associated with the sizer. */ wxStaticBox* GetStaticBox() const; + + virtual wxSize CalcMin(); + virtual void RecalcSizes(); }; @@ -1737,6 +1853,22 @@ public: */ wxBoxSizer(int orient); + /** + Adds non-stretchable space to the main orientation of the sizer only. + More readable way of calling: + @code + if ( wxBoxSizer::IsVertical() ) + { + wxBoxSizer::Add(0, size, 0). + } + else + { + wxBoxSizer::Add(size, 0, 0). + } + @endcode + */ + virtual wxSizerItem *AddSpacer(int size); + /** Implements the calculation of a box sizer's minimal. @@ -1751,6 +1883,12 @@ public: */ int GetOrientation() const; + /** + Sets the orientation of the box sizer, either wxVERTICAL + or wxHORIZONTAL. + */ + void SetOrientation(int orient); + /** Implements the calculation of a box sizer's dimensions and then sets the size of its children (calling wxWindow::SetSize if the child is a window). @@ -1758,6 +1896,6 @@ public: It is used internally only and must not be called by the user (call Layout() if you want to resize). Documented for information. */ - void RecalcSizes(); + virtual void RecalcSizes(); };