Page 1 of 1

wxNotebook with 4 pages - how to manage change in height?

Posted: Thu Aug 09, 2018 7:16 pm
by deepti
I have an instance of "wxNotebook", with 4 pages in it. Previously, all 4 pages were adjusted to be of the same height by manipulating the height of the controls in each page.
But now, I added a few more controls in one of the pages. This increased the height of the remaining 3 pages as well. But it looks odd, since there is only extra space being added at the end, just to make the height of all pages the same.
Is there a way to let this happen automatically, without me having to increase the height of the controls in the remaining pages each time some new control is added to one of the pages?

Please help!

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Thu Aug 09, 2018 7:40 pm
by ONEEYEMAN
Hi,
Do you use sizers?

Thank you.

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Thu Aug 09, 2018 7:45 pm
by deepti
Hi,

Yes, every page has an associated sizer. And the notebook itself also has a sizer associated.

Thank you!

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Thu Aug 09, 2018 8:05 pm
by doublemax
Previously, all 4 pages were adjusted to be of the same height by manipulating the height of the controls in each page.
If hope you don't mean simple controls like buttons and textboxes that are supposed to have a standard height.

For other controls setting the proportion parameter and wxEXPAND flag correctly should do the trick. I can't be more specific without seeing the layout.

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Fri Aug 10, 2018 6:06 am
by deepti
Please see the screenshot below (sorry had to blur out some parts since its our official app). The arrow shows the extra space which has cropped up after adding new controls to another page. Is there a way the listbox and other controls at the right (static texts and buttons) can automatically place themselves according to the height of the page, instead of having to re-adjust the height of each control whenever new controls are added to another page? Please help!

And this is how the listbox is created:
wxBoxSizer* boxSizerNetworkFolderList = new wxBoxSizer(wxHORIZONTAL);
m_panelNetworkFolderControls->SetSizer(boxSizerNetworkFolderList);

wxArrayString m_listBoxNetworkFoldersArr;
m_listBoxNetworkFolders = new wxListBox(m_panelNetworkFolderControls, ID_NETWORKFOLDER_LIST, wxDefaultPosition, wxSize(250,320),
m_listBoxNetworkFoldersArr, wxLB_HSCROLL|wxLB_SINGLE|wxLB_SORT);

boxSizerNetworkFolderList->Add(m_listBoxNetworkFolders, 0, wxALL|wxEXPAND, 5);

Notebook-height.jpg
Notebook-height.jpg (41.57 KiB) Viewed 1429 times

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Fri Aug 10, 2018 8:19 am
by doublemax
You have to consider the whole sizer structure from the top.

Assuming the toplevel sizer is a vertical boxsizer, and there is another horizontal boxsizer that contains the listbox and the controls next to it:

- add the listbox sizer to the toplevel sizer with a proportion of "1". This makes just that this sizer expands to the bottom.

- when adding the listbox to the listbox sizer, add the wxEXPAND flag, so it expands in the vertical direction.

You're already doing the second thing, so i guess you didn't set the proportion in the first step.

I don't understand what you want to happen with the controls on the right. They can't grow to the bottom in a sensible way, i would keep them as they are.

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Fri Aug 10, 2018 10:50 am
by deepti
@doublemax, thanks a lot for your response.
Setting the proportion to 1 helped the listbox expand till the bottom.
Isn't there anything we can do with the remaining controls at the right? Introducing an empty static text between the controls seems to be the only way to me..so that they are evenly spaced out, instead of too much space at the bottom.
Is there a better way than this?

Re: wxNotebook with 4 pages - how to manage change in height?

Posted: Fri Aug 10, 2018 11:27 am
by PB
deepti wrote:Isn't there anything we can do with the remaining controls at the right? Introducing an empty static text between the controls seems to be the only way to me..so that they are evenly spaced out, instead of too much space at the bottom.
Is there a better way than this?
Firstly, I agree with doublemax that leaving those control alone is probably the best idea.

But, if you still want to space them over the area, what about using expandable spacers (wxSizer::AddStretchSpacer())?