| Version: 3.2.8

Public Member Functions | List of all members
wxStaticBoxSizer Class Reference
Class List by Category » Window Layout

`#include <wx/sizer.h>`

Inheritance diagram for wxStaticBoxSizer:
[legend]

## Detailed Description

wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static box around the sizer.

The static box may be either created independently or the sizer may create it itself as a convenience. In any case, the sizer owns the wxStaticBox control and will delete it in the wxStaticBoxSizer destructor.

Note that since wxWidgets 2.9.1 you are strongly encouraged to create the windows which are added to wxStaticBoxSizer as children of wxStaticBox itself, see this class documentation for more details.

Example of use of this class:

void MyFrame::CreateControls()
{
wxPanel *panel = new wxPanel(this);
...
wxStaticBoxSizer *sz = new wxStaticBoxSizer(wxVERTICAL, panel, "Box");
sz->Add(new wxStaticText(sz->GetStaticBox(), wxID_ANY,
"This window is a child of the staticbox"));
...
}
wxPanel
A panel is a window on which controls are placed.
Definition: panel.h:38
wxSizer::Add
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
Appends a child to the sizer.
wxStaticBoxSizer
wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static box around the sizer.
Definition: sizer.h:1974
wxStaticBoxSizer::wxStaticBoxSizer
wxStaticBoxSizer(wxStaticBox *box, int orient)
This constructor uses an already existing static box.
wxStaticBoxSizer::GetStaticBox
wxStaticBox * GetStaticBox() const
Returns the static box associated with the sizer.
wxStaticText
A static text control displays one or more lines of read-only text.
Definition: stattext.h:54
wxVERTICAL
@ wxVERTICAL
Definition: defs.h:28
wxID_ANY
@ wxID_ANY
Any id: means that we don't care about the id, whether when installing an event handler or when creat...
Definition: defs.h:597

##

Library: wxCore
Category: Window Layout

See also
  wxSizer, wxStaticBox, wxBoxSizer, Sizers Overview

