Page 1 of 1

Resize Panel after hiding wxStaticBoxSizer

Posted: Tue Feb 24, 2015 3:21 pm
by Samfox2
I have a few panels that constist of 2 wxStaticBoxSizers with different content inside.
I dynamically hide one of these wxStaticBoxSizers depending on a wxChoice.
A do a panel->Layout() to reduce the size of the panel (as it has to shrink/expand after hinding one of the wxStaticBoxSizers).
This works fine until wxWidgets 3.x

Now the panel stays always at the same size.
How can this be fixed without setting a manual fixed size?

Re: Resize Panel after hiding wxStaticBoxSizer

Posted: Tue Feb 24, 2015 5:27 pm
by tierra
Are the two wxStaticBoxSizers contained in another sizer (either vertical or horizontal box sizer, orientation doesn't matter)?

Another approach is to use the new wxSimpleBook control, which is mean to change pages like a wxNoteook, but without using tabs at all, and only switching pages internally with code.

Re: Resize Panel after hiding wxStaticBoxSizer

Posted: Tue Feb 24, 2015 6:42 pm
by DenDev
If you have a panel that contains a sizer and the sizer contains the two static boxes then you need to do two things: 1) Make sure that both sizer cells are "growable", and 2) Whenever you show/hide a static box you must call sizer->Fit(panel) which will adjust the panels size according to its content.

Re: Resize Panel after hiding wxStaticBoxSizer

Posted: Tue Feb 24, 2015 7:01 pm
by Samfox2
Thanks for your quick answers.
I will try that, just to make it a bit clearer:

The 2 StaticBoxSizers (vertical) which both hold different Controls are in a BoxSizer (vertical) which is attached to a Panel.
I mostly need (context sensitive) just one of the StaticBoxSizers at a time, but in one case I need both of them shown at the same time. So I need different scenarios (hiding/showing) and the Panel should automatically resize.

Re: Resize Panel after hiding wxStaticBoxSizer

Posted: Wed Feb 25, 2015 3:54 am
by tierra
Samfox2 wrote:but in one case I need both of them shown at the same time
Oh, forget about wxSimplebook then, it doesn't do that.

Nothing about your descriptions so far though sound impossible. Usually just takes the appropriate calls to the various Layout() and Fit() methods on the top level window containing the main panel after hiding/showing either of them.

Re: Resize Panel after hiding wxStaticBoxSizer

Posted: Wed Feb 25, 2015 9:09 am
by Samfox2

Code: Select all

sizer->Fit(panel)
solved the problem, thx!