wxSizer?

BlitzMax Forums/Brucey's Modules/wxSizer?

MOBii(Posted 2015) [#1]
I would recommend that you try to build a GUI using wxFormBuilder to see how sizers work. wxFormBuilder project can be imported to Blitzmax using Brucey's codegen app found in wx.mod/tools folder.
-Henri

I can compile it but the code it generate I can't compile

I put myself in a corner, when I manually resize and not use wxSizer/wxBoxSizer
What is the easiest way for me to make a object like a wxListBox autoresize
wxListBox is in a wxPanel that is in a wxSplitterWindow
Where I put the sizer on wxPanel or the wxListBox?
	GoToLua = New wxListBox.Create(FilePanel, 32751, Null)
	Local vbox:wxBoxSizer = New wxBoxSizer.Create(wxVERTICAL)
	Local hbox:wxBoxSizer = New wxBoxSizer.Create(wxHORIZONTAL)
	vbox.AddSizer(hbox, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 0)			' 672
	FilePanel.SetSizer(vbox)
This is obvious not working!

I use align.bmx as my wxBoxSizer example
But I don't understand in the example: hbox1.Add(New wxPanel.Create(panel, -1))
This is not working: panel.SetSizer(hbox1)
but why create a extra panel?

Edit:
I think I not learning the wxSizer secrets because
	ConnectAny(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, OnPositionChanged)
	ConnectAny(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, OnPositionChanging)
it's working in most situations


Henri(Posted 2015) [#2]
Hi,

usually it's the case that you want to group your controls (like wxListCtrl) so you add those controls to a sizer (different type of sizer for different style of grouping). Because usually layouts are bit more complicated then any one sizer can cater you want to group those group of controls to an another sizer with different style. Then finally those goups are added to top sizer of your container (like wxPanel or wxWindow) and this top sizer is added to container itself.

Basic chain could be:
Local FilePanel:wxPanel = New wxPanel.Create(main_window, wxID_ANY,,,,, wxTAB_TRAVERSAL)
Local GoToLua = New wxListBox.Create(FilePanel, 32751, Null)
Local vbox:wxBoxSizer = New wxBoxSizer.Create(wxVERTICAL)
Local hbox:wxBoxSizer = New wxBoxSizer.Create(wxHORIZONTAL)

'Add controls to various sizers
hbox.add(GoToLua,  0, wxEXPAND|wxTOP|wxBOTTOM, 5)

'Group various sizers
vbox.AddSizer(hbox, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 0)			' 672

'Finally set container sizer
FilePanel.SetSizer(vbox)

'Apply sizer layouts
FilePanel.layout()
vbox.fit(FilePanel)



@wxFormBuilder

The wxApp stub is missing from the generated code which you can find from codegen tab.


But I don't understand in the example: hbox1.Add(New wxPanel.Create(panel, -1))
This is not working: panel.SetSizer(hbox1)
but why create a extra panel?


Usually panels are been created separately, but in this example panel is created and added to sizer in one statement. As to why panel is created in the firstplace is probably to have individual style to that particular group (you can't for instance colour sizers, but you can colour panels).

-Henri


MOBii(Posted 2015) [#3]
Before I remove the wxListBox border to hide the resizing flickering
'	GoToLua = New wxListBox.Create(FilePanel, 32751, Null, -1, -1, -1, -1, wxNO_BORDER
	GoToLua = New wxListBox.Create(FilePanel, 32751, Null, -1, -1, -1, -1, 0)		'  With border ^^


Local vbox:wxBoxSizer = New wxBoxSizer.Create(wxVERTICAL)
Local hbox:wxBoxSizer = New wxBoxSizer.Create(wxHORIZONTAL)

'Add controls to various sizers
hbox.Add(GoToLua, 1, wxEXPAND, 0)			' It look like If proportion is 1 Then it ignore the border value

'Group various sizers
vbox.AddSizer(hbox, 1, wxEXPAND, 0)			' Only I need: wxEXPAND


FilePanel.SetSizer(vbox)				' Finally set container sizer
FilePanel.layout()					' Apply sizer Layouts
vbox.fit(FilePanel)
Now I can show the wxListBox with border


When I add 1 to proportion on both hbox.Add and vbox.AddSizer it become silk smooth in all edges!
hbox.Add(GoToLua, 1, wxEXPAND, 0)
vbox.AddSizer(hbox, 1, wxEXPAND, 0)
This was very cool because I only need to add 1 wxVERTICAL and 1 wxHORIZONTAL sizer and then I can go get a coffee and live happy everly after..

Thank the for chairing the wxSizer Secret with me

Edited:
To be honest wxSizer is still a mystery to me