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

71 views
Skip to first unread message

wxTrac

unread,
Mar 4, 2019, 9:22:31 PM3/4/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
-----------------------+--------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Keywords: | Blocked By:
Blocking: | Patch: 0
-----------------------+--------------------
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.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350>

wxTrac

unread,
Mar 5, 2019, 11:35:36 AM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+----------------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: infoneeded_new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+----------------------------
Changes (by vadz):

* status: new => infoneeded_new


Comment:

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.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350#comment:1>

wxTrac

unread,
Mar 5, 2019, 4:38:07 PM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+-------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+-------------------
Changes (by tomay3000):

* status: infoneeded_new => new
* cc: tomay3000@… (added)


Comment:

Replying to [comment:1 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.diff''' file

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350#comment:2>

wxTrac

unread,
Mar 5, 2019, 4:38:32 PM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+-------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+-------------------
Changes (by tomay3000):

* Attachment "minimal.diff" added.

wxTrac

unread,
Mar 5, 2019, 4:45:12 PM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+-------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+-------------------
Changes (by tomay3000):

* Attachment "minimal.2.diff" added.

This is the correct diff one

wxTrac

unread,
Mar 5, 2019, 5:34:27 PM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+-------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+-------------------

Comment (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?

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350#comment:3>

wxTrac

unread,
Mar 5, 2019, 6:10:06 PM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+-------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+-------------------
Changes (by tomay3000):

* cc: tomay3000@… (removed)


Comment:

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.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350#comment:4>

wxTrac

unread,
Mar 5, 2019, 6:10:26 PM3/5/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+-------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+-------------------
Changes (by tomay3000):

* Attachment "Untitled.jpg" added.

wxTrac

unread,
Mar 20, 2019, 11:18:51 PM3/20/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+--------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: closed
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: invalid | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+--------------------
Changes (by vadz):

* status: new => closed
* resolution: => invalid


Comment:

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.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350#comment:5>

wxTrac

unread,
Mar 21, 2019, 5:18:55 PM3/21/19
to wx-...@googlegroups.com
#18350: wxGridSizer::Hide individual child widgets wont cause it to resize even
after calling wxGridSizer::Layout!
------------------------+--------------------
Reporter: tomay3000 | Owner:
Type: defect | Status: closed
Priority: normal | Milestone:
Component: wxMSW | Version: 3.1.2
Resolution: invalid | Keywords:
Blocked By: | Blocking:
Patch: 0 |
------------------------+--------------------
Changes (by tomay3000):

* cc: tomay3000@… (added)


Comment:

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

--
Ticket URL: <https://trac.wxwidgets.org/ticket/18350#comment:6>
Reply all
Reply to author
Forward
0 new messages