wxAuiNotebook Vertical Scrolling

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
SalmonsSteve
Knows some wx things
Knows some wx things
Posts: 27
Joined: Sun Jun 24, 2012 6:00 pm

wxAuiNotebook Vertical Scrolling

Post by SalmonsSteve »

I am working on an application in which I would like to use an AuiNotebook and I have run into a problem. On one tab of the notebook I need to have a 6 wide x 202 tall grid of controls. The first two rows will be static text controls and then the rows will have a uniform layout of one wxStaticText, 3 wxComboBox controls, and 2 wxTextCtrls. I am creating the layout by first creating a wxPanel, then a vertical wxBoxSizer, and then a wxGridSizer. All of the controls are created using the panel as their parent and then loaded into the GridSizer. The GridSizer is then added to the BoxSizer. The panel's sizer is set to be the BoxSizer and finally, the panel is added to the notebook using AddPage. The layout looks good but at runtime I am only able to see the first 16 rows of controls, which was expected really. This is fine as I don't want 202 rows of controls on screen at once but the problem is that I do not get a vertical scrollbar on the notebook. I have tried using wxAUI_NB_SCROLL_BUTTONS (which I suspect is to scroll when you have many tabs rather than adding scrollbars). I have tried using a wxScrolledWindow instead of a wxPanel, and I have tried setting the style of the wxPanel to wxVSCROLL. Only the last one of those actually creates a scrollbar but the scrollbar position indicator always returns to the top after being dragged down and never actually scrolls. I am a little bit puzzled as to why the wxScrolledWindow does not create a scrollbar to tell you the truth. I have looked at the Aui sample and it seems that a scrollbar appears when a control is added directly as a page to the notebook but on the notebook page where a panel is added as the page there is no scrollbar (and none is really needed on that example page).

So to clarify, my question is how would I get a vertical scrollbar onto an auinotebook page? Is this going to be something that I am going to have to implement myself or is there some way to get that panel to scroll appropriately? I hope that I have explained clearly enough what I am doing and my desired outcome.

I have not yet explored the option of using a wxGrid and loading cells with wxComboBoxes. Is that even possible and if so would that eliminate the need for sizers and the panel allowing me to just add a control to the notebook as a page (which I assume would give me the scrollbar)?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAuiNotebook Vertical Scrolling

Post by doublemax »

Using a wxScrollBar instead of wxPanel should work. Did you call SetAutoLayout(true) and SetScrollRate() ?

For a test, you should also try a "normal" wxNoteBook, the wxAUI* classes behave a little different at times.
Use the source, Luke!
SalmonsSteve
Knows some wx things
Knows some wx things
Posts: 27
Joined: Sun Jun 24, 2012 6:00 pm

Re: wxAuiNotebook Vertical Scrolling

Post by SalmonsSteve »

I have not tried using a wxScrollBar as I was hoping to avoid having to write code for dealing with the scrolling events if it was already written and built into something else. I had considered changing directions and using wxNoteBook or even a wxScrolledWindow rather than using the AuiNoteBook. I am exploring those options today. I will provide an update when I either find a way to make this work with an AuiNoteBook or with some other type of window. Luckily I am only on the 2nd of 6 child windows that need to be written using a consistent look so I definitely could have run into this issue at a much worse time.

As a side note, I do suspect that using a wxScrollBar would work fine and if need be I will go that route. Like I said, I am just trying to avoid having to write the code for handling all the scroll events. If I end up going that way I think I will likely derive from AuiNoteBook and add in the code for including scrollbars on the notebook then use that newly derived class as the basis for my notebooks. That's probably the right way to do things.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxAuiNotebook Vertical Scrolling

Post by doublemax »

Sorry, i meant wxScrolledWindow instead of wxPanel, not wxScrollBar.
Use the source, Luke!
JohnDTill
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Mar 16, 2021 3:04 pm

Re: wxAuiNotebook Vertical Scrolling

Post by JohnDTill »

I think I encountered the same problem. Nesting a wxScrolledWindow inside a wxAuiNotebook worked in wx3.1 on Windows, but not wx2.8 on Linux. The problem appears to be that in wxGTK2.8, the wxScrolledWindow GetSize() would not shrink below the minimum size, even when the wxAuiNotebook size was smaller, so the GetSize() would never be smaller than the GetVirtualSize() and the scrollbars would never appear. The solution was to call SetMinSize(wxSize(1,1)) on the wxScrolledWindow.

Of course also call wxScrolledWindow::SetScrollRate(1, 1) in both versions.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxAuiNotebook Vertical Scrolling

Post by ONEEYEMAN »

Hi,
Why do you work with the {very outdated} version of the library on Linux, but different version on Windows?
Can you check if wxWidgets 3.1 (or even Git master) suffers from this on both platforms?

Thank you.
rando
Knows some wx things
Knows some wx things
Posts: 35
Joined: Fri Nov 09, 2018 9:11 pm

Re: wxAuiNotebook Vertical Scrolling

Post by rando »

Using wxWidgets 3.1.3

I use almost exactly the same setup and have no problems with scrolling. My wxAuiNotebook page base is derived from wxScrolled, uses a wxFlexGridSizer, and has a wxCollapsiblePane control in addition to the other buttons, text boxes, and etc. When the collapsible pane is toggled, sizing is correct and scrollbars are shown.

Code: Select all

class MyCustomAuiPage:public wxScrolled<wxPanel> {/*...*/};
At the end of the panel constructor call wxWindow::FitInside() and all should work.
Make sure to call Layout() as appropriate, such as when hiding/showing controls.

For me, that is all that is needed for everything to work correctly. I have some pages where I show/hide controls and those also work correctly with automatic scrollbars.

I have found that many problem I encountered while developing MyCustomAuiPage were caused by trying to do too much manually. Instead of trying to anticipate what will be needed just do the minimum to get the display and usually only have to do some minor change such as the FitInside() call.
Post Reply