Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#18350 closed defect (invalid)

wxGridSizer::Hide individual child widgets wont cause it to resize even after calling wxGridSizer::Layout!

Reported by: tomay3000 Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 3.1.2
Keywords: Cc: tomay3000@…
Blocked By: Blocking:
Patch: no

Description

a simple test frame with (wxGridSizer with some random child widgets) inside another wxStaticBoxSizer.

When calling wxGridSizer::Hide for some widget list in the bottom of it wxGridSizer::Hide followed by wxGridSizer::Layout will hide the expected child widgets but it wont resize, I even tried calling the parent sizer layout: wxStaticBoxSizer::Layout.

The only solution that worked for me is hiding the entire wxGridSizer child from the parent one: wxStaticBoxSizer::Hide(The_Child_Grid_Sizer).

But I needed to hide only some widgets in the bottom of the sizer not all of them.

NB: Using wxStaticBoxSizer is to be able to see the static line area.

Attachments (3)

minimal.diff download (7.9 KB) - added by tomay3000 9 months ago.
minimal.2.diff download (7.9 KB) - added by tomay3000 9 months ago.
This is the correct diff one
Untitled.jpg download (76.3 KB) - added by tomay3000 9 months ago.

Download all attachments as: .zip

Change History (9)

comment:1 follow-up: Changed 9 months ago by vadz

  • Status changed from new to infoneeded_new

Could you please provide the minimal (i.e. avoiding any superfluous sizers not necessary to trigger the problem) patch to the minimal sample allowing to reproduce the problem? AFAICS what you're describing should work, i.e. Layout() shouldn't account for the hidden children unless they explicitly use the reserve-space-even-if-hidden style.

comment:2 in reply to: ↑ 1 Changed 9 months ago by tomay3000

  • Cc tomay3000@… added
  • Status changed from infoneeded_new to new

Replying to vadz:

Could you please provide the minimal (i.e. avoiding any superfluous sizers not necessary to trigger the problem) patch to the minimal sample allowing to reproduce the problem? AFAICS what you're describing should work, i.e. Layout() shouldn't account for the hidden children unless they explicitly use the reserve-space-even-if-hidden style.

I have uploaded a minimal.2.diff file

Last edited 9 months ago by tomay3000 (previous) (diff)

Changed 9 months ago by tomay3000

Changed 9 months ago by tomay3000

This is the correct diff one

comment:3 Changed 9 months ago by vadz

There seem to be a couple of lines of apparently auto-generated code in this diff, making it rather hard to read, so I'm not too sure about this, but I wonder if you're not just calling Layout() on a wrong sizer: you do realize that calling gSizer8->Layout() will never change the size allocated to this sizer itself, as it's determined by its parent and that you need to use sbSizer10->Layout() if this is what you really want to do?

comment:4 Changed 9 months ago by tomay3000

  • Cc tomay3000@… removed

I already said in the first post that even calling sbSizer10->Layout() did not help.
Take a look at the screenshot I uploaded to understand what I mean.
The wxStaticBoxSizer should shrink to fit.

Last edited 9 months ago by tomay3000 (previous) (diff)

Changed 9 months ago by tomay3000

comment:5 Changed 9 months ago by vadz

  • Resolution set to invalid
  • Status changed from new to closed

OK, sorry, I was misled by the bug title. It's not that calling Layout() doesn't cause the sizer to _re_ size, it does. It's just that wxGridSizer always uses the same size for all its rows and columns and this doesn't change even if all the elements of the same row (or of the same column) are hidden. I.e. it behaves exactly the same even if you hide the items from the very beginning.

If you want the sizer to adapt, just use wxFlexGridSizer instead which is, well, flexible. Granted, wxGridSizer behaviour may not seem to be very useful, but this is what it does. And it's true that in 99% of cases you want to use wxFlexGridSizer instead.

comment:6 Changed 9 months ago by tomay3000

  • Cc tomay3000@… added

Mmm, OK.
Thank you for the info.
I think that there should be a note in the documentation.

Note: See TracTickets for help on using tickets.