## wxGridBagSizer

A wxSizer that can lay out items in a virtual grid like a wxFlexGridSizer but in this case explicit positioning of the items is allowed using wxGBPosition, and items can optionally span more than one row and/or column using wxGBSpan.

Derived from

wxFlexGridSizer
wxGridSizer
wxSizer
wxObject

Include files

<wx/gbsizer.h>

Members

wxGridBagSizer::wxGridBagSizer
wxGridBagSizer::Add
wxGridBagSizer::CalcMin
wxGridBagSizer::CheckForIntersection
wxGridBagSizer::FindItem
wxGridBagSizer::FindItemAtPoint
wxGridBagSizer::FindItemAtPosition
wxGridBagSizer::FindItemWithData
wxGridBagSizer::GetCellSize
wxGridBagSizer::GetEmptyCellSize
wxGridBagSizer::GetItemPosition
wxGridBagSizer::GetItemSpan
wxGridBagSizer::RecalcSizes
wxGridBagSizer::SetEmptyCellSize
wxGridBagSizer::SetItemPosition
wxGridBagSizer::SetItemSpan

### wxGridBagSizer::wxGridBagSizer

wxGridBagSizer(int vgap = 0, int hgap = 0)

Constructor, with optional parameters to specify the gap between the rows and columns.

### wxGridBagSizer::Add

wxSizerItem* Add(wxWindow* window, const wxGBPosition& pos, const wxGBSpan& span = wxDefaultSpan, int flag = 0, int border = 0, wxObject* userData = NULL)

wxSizerItem* Add(wxSizer* sizer, const wxGBPosition& pos, const wxGBSpan& span = wxDefaultSpan, int flag = 0, int border = 0, wxObject* userData = NULL)

wxSizerItem* Add(int width, int height, const wxGBPosition& pos, const wxGBSpan& span = wxDefaultSpan, int flag = 0, int border = 0, wxObject* userData = NULL)

wxSizerItem* Add(wxGBSizerItem* item)

The Add methods return a valid pointer if the item was successfully placed at the given position, NULL if something was already there.

### wxGridBagSizer::CalcMin

wxSize CalcMin()

Called when the managed size of the sizer is needed or when layout needs done.

### wxGridBagSizer::CheckForIntersection

bool CheckForIntersection(wxGBSizerItem* item, wxGBSizerItem* excludeItem = NULL)

bool CheckForIntersection(const wxGBPosition& pos, const wxGBSpan& span, wxGBSizerItem* excludeItem = NULL)

Look at all items and see if any intersect (or would overlap) the given item. Returns true if so, false if there would be no overlap. If an excludeItem is given then it will not be checked for intersection, for example it may be the item we are checking the position of.

### wxGridBagSizer::FindItem

wxGBSizerItem* FindItem(wxWindow* window)

wxGBSizerItem* FindItem(wxSizer* sizer)

Find the sizer item for the given window or subsizer, returns NULL if not found. (non-recursive)

### wxGridBagSizer::FindItemAtPoint

wxGBSizerItem* FindItemAtPoint(const wxPoint& pt)

Return the sizer item located at the point given in pt, or NULL if there is no item at that point. The (x,y) coordinates in pt correspond to the client coordinates of the window using the sizer for layout. (non-recursive)

### wxGridBagSizer::FindItemAtPosition

wxGBSizerItem* FindItemAtPosition(const wxGBPosition& pos)

Return the sizer item for the given grid cell, or NULL if there is no item at that position. (non-recursive)

### wxGridBagSizer::FindItemWithData

wxGBSizerItem* FindItemWithData(const wxObject* userData)

Return the sizer item that has a matching user data (it only compares pointer values) or NULL if not found. (non-recursive)

### wxGridBagSizer::GetCellSize

wxSize GetCellSize(int row, int col) const

Get the size of the specified cell, including hgap and vgap. Only valid after a Layout.

### wxGridBagSizer::GetEmptyCellSize

wxSize GetEmptyCellSize() const

Get the size used for cells in the grid with no item.

### wxGridBagSizer::GetItemPosition

wxGBPosition GetItemPosition(wxWindow* window)

wxGBPosition GetItemPosition(wxSizer* sizer)

wxGBPosition GetItemPosition(size_t index)

Get the grid position of the specified item.

### wxGridBagSizer::GetItemSpan

wxGBSpan GetItemSpan(wxWindow* window)

wxGBSpan GetItemSpan(wxSizer* sizer)

wxGBSpan GetItemSpan(size_t index)

Get the row/col spanning of the specified item

### wxGridBagSizer::RecalcSizes

void RecalcSizes()

Called when the managed size of the sizer is needed or when layout needs done.

### wxGridBagSizer::SetEmptyCellSize

void SetEmptyCellSize(const wxSize& sz)

Set the size used for cells in the grid with no item.

### wxGridBagSizer::SetItemPosition

bool SetItemPosition(wxWindow* window, const wxGBPosition& pos)

bool SetItemPosition(wxSizer* sizer, const wxGBPosition& pos)

bool SetItemPosition(size_t index, const wxGBPosition& pos)

Set the grid position of the specified item. Returns true on success. If the move is not allowed (because an item is already there) then false is returned.

### wxGridBagSizer::SetItemSpan

bool SetItemSpan(wxWindow* window, const wxGBSpan& span)

bool SetItemSpan(wxSizer* sizer, const wxGBSpan& span)

bool SetItemSpan(size_t index, const wxGBSpan& span)

Set the row/col spanning of the specified item. Returns true on success. If the move is not allowed (because an item is already there) then false is returned.