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.
deepti
Experienced Solver
Experienced Solver
Posts: 59
Joined: Tue Jul 17, 2018 5:38 pm

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

Postby deepti » Thu Aug 09, 2018 7:16 pm

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: 2687
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Postby ONEEYEMAN » Thu Aug 09, 2018 7:40 pm

Hi,
Do you use sizers?

Thank you.

deepti
Experienced Solver
Experienced Solver
Posts: 59
Joined: Tue Jul 17, 2018 5:38 pm

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

Postby deepti » Thu Aug 09, 2018 7:45 pm

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: 12690
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Postby doublemax » Thu Aug 09, 2018 8:05 pm

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
Experienced Solver
Experienced Solver
Posts: 59
Joined: Tue Jul 17, 2018 5:38 pm

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

Postby deepti » Fri Aug 10, 2018 6:06 am

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 136 times

User avatar
doublemax
Moderator
Moderator
Posts: 12690
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Postby doublemax » Fri Aug 10, 2018 8:19 am

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
Experienced Solver
Experienced Solver
Posts: 59
Joined: Tue Jul 17, 2018 5:38 pm

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

Postby deepti » Fri Aug 10, 2018 10:50 am

@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: 1714
Joined: Sun Jan 03, 2010 5:45 pm

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

Postby PB » Fri Aug 10, 2018 11:27 am

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


Return to “C++ Development”

Who is online

Users browsing this forum: Bing [Bot], wxJack and 19 guests