Page 1 of 1

wxFlexGridSizer row height proportions

Posted: Tue Jan 08, 2019 8:32 pm
by Victory
Is there any way to specify the proportion of vertical space taken up by each row in wxFlexGridSizer?

In my case, I am using a wxFlexGridSizer with 3 rows and 2 columns. I would like the first row to take 1/7 of the vertical space, the second row to take 4/7 of the vertical space, and the third row to take 2/7 of the vertical space.

Thanks.

Re: wxFlexGridSizer row height proportions  [SOLVED]

Posted: Tue Jan 08, 2019 8:47 pm
by doublemax
wxFlexGridSizer::AddGrowableRow() has a proportion parameter.

Re: wxFlexGridSizer row height proportions

Posted: Thu Jan 10, 2019 7:46 pm
by Victory
I am noticing something weird with this dialog (i.e., the one using wxFlexGridSizer) which I haven't seen before with any other. I am now calling AddGrowableRow as you suggested. But, they don't have an impact until I move the dialog a bit.

I do call the following at the end of the dialog's constructor.

Code: Select all

   Layout();
   wxSizer* pSizer = GetSizer();
   if (pSizer)
      pSizer->Fit(this);


To get the proper layout, all that I have to do is just move the dialog. But, when it first shows up, it is not right. As an attempt to get around, I tried calling Refresh or Update at the end of the constructor so that the layout is right when first shown; but, they didn't help.

Any idea?
Thanks.
P.S. Using wxWidgets-3.1.2 on Windows 10.

Re: wxFlexGridSizer row height proportions

Posted: Thu Jan 10, 2019 8:06 pm
by doublemax
Hard to tell without seeing the complete sizer code, but sometimes calling SendSizeEvent() helps.
https://docs.wxwidgets.org/trunk/classw ... 5fa82ba4c2

But, they don't have an impact until I move the dialog a bit.
Is it really about moving? Usually only resizing should have an impact on the layout. I've never seen it happen when moving.

Re: wxFlexGridSizer row height proportions

Posted: Thu Jan 10, 2019 8:20 pm
by Victory
Either moving or resizing fixes it.

As an experiment I just now added the following code at the end of the constructor:

Code: Select all

   const wxPoint pos = GetPosition();
   Move(pos.x + 1, pos.y + 1);


That makes the dialog have the right layout when it appears. So, I seem to have a work-around for this as of now, though hackish.