## Public Member Functions
| wxStaticBoxSizer (wxStaticBox *box, int orient)
| This constructor uses an already existing static box. More...
| wxStaticBoxSizer (int orient, wxWindow *parent, const wxString &label=wxEmptyString)
| This constructor creates a new static box with the given label and parent window. More...
wxStaticBox * | GetStaticBox () const
| Returns the static box associated with the sizer. More...
virtual wxSize | CalcMin ()
| Implements the calculation of a box sizer's minimal. More...
virtual void | RepositionChildren (const wxSize &minSize)
| Method which must be overridden in the derived sizer classes. More...
Public Member Functions inherited from wxBoxSizer
| wxBoxSizer (int orient)
| Constructor for a wxBoxSizer. More...
virtual wxSizerItem * | AddSpacer (int size)
| Adds non-stretchable space to the main orientation of the sizer only. More...
int | GetOrientation () const
| Returns the orientation of the box sizer, either wxVERTICAL or wxHORIZONTAL. More...
void | SetOrientation (int orient)
| Sets the orientation of the box sizer, either wxVERTICAL or wxHORIZONTAL. More...
virtual bool | InformFirstDirection (int direction, int size, int availableOtherDir)
| Inform sizer about the first direction that has been decided (by parent item). More...
Public Member Functions inherited from wxSizer
| wxSizer ()
| The constructor. More...
virtual | ~wxSizer ()
| The destructor. More...
wxSizerItem * | Add (wxWindow *window, const wxSizerFlags &flags)
| Appends a child to the sizer. More...
wxSizerItem * | Add (wxWindow *window, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Appends a child to the sizer. More...
wxSizerItem * | Add (wxSizer *sizer, const wxSizerFlags &flags)
| Appends a child to the sizer. More...
wxSizerItem * | Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
| Appends a child to the sizer. More...
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. More...
wxSizerItem * | Add (int width, int height, const wxSizerFlags &flags)
| Appends a spacer child to the sizer. More...
wxSizerItem * | Add (wxSizerItem *item)
wxSizerItem * | AddStretchSpacer (int prop=1)
| Adds stretchable space to the sizer. More...
virtual void | Clear (bool delete_windows=false)
| Detaches all children from the sizer. More...
wxSize | ComputeFittingClientSize (wxWindow *window)
| Computes client area size for window so that it matches the sizer's minimal size. More...
wxSize | ComputeFittingWindowSize (wxWindow *window)
| Like ComputeFittingClientSize(), but converts the result into window size. More...
virtual bool | Detach (wxWindow *window)
| Detach the child window from the sizer without destroying it. More...
virtual bool | Detach (wxSizer *sizer)
| Detach the child sizer from the sizer without destroying it. More...
virtual bool | Detach (int index)
| Detach an item at position index from the sizer without destroying it. More...
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). More...
void | FitInside (wxWindow *window)
| Tell the sizer to resize the virtual size of the window to match the sizer's minimal size. More...
wxWindow * | GetContainingWindow () const
| Returns the window this sizer is used in or NULL if none. More...
void | SetContainingWindow (wxWindow *window)
| Set the window this sizer is used in. More...
size_t | GetItemCount () const
| Returns the number of items in the sizer. More...
wxSizerItem * | GetItem (wxWindow *window, bool recursive=false)
| Finds the wxSizerItem which holds the given window. More...
wxSizerItem * | GetItem (wxSizer *sizer, bool recursive=false)
| Finds the wxSizerItem which holds the given sizer. More...
wxSizerItem * | GetItem (size_t index)
| Finds the wxSizerItem which is located in the sizer at position index. More...
wxSizerItem * | GetItemById (int id, bool recursive=false)
| Finds the item in the sizer which has the given id. More...
wxSize | GetMinSize ()
| Returns the minimal size of the sizer. More...
wxPoint | GetPosition () const
| Returns the current position of the sizer. More...
wxSize | GetSize () const
| Returns the current size of the sizer. More...
bool | Hide (wxWindow *window, bool recursive=false)
| Hides the child window. More...
bool | Hide (wxSizer *sizer, bool recursive=false)
| Hides the child sizer. More...
bool | Hide (size_t index)
| Hides the item at position index. More...
wxSizerItem * | Insert (size_t index, wxWindow *window, const wxSizerFlags &flags)
| Insert a child into the sizer before any existing item at index. More...
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. More...
wxSizerItem * | Insert (size_t index, wxSizer *sizer, const wxSizerFlags &flags)
| Insert a child into the sizer before any existing item at index. More...
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. More...
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. More...
wxSizerItem * | Insert (size_t index, int width, int height, const wxSizerFlags &flags)
| Insert a child into the sizer before any existing item at index. More...
wxSizerItem * | Insert (size_t index, wxSizerItem *item)
wxSizerItem * | InsertSpacer (size_t index, int size)
| Inserts non-stretchable space to the sizer. More...
wxSizerItem * | InsertStretchSpacer (size_t index, int prop=1)
| Inserts stretchable space to the sizer. More...
bool | IsEmpty () const
| Return true if the sizer has no elements. More...
bool | IsShown (wxWindow *window) const
| Returns true if the window is shown. More...
bool | IsShown (wxSizer *sizer) const
| Returns true if the sizer is shown. More...
bool | IsShown (size_t index) const
| Returns true if the item at index is shown. More...
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. More...
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. More...
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. More...
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. More...
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. More...
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. More...
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. More...
wxSizerItem * | Prepend (wxSizerItem *item)
wxSizerItem * | PrependSpacer (int size)
| Prepends non-stretchable space to the sizer. More...
wxSizerItem * | PrependStretchSpacer (int prop=1)
| Prepends stretchable space to the sizer. More...
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). More...
virtual bool | Remove (wxSizer *sizer)
| Removes a sizer child from the sizer and destroys it. More...
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). More...
virtual bool | Replace (wxWindow *oldwin, wxWindow *newwin, bool recursive=false)
| Detaches the given oldwin from the sizer and replaces it with the given newwin. More...
virtual bool | Replace (wxSizer *oldsz, wxSizer *newsz, bool recursive=false)
| Detaches the given oldsz from the sizer and replaces it with the given newsz. More...
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. More...
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. More...
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. More...
void | SetMinSize (const wxSize &size)
| Call this to give the sizer a minimal size. More...
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. More...
void | SetSizeHints (wxWindow *window)
| This method first calls Fit() and then wxTopLevelWindow::SetSizeHints() on the window passed to it. More...
void | SetVirtualSizeHints (wxWindow *window)
| Tell the sizer to set the minimal size of the window virtual area to match the sizer's minimal size. More...
bool | Show (wxWindow *window, bool show=true, bool recursive=false)
| Shows or hides the window. More...
bool | Show (wxSizer *sizer, bool show=true, bool recursive=false)
| Shows or hides sizer. More...
bool | Show (size_t index, bool show=true)
| Shows the item at index. More...
virtual void | ShowItems (bool show)
| Show or hide all items managed by the sizer. More...
wxSizerItemList & | GetChildren ()
| Returns the list of the items in this sizer. More...
const wxSizerItemList & | GetChildren () const
| Returns the list of the items in this sizer. More...
bool | SetItemMinSize (wxWindow *window, int width, int height)
| Set an item's minimum size by window, sizer, or position. More...
bool | SetItemMinSize (wxWindow *window, const wxSize &size)
| Set an item's minimum size by window, sizer, or position. More...
bool | SetItemMinSize (wxSizer *sizer, int width, int height)
| Set an item's minimum size by window, sizer, or position. More...
bool | SetItemMinSize (wxSizer *sizer, const wxSize &size)
| Set an item's minimum size by window, sizer, or position. More...
bool | SetItemMinSize (size_t index, int width, int height)
| Set an item's minimum size by window, sizer, or position. More...
bool | SetItemMinSize (size_t index, const wxSize &size)
| Set an item's minimum size by window, sizer, or position. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
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). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
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. More...

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

## Constructor & Destructor Documentation

## ◆ wxStaticBoxSizer() [1/2]

wxStaticBoxSizer::wxStaticBoxSizer | ( | wxStaticBox * | box,
|  | int | orient
| ) |  |

This constructor uses an already existing static box.

Parameters

  box | The static box to associate with the sizer (which will take its ownership).
  orient | Can be either `wxVERTICAL` or `wxHORIZONTAL`.

## ◆ wxStaticBoxSizer() [2/2]

wxStaticBoxSizer::wxStaticBoxSizer | ( | int | orient,
|  | wxWindow * | parent,
|  | const wxString & | label = `wxEmptyString`
| ) |  |

This constructor creates a new static box with the given label and parent window.

## Member Function Documentation

## ◆ CalcMin()

virtual wxSize wxStaticBoxSizer::CalcMin | ( |  | ) |
| virtual

Implements the calculation of a box sizer's minimal.

It is used internally only and must not be called by the user. Documented for information.

Reimplemented from wxBoxSizer.

## ◆ GetStaticBox()

wxStaticBox* wxStaticBoxSizer::GetStaticBox | ( |  | ) | const

Returns the static box associated with the sizer.

## ◆ RepositionChildren()

virtual void wxStaticBoxSizer::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().

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

Reimplemented from wxBoxSizer.