Sizer's question

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
Morat20
Knows some wx things
Knows some wx things
Posts: 32
Joined: Tue Jan 07, 2014 8:43 pm

Sizer's question

Post by Morat20 » Wed Jan 30, 2019 12:30 am

Is it possible to change a sizer's flags after the creation of a sizer? Say I wanted a horizontal BoxSizer to expand only under certain circumstances, or wanted to add and remove the wxRESERVE_SPACE_EVEN_IF_HIDDEN flag?

Secondly, what are the limitations of the wxRESERVE_SPACE_EVEN_IF_HIDDEN? Will it reserve the space if the control is hidden? The sizer hidden? The panel hidden? Is there a way to override it, or will it reserve space no matter what?

rando
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri Nov 09, 2018 9:11 pm

Re: Sizer's question

Post by rando » Wed Jan 30, 2019 3:55 pm

Morat20 wrote:Is it possible to change a sizer's flags after the creation of a sizer? Say I wanted a horizontal BoxSizer to expand only under certain circumstances, or wanted to add and remove the wxRESERVE_SPACE_EVEN_IF_HIDDEN flag?
I am not sure about the wxRESERVE_SPACE_EVENT_IF_HIDDEN flag but you can certainly change proportions during program execution. Check out the layout sample, in particular

Code: Select all

void MyProportionsFrame::UpdateProportions()

You could add some code to that sample to test toggling wxRESERVE_SPACE_EVENT_IF_HIDDEN, you will need to call Layout() after setting the flag to see the effect.
Morat20 wrote:Secondly, what are the limitations of the wxRESERVE_SPACE_EVEN_IF_HIDDEN? Will it reserve the space if the control is hidden? The sizer hidden? The panel hidden? Is there a way to override it, or will it reserve space no matter what?
It will reserve all of the space required for all of the items contained in the sizer regardless of the IsShown() state of any of those items.

Morat20
Knows some wx things
Knows some wx things
Posts: 32
Joined: Tue Jan 07, 2014 8:43 pm

Re: Sizer's question

Post by Morat20 » Wed Jan 30, 2019 4:23 pm

Thanks. That covered what I needed to move forward and saved me a few hours of experimentation.

Honestly, the ideal solution to the legacy issue I'm facing would beto use z-order positioning with two separate panels and just swap which one is top, but I don't think I can do that in wxWidgets inside a single notebook tab. (One notebook tab, two panels of identical size)

It looks like I'll have to dynamically deconstruct and reconstruct a chunk of the sizers instead.

rando
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri Nov 09, 2018 9:11 pm

Re: Sizer's question

Post by rando » Wed Jan 30, 2019 6:14 pm

Sure you can, just Hide()the current page, call Remove() on it, then call Add() on the other page and Show().
I often keep "stacks" of hidden windows and swap them in/out of notebook pages as needed.

Post Reply