wxFlexGridSizer row height proportions Topic is solved

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
Victory
Experienced Solver
Experienced Solver
Posts: 95
Joined: Fri Mar 19, 2010 1:20 am

wxFlexGridSizer row height proportions

Post by Victory » Tue Jan 08, 2019 8:32 pm

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.

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

Re: wxFlexGridSizer row height proportions

Post by doublemax » Tue Jan 08, 2019 8:47 pm

wxFlexGridSizer::AddGrowableRow() has a proportion parameter.
Use the source, Luke!

Victory
Experienced Solver
Experienced Solver
Posts: 95
Joined: Fri Mar 19, 2010 1:20 am

Re: wxFlexGridSizer row height proportions

Post by Victory » Thu Jan 10, 2019 7:46 pm

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.
Last edited by Victory on Thu Jan 10, 2019 8:09 pm, edited 1 time in total.

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

Re: wxFlexGridSizer row height proportions

Post by doublemax » Thu Jan 10, 2019 8:06 pm

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.
Use the source, Luke!

Victory
Experienced Solver
Experienced Solver
Posts: 95
Joined: Fri Mar 19, 2010 1:20 am

Re: wxFlexGridSizer row height proportions

Post by Victory » Thu Jan 10, 2019 8:20 pm

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.

Post Reply