Cannot refresh the window when Show/Hide a panel

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
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Cannot refresh the window when Show/Hide a panel

Post by Parduz »

I'm fighting from longtime with hiding/showing controls and refreshing/realigning the app window. I think i'm missing something important, and i would like to finally learn to handle these kind of behaviour.

The attached .cpp files shows a portion of a very complex "kiosk" app. It should compile alone and should look like this (screenshot taken on Win10, but the problem exists on Debian also):
01.jpg
01.jpg (13.17 KiB) Viewed 1589 times
When clicking on one of the menu, a panel should appear at the bottom of the window, but instead you nothing (if not that tiny part of a button in the corner)
02.jpg
02.jpg (13.76 KiB) Viewed 1589 times
... continuing on the next post as i can't attach more image.
Attachments
TestDebug_HidePanels.cpp
(20.79 KiB) Downloaded 98 times
Last edited by Parduz on Wed Feb 01, 2023 4:09 pm, edited 1 time in total.
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Cannot refresh the window when Show/Hide a panel

Post by Parduz »

The bottom panel becomes visible only if i resize the window (a thing that i cannot do even with code in the deployement field as the form is borderless and maximized)
03.jpg
03.jpg (18.61 KiB) Viewed 1588 times
When clicking again on the menu items the panel should get hidden again, but this is what i got (unless i resize again)
04.jpg
04.jpg (14.87 KiB) Viewed 1588 times

On the very bottom of the source file there's all i've tried to fix it without any result.

What should i do?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cannot refresh the window when Show/Hide a panel

Post by doublemax »

Usually when resizing the outer frame fixes the layout, just a Layout() call on the topmost sizer will do the trick.
But as you're already doing it, there must be something else going on.
You could try calling SendSizeEvent() on the outer frame.

Otherwise, I'm not going to debug 200 lines of pure sizer code. Please strip it down to the absolute minimum to reproduce the issue.

General advice: A sizer that only contains one element usually doesn't make any sense. And i see quite a few of those.
Use the source, Luke!
User avatar
Parduz
I live to help wx-kind
I live to help wx-kind
Posts: 188
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Cannot refresh the window when Show/Hide a panel

Post by Parduz »

doublemax wrote: Wed Feb 01, 2023 4:57 pm Usually when resizing the outer frame fixes the layout, just a Layout() call on the topmost sizer will do the trick.
But as you're already doing it, there must be something else going on.
You could try calling SendSizeEvent() on the outer frame.
Ok, i'll try ASAP.
doublemax wrote: Wed Feb 01, 2023 4:57 pm Otherwise, I'm not going to debug 200 lines of pure sizer code. Please strip it down to the absolute minimum to reproduce the issue.
Now, this is a bit hard, not 'cause i don't want but 'cause i don't know how to do it.
The full story is that i make my app UI using wxCrafter, and what's in the code i posted here is just the single .... "branch" relevant to the problem. I mean: i've removed everything else that was not parent/sibling of the panel that has to be hidden (i'm talking about a dozen of pages and a tenth of sub-pages of equal complexity).
page_03_branch.jpg
(this is my whole app: the page 03/sub bitmap is the only branch i've put in the code attached)

The fun (or tragic) part is that this code was planned to be the WORKING sample, because in my app this works! The show/hide panel ceased to work when i changed all the "topmost" labels and textboxes with the wxstyledtextcontrol we already talked about in one of my recent threads.
I was preparing 2 code samples, basically identical apart for that controls, and asking why one works and the other one not. I was not expecting to have the problem appearing with THIS code.

Which gives me the idea that whatever i touch/change can make it works without really knowing what was the real problem (and this is exactly why i'm fighting with this kind of problems from longtime: sometime things just starts working and i can't track down what of the many unrelated changes in the UI i've made "solved" it, sometime a bunch of "layout" calls solves it. My impression is that i "mask", or "patch" the real problem, not "understanding and solving" it).
doublemax wrote: Wed Feb 01, 2023 4:57 pm General advice: A sizer that only contains one element usually doesn't make any sense. And i see quite a few of those.
Usually i do this 'cause alignement: wxStaticText can be centered on the containers only using a sizer... AFAIK. Am i wrong?
Post Reply