wxWidgets - Sizers

BlitzMax Forums/Brucey's Modules/wxWidgets - Sizers

Peter(Posted 2008) [#1]
I'm playing around with Sizers and so far I figured out how that stuff works, but now I reached a point where I'm stuck.

I'm trying to set up a dynamic dialog box with an array of up to 3x3 images in the area of tGridS.

'*** +---------+-+---------------------+
'*** |         |S|                     |
'*** | Buttons |P| tGridS              |
'*** |         |C|                     |
'*** +---------+-+---------------------+
'*** |         |S|                     |
'*** | Spacer  |P| StaticBoxSizer      |
'*** |         |C| (ComboBoxes)        |
'*** +---------+-+---------------------+
'***		
'*** tGridS holds up to 3x3 images
'***	


The dialog box should only start with one visible image in the topleft position of tGridS (wxGridSizer.CreateRC(3,3,0,0)). The other possible positions are set to tGridS.Show(tCanvas[x,y], False).

The respective controls are not visible in the dialog but despite the Show(False) command and the call of Layout() in several places I did not manage to reduce the dialog box to the minimum size needed with only one image visible (I started with only wxGridSizer.CreateRC(1,1,0,0) to make things easier).

Is there anywhere out there a working example for a dynamic dialog?

Maybe I'm using the wrong Sizer for the result I would like to achive.

I would appreciate any hints that would help me to get where I want to.

-- Peter


Glenn Dodd(Posted 2008) [#2]
try setting the SizerItem proportion to 1 for the hidden ones and the visible one to something like 10.
That way the other hidden items should take up very little of the screen real estate.

in this example i have 2 items set to 1 so they take 50% of the space each.
ie bSizerMiddlePortion.Add(m_radioBoxShowTasks, 1, wxALL, 5)
and
bSizerMiddlePortion.Add(m_radioBoxShowMainTasks, 1, wxALL, 5)




Brucey(Posted 2008) [#3]
After much trawling through the wxWidgets source code... :-p ... it seems that a wxGridSizer is doesn't care if you are showing an item or not.

Instead, try using a wxFlexGridSizer, which is a subclass of wxGridSizer. You also need to call Fit() on your window to get it to recalculate itself.

Example :

hidden.bmx


hiddengen.bmx


:o)


Peter(Posted 2008) [#4]
Thanks for the tip with wxFlexGridSizer.

I just inserted the 4 letters to the respective source code line and 'voila' everything looks as intended now.

You saved my day.

-- Peter