GUI Components not hidden on switching panels

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
jgoodchild
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jul 28, 2016 9:09 am

GUI Components not hidden on switching panels

Post by jgoodchild » Wed May 08, 2019 3:25 pm

I am porting an application from Linux to Windows. On Linux, it works as intended, but on Windows I am getting some unwanted effects, with some GUI components (such as buttons) being displayed on the screen, albeit behind other components, when they are supposed to be hidden.

The application has multiple "pages", which are each based on wxPanels. Because the panels share the same portion of the screen display, only one of the "pages" is supposed to be displayed at any one time. Switching pages occurs mainly as a result of a GUI event (such as a button press).

What's happening on switching pages is that some of the components belonging to one panel remain on the screen, underneath the components for the newly displayed page. On switching back, however, things are displayed correctly.

It looks like it is order sensitive. The page objects are all held in an array, and when a page switch occurs, an update interface function is called for each of the objects, always in the same order, instructing them whether they should be showing or hiding themselves. When page 1 switches to page 2, the components belonging to page 1 get hidden successfully, presumably because page 2 remains in a hidden state until after page 1 is hidden. When switching from page 2 to page 1, however, the update to show page 1 gets called before page 2 is hidden, and parts of page 2 remain visible.

Am I correct that something specific to Windows is making this sort of operation order sensitive?
Or do I have some other sort of problem lurking?

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

Re: GUI Components not hidden on switching panels

Post by doublemax » Wed May 08, 2019 4:14 pm

The application has multiple "pages", which are each based on wxPanels. Because the panels share the same portion of the screen display,
Are you saying they're all lying on top of each other at the same coordinates? That would be bad.

Use wxSimplebook:
https://docs.wxwidgets.org/trunk/classw ... ebook.html
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3324
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: GUI Components not hidden on switching panels

Post by ONEEYEMAN » Wed May 08, 2019 6:58 pm

Hi,
Can you show some code and maybe a screenshot?

Thank you.

jgoodchild
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jul 28, 2016 9:09 am

Re: GUI Components not hidden on switching panels

Post by jgoodchild » Thu May 09, 2019 10:06 am

doublemax wrote:
Wed May 08, 2019 4:14 pm
Are you saying they're all lying on top of each other at the same coordinates? That would be bad.
Yes, that is exactly what I am saying, and yes, I am experiencing varying forms of badness. Or at least, I am on Windows; on Linux, it seems to work well enough.

Thank you for the suggestion of wxSimpleBook, of which I guess the original designer of the program was not aware. I will investigate whether I can make use of it without a major redesign...

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

Re: GUI Components not hidden on switching panels

Post by doublemax » Thu May 09, 2019 10:25 am

Thank you for the suggestion of wxSimpleBook, of which I guess the original designer of the program was not aware. I will investigate whether I can make use of it without a major redesign...
Alternatively, just put all panels in a wxBoxsizer and call Layout() after you changed the visibility of the panels.
Use the source, Luke!

jgoodchild
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jul 28, 2016 9:09 am

Re: GUI Components not hidden on switching panels

Post by jgoodchild » Fri May 10, 2019 10:19 am

doublemax wrote:
Thu May 09, 2019 10:25 am
Alternatively, just put all panels in a wxBoxsizer and call Layout() after you changed the visibility of the panels.
Having figured that using a wxBoxSizer should be a much simpler change for me than using wxSimpleBook, I gave it a go first. I assume that I should just create the wxBoxSizer, and then add each of the wxPanels corresponding to my pages to the sizer after creating each page.

However, when I switch page and call Layout(), the whole screen goes completely blank, even the part of the screen outside of the area of the pages. So it would seem there's something else I should be doing in addition.

I guess I will need to look into wxSimpleBook instead...

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

Re: GUI Components not hidden on switching panels

Post by doublemax » Fri May 10, 2019 10:56 am

However, when I switch page and call Layout(), the whole screen goes completely blank, even the part of the screen outside of the area of the pages. So it would seem there's something else I should be doing in addition.
That should have worked. Can you show some code that shows the sizer structure?
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3324
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: GUI Components not hidden on switching panels

Post by ONEEYEMAN » Fri May 10, 2019 2:34 pm

Hi,
And how do you hide/show different panels and its creation?

Thank you.

jgoodchild
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jul 28, 2016 9:09 am

Re: GUI Components not hidden on switching panels

Post by jgoodchild » Wed May 15, 2019 11:12 am

I haven't had the time to simplify the code sufficiently to be able to post any (I am working on a number of other things), but I now suspect that the problem was related to the fact that I was not calling SetSizer().

Basically, I have a Frame occupying the whole screen, and a panel which is almost always present at the top of the screen, occupying the top 10%. The remaining 90% is where I have the pages, which are created as panels on the frame. I am now adding each of these panels to the new sizer I have created, but my problem is what I should associate the sizer with - I don't think the frame is the correct place.

Instead, I assume that I need to create a new base panel to occupy the bottom 90% of the screen, create my pages on that panel instead of on the frame, and then call SetSizer() on the base panel.

So that's my plan - but it requires me to reorganize the code a bit, which will probably take me a while (mainly due all of the other claims on my time!). If that doesn't work, I will try to produce a simplified program illustrating what I am trying to do, and then post the source.

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

Re: GUI Components not hidden on switching panels

Post by doublemax » Wed May 15, 2019 1:05 pm

I am now adding each of these panels to the new sizer I have created, but my problem is what I should associate the sizer with
You can add a sizer into another sizer, in that case it doesn't have to be assigned to a window.

Based on your description, i think you need a sizer structure like this:

Code: Select all

frame
  wxBoxSizer(Vertical)
    top panel
    wxBoxSizer(Horizontal)
      panel1
      panel2
      panel3
      panel4
All panels are children of the frame.
Use the source, Luke!

Post Reply