Discussion:
Calculating size hints
Igor Korot
2014-08-24 09:43:28 UTC
Permalink
Hi, ALL,
I am developing a program which has following:

MainFrame as a main window which is initially maximized.
Inside it has 2 panels in a sizer:
Top panel has some controls and a grid with just one row.
Bottom panel has 2 rows of buttons, then row of some additional
controls and then a grid.

Now, here is the problem:
When I resize the main window, I want the resizing stop on the first
row of the bottom'
panel grid.
In order to do that I am trying to use SetSizeHints() but calculating
the height of all
those controls is not correct.
Everything is managed by the sizer.

Here is the relevant code snippet. Sorry it is kind of long.

TopPanel::TopPanel()
{
wxBoxSizer *mainSizer = new wxBoxSizer( wxVERTICAL );
// create controls and grid and add them to sizers
SetSizerAndFit( mainSizer ); // I don't call Layout()
}

BottomPanel::BottomPanel()
{
wxBoxSizer *mainSizer = new wxBoxSizer( wxVERTICAL );
// create controls
// populate grid
// add controls to sizers
SetSizer( mainSizer );
mainSizer->Fit( this ); // again, no Layout() call
}

MainFrame::MainFrame()
{
wxBoxSizer *mainSizer = new wxBoxSizer( wxVERTICAL );
TopPanel *panel1 = new TopPanel();
BottomPanel *panel2 = new BottomPanel();
// add both panels to sizers
SetSizerAndFit( mainSizer );
int minimalHeight = panel1->GetMyControl().GetSize().GetY() + 5;
minimalHeight += 2 *
(panel1->GetTopPanelGridWindow()->GetSize().GetY() + 5 );
minimalHeight += 2 * ( panel2->GetMyButton().GetSize().GetY() + 5 );
SetSizeHints( 100, minimalHeight );
}

The calculation of the minimalHeight is wrong as I can resize the
window vertically way
over the bottom panel grid.

There is nothing wrong with the calculation, but I think I just doing
it at the wrong place.

Could someone please point me in the right direction?

Thank you.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...