Another 3.0 upgrade problem

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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Another 3.0 upgrade problem

Post by ONEEYEMAN »

Hi, ALL,
In our codebase we have a code like following:

Code: Select all

    wxStaticBox *itemFix1 = new wxStaticBox( parent, -1, "" );
    itemFix1->Show(false);
    wxStaticBoxSizer *itemFix2 = new wxStaticBoxSizer( itemFix1, wxHORIZONTAL );
    
    wxStaticBox *itemFix3 = new wxStaticBox( parent, -1, "" );
    itemFix3->Show(false);
    wxStaticBoxSizer *itemFix4 = new wxStaticBoxSizer( itemFix3, wxHORIZONTAL ); 

    wxButton *item6 = new wxButton( parent, ID_ANY, "Some text", wxDefaultPosition, wxDefaultSize, 0 );
    itemFix2->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
Now this code works fine in 2.8.10. However when I upgraded to 3.0, the static boxes disappear and the button is not positioned correctly.

I can probably remove the call to Show( false ), but just wondering whether anybody see this before?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19164
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Another 3.0 upgrade problem

Post by doublemax »

Now this code works fine in 2.8.10. However when I upgraded to 3.0, the static boxes disappear and the button is not positioned correctly.
wxStaticBox disappearing after you Hide them seems correct to me. Or am i missing something here?

What's the point in hiding them anyway? A wxStaticBoxSizer with a hidden wxStaticBoxSizer should be the same as a normal wxBoxSizer.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Another 3.0 upgrade problem

Post by ONEEYEMAN »

doublemax,
doublemax wrote:
Now this code works fine in 2.8.10. However when I upgraded to 3.0, the static boxes disappear and the button is not positioned correctly.
wxStaticBox disappearing after you Hide them seems correct to me. Or am i missing something here?
Yes, a second part of the statement - and the button is not positioned correctly.
doublemax wrote: What's the point in hiding them anyway? A wxStaticBoxSizer with a hidden wxStaticBoxSizer should be the same as a normal wxBoxSizer.
Don't know. Removing Show( false ); makes the layout works again, but then the static boxes are visible.
I guess its just an aesthetics.

Thank you.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: Another 3.0 upgrade problem

Post by Manolo »

Try setting wxRESERVE_SPACE_EVEN_IF_HIDDEN flag to those items that can be hidden.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Another 3.0 upgrade problem

Post by PB »

The code seems rather convoluted to me, just as doublemax said...

itemFix1 is a wxStaticBox with parent as the parent and is hidden.
itemFix2 is a wxStaticBoxSizer created with itemFix1 as the parent.
item6 is a wxButton with parent as the parent and is added to itemFix2 sizer.

Does it even make sense to have the button visible when a static box which it is a part of is hidden?