GUI update calls on expand/hide

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.
thoray
Knows some wx things
Knows some wx things
Posts: 48
Joined: Sun Oct 18, 2015 9:31 am

GUI update calls on expand/hide

Post by thoray »

I seem to be at loss on what to call and for which window when GUI elements are expanded/collapsed or hidden.

First, I have wxCollapsiplePane inside boxsizer that is inside wxScrolledWindow that is inside wxSplitterWindow.

It all works fine if I manually call Layout() for the scrolledwindow when collapsing/expanding the pane. However, if I call Expand() for the collapsiplepane right after creating the object, then no matter what I've tried the then by default shown contents of the collapsiplepane are way too wide horizontally initially which adds a horizontal scrollbar to the scrolledwindow. This is only fixed by moving the sash of the splitterwindow. What should I call to fix that?

Second, I have wxColourPickerCtrl inside the collapsiplepane. If I call Show(false) for the colourpickerctrl, then the ctrl is hidden and other elements inside the collapsiplepane take its space when I manually call Layout() for the window returned by GetPane(). However, the collapsiplepane doesn't release the space the now hidden control has freed until I manually collapse and then expand the collapsiplepane. What should I call to fix that?

Thanks.
thoray
Knows some wx things
Knows some wx things
Posts: 48
Joined: Sun Oct 18, 2015 9:31 am

Re: GUI update calls on expand/hide

Post by thoray »

I finally took the time to find solutions to these problems so I will answer myself.
thoray wrote: First, I have wxCollapsiplePane inside boxsizer that is inside wxScrolledWindow that is inside wxSplitterWindow.

If I call Expand() for the collapsiplepane right after creating the object, then no matter what I've tried the then by default shown contents of the collapsiplepane are way too wide horizontally initially which adds a horizontal scrollbar to the scrolledwindow. This is only fixed by moving the sash of the splitterwindow. What should I call to fix that?
The solution was to move the collapsiplepane Expand() call at a later stage, outside from the main frame constructor, and following it by FitInside() call to the containing scrolledwindow.
thoray wrote: Second, I have wxColourPickerCtrl inside the collapsiplepane. If I call Show(false) for the colourpickerctrl, then the ctrl is hidden and other elements inside the collapsiplepane take its space when I manually call Layout() for the window returned by GetPane(). However, the collapsiplepane doesn't release the space the now hidden control has freed until I manually collapse and then expand the collapsiplepane. What should I call to fix that?
The solution was to first call FitInside() for the window returned by collapsiple pane's GetPane(), and then call Collapse() followed by Expand() for the collapsiplepane, and finally calling FitInside() for the containing scrolledwindow.

I also had a problem that a wxSlider (and all other elements) inside the collapsiplepane didn't properly downsize when the scrolledwindow got a scrollbar added due another collapsiplepane expanding, and instead the right side of the slider got hidden under the scrollbar. The only way I could fix that was to first apply the latter solution for each collapsiplepane at function called by EVT_COLLAPSIBLEPANE_CHANGED and after that send wxSplitterEvent to the splitterwindow which again applied the latter solution to all collapsiplepanes at a function called by EVT_SPLITTER_SASH_POS_CHANGED.

I'd still be curious if there would be more proper solutions to some of the problems. I don't know why the Expand() had to be called outside the main frame's constructor, or why I need to call Collapse() followed by Expand() for collapsiplepanes to get them properly update with contents or why I need the complicated update to make sure contents of collapsiplepanes can't end up under containing window's scrollbar.