wxStaticBox with wxGridSizer cuts off wxStaticBox label

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Nefarious
Knows some wx things
Knows some wx things
Posts: 28
Joined: Fri Feb 24, 2017 8:23 pm

wxStaticBox with wxGridSizer cuts off wxStaticBox label

Post by Nefarious »

I create a static box and a grid sizer so I can put some controls in it as follows:

Code: Select all

mImageControl = new wxStaticBox(this, wxID_ANY, "Image Control",
	wxDefaultPosition, wxDefaultSize, 0, "Image");

wxGridSizer* pGSizer = new wxGridSizer(2, 0, 0); // two columns and no gap

pGSizer->Add(CreateCeilingControl());
// Do this for the three other controls in the grid

// Set the sizer and fit the control
mImageControl->SetSizerAndFit(pGSizer);
I then put controls that are wxBoxSizers into the grid sizer that are created as:

Code: Select all

wxBoxSizer* siControlPanel::CreateCeilingControl()
{
	wxBoxSizer* mCeilingSizer = new wxBoxSizer(wxVERTICAL);

	mCeilingLabel = new wxStaticText(this, wxID_ANY, "Beamform Ceiling",
		wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE);
	mCeilingSizer->Add(mCeilingLabel, 0, wxFIXED_MINSIZE | wxALL, 5);

	mCeilingSpinner = new wxSpinCtrl(this, wxID_ANY, wxEmptyString,
		wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE);
	mCeilingSizer->Add(mCeilingSpinner, 0, wxFIXED_MINSIZE | wxALL, 5);

	return mCeilingSizer;
}
The wxStaticBox name is written over by the contents of the grid sizer. Do I have to reserve space for the wxStaticBox label?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7460
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxStaticBox with wxGridSizer cuts off wxStaticBox label

Post by ONEEYEMAN »

Hi,
You probably need a wxStaticBoxSizer, not a wxStaticBox.

Thank you.
Post Reply