wx.Listbox and FlexGridSizer

BlitzMax Forums/Brucey's Modules/wx.Listbox and FlexGridSizer

Glenn Dodd(Posted 2008) [#1]
The code below compiles and runs but i don't know where the docs are for FlexGridSizer so i can't find what the number "5" on the end of this line means:

flex.Add(New wxListBox.Create(panel, -1, strings,200,200,100,100,wxlb_single), 1, wxALL | wxALIGN_CENTRE, 5)

also why isn't the Listbox being positioned at 200.200 and 100*100 wide/deep?




Cheers
Glenn


Brucey(Posted 2008) [#2]
Hmmm :-)

Something to guide you a little : Online Manual

"5" is the size of the border around the control you are placing. You are specifying a 5 pixel gap between the listbox and the next control.

The reason for the listbox not being placed at the desired coordinates is because you are placing inside a Sizer.
Sizers are there to help you lay out your controls in such a way that you don't need to specify *where* exactly a control is placed - this is good, because on different platforms, controls can be different sizes.

You can skip around the flexible layout of sizers by placing your control onto a panel instead - but be warned of the cross-platform / theme differences issues, if you choose that path.

Coding sizers by hand is a lot of work, even if you can visualize what you want in your head. (sizers inside sizers, beside other sizers etc).
You may find that playing with a tool like wxFormBuilder will help you get the hang of how sizers work.

You can even load the wxFormBuilder project into wxCodeGen (see the wx.mod/tools folder) and have it generate Max code for you (at least for the current supported controls).

This what the docs say about a wxFlexGridSizer :
A flex grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields in one row having the same height and all fields in one column having the same width, but all rows or all columns are not necessarily the same height or width as in the wxGridSizer.

May not be what you want :-)


Glenn Dodd(Posted 2008) [#3]
cheers


Glenn Dodd(Posted 2008) [#4]
Is there a method to set a header/column name for a ListBox?


Brucey(Posted 2008) [#5]
A wxListBox is a plain single-column list of selectable Strings.

Perhaps you want to use a wxListCtrl with a single column if you need an "enhanced" list?