wxFlexGridSizer Class Reference | wxWidgets

| Version: 3.2.11

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxFlexGridSizer Class Reference
Class List by Category » Window Layout

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.2/wxWidgets3.2-3.2.11-1.x86_64/src/wxWidgets-3.2.11/interface/wx/sizer.h>`

Inheritance diagram for wxFlexGridSizer:
[legend]

## Detailed Description

A flex grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields in one row having the same height and all fields in one column having the same width, but all rows or all columns are not necessarily the same height or width as in the wxGridSizer.

Since wxWidgets 2.5.0, wxFlexGridSizer can also size items equally in one direction but unequally ("flexibly") in the other. If the sizer is only flexible in one direction (this can be changed using wxFlexGridSizer::SetFlexibleDirection), it needs to be decided how the sizer should grow in the other ("non-flexible") direction in order to fill the available space. The wxFlexGridSizer::SetNonFlexibleGrowMode() method serves this purpose.

##

Library: wxCore
Category: Window Layout

See also
  wxSizer, Sizers Overview

## Public Member Functions
void | AddGrowableCol (size_t idx, int proportion=0)
| Specifies that column idx (starting from zero) should be grown if there is extra space available to the sizer.
void | AddGrowableRow (size_t idx, int proportion=0)
| Specifies that row idx (starting from zero) should be grown if there is extra space available to the sizer.
int | GetFlexibleDirection () const
| Returns a wxOrientation value that specifies whether the sizer flexibly resizes its columns, rows, or both (default).
wxFlexSizerGrowMode | GetNonFlexibleGrowMode () const
| Returns the value that specifies how the sizer grows in the "non-flexible" direction if there is one.
bool | IsColGrowable (size_t idx)
| Returns true if column idx is growable.
bool | IsRowGrowable (size_t idx)
| Returns true if row idx is growable.
void | RemoveGrowableCol (size_t idx)
| Specifies that the idx column index is no longer growable.
void | RemoveGrowableRow (size_t idx)
| Specifies that the idx row index is no longer growable.
void | SetFlexibleDirection (int direction)
| Specifies whether the sizer should flexibly resize its columns, rows, or both.
void | SetNonFlexibleGrowMode (wxFlexSizerGrowMode mode)
| Specifies how the sizer should grow in the non-flexible direction if there is one (so SetFlexibleDirection() must have been called previously).
const wxArrayInt & | GetRowHeights () const
| Returns a read-only array containing the heights of the rows in the sizer.
const wxArrayInt & | GetColWidths () const
| Returns a read-only array containing the widths of the columns in the sizer.
virtual void | RepositionChildren (const wxSize &minSize)
| Method which must be overridden in the derived sizer classes.
virtual wxSize | CalcMin ()
| This method is abstract and has to be overwritten by any derived class.
| wxFlexGridSizer (int cols, int vgap, int hgap)
| wxFlexGridSizer constructors.
| wxFlexGridSizer (int cols, const wxSize &gap=wxSize(0, 0))
| wxFlexGridSizer constructors.
| wxFlexGridSizer (int rows, int cols, int vgap, int hgap)
| wxFlexGridSizer constructors.
| wxFlexGridSizer (int rows, int cols, const wxSize &gap)
| wxFlexGridSizer constructors.
Public Member Functions inherited from wxGridSizer
int | GetCols () const
| Returns the number of columns that has been specified for the sizer.
int | GetRows () const
| Returns the number of rows that has been specified for the sizer.
int | GetEffectiveColsCount () const
| Returns the number of columns currently used by the sizer.
int | GetEffectiveRowsCount () const
| Returns the number of rows currently used by the sizer.
int | GetHGap () const
| Returns the horizontal gap (in pixels) between cells in the sizer.
int | GetVGap () const
| Returns the vertical gap (in pixels) between the cells in the sizer.
void | SetCols (int cols)
| Sets the number of columns in the sizer.
void | SetHGap (int gap)
| Sets the horizontal gap (in pixels) between cells in the sizer.
void | SetRows (int rows)
| Sets the number of rows in the sizer.
void | SetVGap (int gap)
| Sets the vertical gap (in pixels) between the cells in the sizer.
| wxGridSizer (int cols, int vgap, int hgap)
| wxGridSizer constructors.
| wxGridSizer (int cols, const wxSize &gap=wxSize(0, 0))
| wxGridSizer constructors.
| wxGridSizer (int rows, int cols, int vgap, int hgap)
| wxGridSizer constructors.
| wxGridSizer (int rows, int cols, const wxSize &gap)
| wxGridSizer constructors.
Public Member Functions inherited from wxSizer
| wxSizer ()
| The constructor.
virtual | ~wxSizer ()
| The destructor.
wxSizerItem * | Add (wxWindow *window, const wxSizerFlags &flags)
| Appends a child to the sizer.
wxSizerItem * | Add (wxWindow *window, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Appends a child to the sizer.
wxSizerItem * | Add (wxSizer *sizer, const wxSizerFlags &flags)
| Appends a child to the sizer.
wxSizerItem * | Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Appends a child to the sizer.
wxSizerItem * | Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Appends a spacer child to the sizer.
wxSizerItem * | Add (int width, int height, const wxSizerFlags &flags)
| Appends a spacer child to the sizer.
wxSizerItem * | Add (wxSizerItem *item)
virtual wxSizerItem * | AddSpacer (int size)
| This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer.
wxSizerItem * | AddStretchSpacer (int prop=1)
| Adds stretchable space to the sizer.
virtual void | Clear (bool delete_windows=false)
| Detaches all children from the sizer.
wxSize | ComputeFittingClientSize (wxWindow *window)
| Computes client area size for window so that it matches the sizer's minimal size.
wxSize | ComputeFittingWindowSize (wxWindow *window)
| Like ComputeFittingClientSize(), but converts the result into window size.
virtual bool | Detach (wxWindow *window)
| Detach the child window from the sizer without destroying it.
virtual bool | Detach (wxSizer *sizer)
| Detach the child sizer from the sizer without destroying it.
virtual bool | Detach (int index)
| Detach an item at position index from the sizer without destroying it.
wxSize | Fit (wxWindow *window)
| Tell the sizer to resize the window so that its client area matches the sizer's minimal size (ComputeFittingClientSize() is called to determine it).
void | FitInside (wxWindow *window)
| Tell the sizer to resize the virtual size of the window to match the sizer's minimal size.
virtual bool | InformFirstDirection (int direction, int size, int availableOtherDir)
| Inform sizer about the first direction that has been decided (by parent item).
wxWindow * | GetContainingWindow () const
| Returns the window this sizer is used in or NULL if none.
void | SetContainingWindow (wxWindow *window)
| Set the window this sizer is used in.
size_t | GetItemCount () const
| Returns the number of items in the sizer.
wxSizerItem * | GetItem (wxWindow *window, bool recursive=false)
| Finds the wxSizerItem which holds the given window.
wxSizerItem * | GetItem (wxSizer *sizer, bool recursive=false)
| Finds the wxSizerItem which holds the given sizer.
wxSizerItem * | GetItem (size_t index)
| Finds the wxSizerItem which is located in the sizer at position index.
wxSizerItem * | GetItemById (int id, bool recursive=false)
| Finds the item in the sizer which has the given id.
wxSize | GetMinSize ()
| Returns the minimal size of the sizer.
wxPoint | GetPosition () const
| Returns the current position of the sizer.
wxSize | GetSize () const
| Returns the current size of the sizer.
bool | Hide (wxWindow *window, bool recursive=false)
| Hides the child window.
bool | Hide (wxSizer *sizer, bool recursive=false)
| Hides the child sizer.
bool | Hide (size_t index)
| Hides the item at position index.
wxSizerItem * | Insert (size_t index, wxWindow *window, const wxSizerFlags &flags)
| Insert a child into the sizer before any existing item at index.
wxSizerItem * | Insert (size_t index, wxWindow *window, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Insert a child into the sizer before any existing item at index.
wxSizerItem * | Insert (size_t index, wxSizer *sizer, const wxSizerFlags &flags)
| Insert a child into the sizer before any existing item at index.
wxSizerItem * | Insert (size_t index, wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Insert a child into the sizer before any existing item at index.
wxSizerItem * | Insert (size_t index, int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Insert a child into the sizer before any existing item at index.
wxSizerItem * | Insert (size_t index, int width, int height, const wxSizerFlags &flags)
| Insert a child into the sizer before any existing item at index.
wxSizerItem * | Insert (size_t index, wxSizerItem *item)
wxSizerItem * | InsertSpacer (size_t index, int size)
| Inserts non-stretchable space to the sizer.
wxSizerItem * | InsertStretchSpacer (size_t index, int prop=1)
| Inserts stretchable space to the sizer.
bool | IsEmpty () const
| Return true if the sizer has no elements.
bool | IsShown (wxWindow *window) const
| Returns true if the window is shown.
bool | IsShown (wxSizer *sizer) const
| Returns true if the sizer is shown.
bool | IsShown (size_t index) const
| Returns true if the item at index is shown.
virtual void | Layout ()
| 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.
wxSizerItem * | Prepend (wxWindow *window, const wxSizerFlags &flags)
| 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 (wxWindow *window, int proportion=0, int flag=0, 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 (wxSizer *sizer, const wxSizerFlags &flags)
| 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 (wxSizer *sizer, int proportion=0, int flag=0, 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, int proportion=0, int flag=0, 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)
| 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 (wxSizerItem *item)
wxSizerItem * | PrependSpacer (int size)
| Prepends non-stretchable space to the sizer.
wxSizerItem * | PrependStretchSpacer (int prop=1)
| Prepends stretchable space to the sizer.
virtual bool | Remove (wxWindow *window)
| Removes a child window from the sizer, but does not destroy it (because windows are owned by their parent window, not the sizer).
virtual bool | Remove (wxSizer *sizer)
| Removes a sizer child from the sizer and destroys it.
virtual bool | Remove (int index)
| Removes a child from the sizer and destroys it if it is a sizer or a spacer, but not if it is a window (because windows are owned by their parent window, not the sizer).
virtual bool | Replace (wxWindow *oldwin, wxWindow *newwin, bool recursive=false)
| Detaches the given oldwin from the sizer and replaces it with the given newwin.
virtual bool | Replace (wxSizer *oldsz, wxSizer *newsz, bool recursive=false)
| Detaches the given oldsz from the sizer and replaces it with the given newsz.
virtual bool | Replace (size_t index, wxSizerItem *newitem)
| Detaches the given item at position index from the sizer and replaces it with the given wxSizerItem newitem.
void | SetDimension (int x, int y, int width, int height)
| Call this to force the sizer to take the given dimension and thus force the items owned by the sizer to resize themselves according to the rules defined by the parameter in the Add() and Prepend() methods.
void | SetDimension (const wxPoint &pos, const wxSize &size)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | SetMinSize (const wxSize &size)
| Call this to give the sizer a minimal size.
void | SetMinSize (int width, int height)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void | SetSizeHints (wxWindow *window)
| This method first calls Fit() and then wxTopLevelWindow::SetSizeHints() on the window passed to it.
void | SetVirtualSizeHints (wxWindow *window)
| Tell the sizer to set the minimal size of the window virtual area to match the sizer's minimal size.
bool | Show (wxWindow *window, bool show=true, bool recursive=false)
| Shows or hides the window.
bool | Show (wxSizer *sizer, bool show=true, bool recursive=false)
| Shows or hides sizer.
bool | Show (size_t index, bool show=true)
| Shows the item at index.
virtual void | ShowItems (bool show)
| Show or hide all items managed by the sizer.
wxSizerItemList & | GetChildren ()
| Returns the list of the items in this sizer.
const wxSizerItemList & | GetChildren () const
| Returns the list of the items in this sizer.
bool | SetItemMinSize (wxWindow *window, int width, int height)
| Set an item's minimum size by window, sizer, or position.
bool | SetItemMinSize (wxWindow *window, const wxSize &size)
| Set an item's minimum size by window, sizer, or position.
bool | SetItemMinSize (wxSizer *sizer, int width, int height)
| Set an item's minimum size by window, sizer, or position.
bool | SetItemMinSize (wxSizer *sizer, const wxSize &size)
| Set an item's minimum size by window, sizer, or position.
bool | SetItemMinSize (size_t index, int width, int height)
| Set an item's minimum size by window, sizer, or position.
bool | SetItemMinSize (size_t index, const wxSize &size)
| Set an item's minimum size by window, sizer, or position.
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data.
| wxObject (const wxObject &other)
| Copy ctor.
virtual | ~wxObject ()
| Destructor.
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class.
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj.
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone.
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer.
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data.
void | UnShare ()
| This is the same of AllocExclusive() but this method is public.
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object.
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data.

## Constructor & Destructor Documentation

## ◆ wxFlexGridSizer() [1/4]

wxFlexGridSizer::wxFlexGridSizer | ( | int | cols,
|  | int | vgap,
|  | int | hgap )

wxFlexGridSizer constructors.

Please see wxGridSizer::wxGridSizer documentation.

Since
  2.9.1 (except for the four argument overload)

## ◆ wxFlexGridSizer() [2/4]

wxFlexGridSizer::wxFlexGridSizer | ( | int | cols,
|  | const wxSize & | gap = wxSize(0, 0) )

wxFlexGridSizer constructors.

Please see wxGridSizer::wxGridSizer documentation.

Since
  2.9.1 (except for the four argument overload)

## ◆ wxFlexGridSizer() [3/4]

wxFlexGridSizer::wxFlexGridSizer | ( | int | rows,
|  | int | cols,
|  | int | vgap,
|  | int | hgap )

wxFlexGridSizer constructors.

Please see wxGridSizer::wxGridSizer documentation.

Since
  2.9.1 (except for the four argument overload)

## ◆ wxFlexGridSizer() [4/4]

wxFlexGridSizer::wxFlexGridSizer | ( | int | rows,
|  | int | cols,
|  | const wxSize & | gap )

wxFlexGridSizer constructors.

Please see wxGridSizer::wxGridSizer documentation.

Since
  2.9.1 (except for the four argument overload)

## Member Function Documentation

## ◆ AddGrowableCol()

void wxFlexGridSizer::AddGrowableCol | ( | size_t | idx,
|  | int | proportion = 0 )

Specifies that column idx (starting from zero) should be grown if there is extra space available to the sizer.

The proportion parameter has the same meaning as the stretch factor for the sizers (see wxBoxSizer) except that if all proportions are 0, then all columns are resized equally (instead of not being resized at all).

Notice that the column must not be already growable, if you need to change the proportion you must call RemoveGrowableCol() first and then make it growable (with a different proportion) again. You can use IsColGrowable() to check whether a column is already growable.

## ◆ AddGrowableRow()

void wxFlexGridSizer::AddGrowableRow | ( | size_t | idx,
|  | int | proportion = 0 )

Specifies that row idx (starting from zero) should be grown if there is extra space available to the sizer.

This is identical to AddGrowableCol() except that it works with rows and not columns.

## ◆ CalcMin()

virtual wxSize wxFlexGridSizer::CalcMin | ( |  | ) |
| virtual

This method is abstract and has to be overwritten by any derived class.

Here, the sizer will do the actual calculation of its children's minimal sizes.

Reimplemented from wxGridSizer.

Reimplemented in wxGridBagSizer.

## ◆ GetColWidths()

const wxArrayInt & wxFlexGridSizer::GetColWidths | ( |  | ) | const

Returns a read-only array containing the widths of the columns in the sizer.

## ◆ GetFlexibleDirection()

int wxFlexGridSizer::GetFlexibleDirection | ( |  | ) | const

Returns a wxOrientation value that specifies whether the sizer flexibly resizes its columns, rows, or both (default).

Returns
  One of the following values:
  - wxVERTICAL: Rows are flexibly sized.
  - wxHORIZONTAL: Columns are flexibly sized.
  - wxBOTH: Both rows and columns are flexibly sized (this is the default value).

See also
  SetFlexibleDirection()

## ◆ GetNonFlexibleGrowMode()

wxFlexSizerGrowMode wxFlexGridSizer::GetNonFlexibleGrowMode | ( |  | ) | const

Returns the value that specifies how the sizer grows in the "non-flexible" direction if there is one.

The behaviour of the elements in the flexible direction (i.e. both rows and columns by default, or rows only if GetFlexibleDirection() is `wxVERTICAL` or columns only if it is `wxHORIZONTAL`) is always governed by their proportion as specified in the call to AddGrowableRow() or AddGrowableCol(). What happens in the other direction depends on the value of returned by this function as described below.

Returns
  One of the following values:
  - wxFLEX_GROWMODE_NONE: Sizer doesn't grow its elements at all in the non-flexible direction.
  - wxFLEX_GROWMODE_SPECIFIED: Sizer honors growable columns/rows set with AddGrowableCol() and AddGrowableRow() in the non-flexible direction as well. In this case equal sizing applies to minimum sizes of columns or rows (this is the default value).
  - wxFLEX_GROWMODE_ALL: Sizer equally stretches all columns or rows in the non-flexible direction, independently of the proportions applied in the flexible direction.

See also
  SetFlexibleDirection(), SetNonFlexibleGrowMode()

## ◆ GetRowHeights()

const wxArrayInt & wxFlexGridSizer::GetRowHeights | ( |  | ) | const

Returns a read-only array containing the heights of the rows in the sizer.

## ◆ IsColGrowable()

bool wxFlexGridSizer::IsColGrowable | ( | size_t | idx | ) |

Returns true if column idx is growable.

Since
  2.9.0

## ◆ IsRowGrowable()

bool wxFlexGridSizer::IsRowGrowable | ( | size_t | idx | ) |

Returns true if row idx is growable.

Since
  2.9.0

## ◆ RemoveGrowableCol()

void wxFlexGridSizer::RemoveGrowableCol | ( | size_t | idx | ) |

Specifies that the idx column index is no longer growable.

## ◆ RemoveGrowableRow()

void wxFlexGridSizer::RemoveGrowableRow | ( | size_t | idx | ) |

Specifies that the idx row index is no longer growable.

## ◆ RepositionChildren()

virtual void wxFlexGridSizer::RepositionChildren | ( | const wxSize & | minSize | ) |
| virtual

Method which must be overridden in the derived sizer classes.

The implementation should reposition the children using the current total size available to the sizer (`m_size`) and the size computed by the last call to CalcMin().

Note that you should never call this method directly, call Layout() instead if you need to manually update the sizer elements positions. This method is only called by wxWidgets itself.

Since
  3.1.3, before this version RecalcSizes() method not taking any arguments had to be overridden in the derived classes instead.

Reimplemented from wxGridSizer.

Reimplemented in wxGridBagSizer.

## ◆ SetFlexibleDirection()

void wxFlexGridSizer::SetFlexibleDirection | ( | int | direction | ) |

Specifies whether the sizer should flexibly resize its columns, rows, or both.

Argument direction can be `wxVERTICAL`, `wxHORIZONTAL` or `wxBOTH` (which is the default value). Any other value is ignored.

See GetFlexibleDirection() for the explanation of these values. Note that this method does not trigger relayout.

## ◆ SetNonFlexibleGrowMode()

void wxFlexGridSizer::SetNonFlexibleGrowMode | ( | wxFlexSizerGrowMode | mode | ) |

Specifies how the sizer should grow in the non-flexible direction if there is one (so SetFlexibleDirection() must have been called previously).

Argument mode can be one of those documented in GetNonFlexibleGrowMode(), please see there for their explanation. Note that this method does not trigger relayout.