wx.Listbox and FlexGridSizer

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

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?


SuperStrict

Framework wx.wxApp
Import wx.wxFrame
Import wx.wxAui
Import wx.wxListBox
Import wx.wxButton
Import wx.wxStaticText
Import wx.wxHtmlWindow			' this has the wxPanel in it...


New MyApp.run()

Type MyApp Extends wxApp

	Field frame:MyFrame

	Method OnInit:Int()

		frame = MyFrame(New MyFrame.Create(,,"wxAUI Sample Application", , , 800, 600,wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER))

		SetTopWindow(frame)
		
		frame.show()
		
		Return True
	
	End Method

End Type

Type MyFrame Extends wxFrame

	Field manager:wxAuiManager
	Field notebookStyle:Int
	Field notebookTheme:Int
		
	Method OnInit()

		' tell wxAuiManager to manage this frame
		manager = New wxAuiManager.Create(Self)

		SetMinSize(400, 300)
		
		' add a bunch of panes
		manager.AddPaneInfo(CreateNotebook(), New wxAuiPaneInfo.Create().Name("notebook_content").CenterPane().PaneBorder(False))
		
	End Method

	Method CreateNotebook:wxAuiNotebook()
		' create the notebook off-window to avoid flicker
		Local width:Int, height:Int
		GetClientSize(width, height)

		Local ctrl:wxAuiNotebook = New wxAuiNotebook.Create(Self, wxID_ANY, width, height, 430, 200, notebookStyle)
		
		Local panel:wxPanel = New wxPanel.Create(ctrl, wxID_ANY)
		Local flex:wxFlexGridSizer = New wxFlexGridSizer.Create( 2 )

'		flex.Add(New wxStaticText.Create(panel, -1, "wxTextCtrl"), 0, wxALL | wxALIGN_CENTRE, 5)
		
'		DebugStop
		Local strings:String[] = ["1","2"]
		flex.Add(New wxListBox.Create(panel, -1, strings,200,200,100,100,wxlb_single), 1, wxALL | wxALIGN_CENTRE, 5)
		panel.SetSizer(flex)
		ctrl.AddPage(panel, "Glenns wxPanel", False, Null  )
	
		Return ctrl
	End Method
	
End Type


Cheers
Glenn

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 :-)

cheers

Is there a method to set a header/column name for a ListBox?

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?