Resize Panel after hiding wxStaticBoxSizer Topic is solved

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
Samfox2
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Feb 24, 2015 3:08 pm

Resize Panel after hiding wxStaticBoxSizer

Post by Samfox2 » Tue Feb 24, 2015 3:21 pm

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?

User avatar
tierra
Site Admin
Site Admin
Posts: 1342
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Re: Resize Panel after hiding wxStaticBoxSizer

Post by tierra » Tue Feb 24, 2015 5:27 pm

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.

DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

Re: Resize Panel after hiding wxStaticBoxSizer

Post by DenDev » Tue Feb 24, 2015 6:42 pm

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.
I have a bad habbit of not testing the code I post :D

Samfox2
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Feb 24, 2015 3:08 pm

Re: Resize Panel after hiding wxStaticBoxSizer

Post by Samfox2 » Tue Feb 24, 2015 7:01 pm

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.

User avatar
tierra
Site Admin
Site Admin
Posts: 1342
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Re: Resize Panel after hiding wxStaticBoxSizer

Post by tierra » Wed Feb 25, 2015 3:54 am

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.

Samfox2
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Feb 24, 2015 3:08 pm

Re: Resize Panel after hiding wxStaticBoxSizer

Post by Samfox2 » Wed Feb 25, 2015 9:09 am

Code: Select all

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

Post Reply