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

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
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

Hi,
Do you use sizers?

Thank you.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post by deepti »

Hi,

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

Thank you!
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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.
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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 1428 times
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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.
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

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

Post 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?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

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

Post 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())?
Post Reply