wxBoxSizer

BlitzMax Modules Forums/Brucey's Modules/wxBoxSizer

The following is generated by wxCodeGen.

The screen is split in 2 horizontal halves, then the bottom half is split into 3 vertical pieces.

I want to apply a size to the boxsizers.
The top part should never be bigger than the default size of the listbox, generaly about a 1/4 of the height of the window.
The bottom part should have the middle sizer stretching to fill the gaps. ie the first and third sizer will be a set width.

Perhaps i shouldn't be using boxsizers?

I have also included the fbp file for the form builder if that helps

Cheers
Glenn

wxCodeGen
'
' BlitzMax code generated with wxCodeGen v0.91 : 13 Feb 2008 22:30:53
' 
' 
' PLEASE DO "NOT" EDIT THIS FILE!
' 
SuperStrict

Framework wx.wxApp

Import wx.wxButton
Import wx.wxFrame
Import wx.wxListBox
Import wx.wxListCtrl
Import wx.wxMenu
Import wx.wxMenuBar
Import wx.wxPanel
Import wx.wxRadioBox
Import wx.wxStaticBitmap
Import wx.wxStatusBar
Import wx.wxTextCtrl
Import wx.wxWindow

New MyApp.run()


Type MyApp Extends wxApp

	Method OnInit:Int()
	
		wxImage.AddHandler( New wxXPMHandler ) ' for Mac/Win32 (it is default on Linux)

		Local frame:MyFrameBase = MyFrameBase(New MyFrameBase.Create(, , "C2D Task Manager Test"))

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

End Type

Type MyFrameBase Extends wxFrame

	Field m_panel:wxPanel
	Field m_bitmapLeft:wxStaticBitmap
	Field m_radioBoxSelectorType:wxRadioBox
	Field m_listBoxNames:wxListBox
	Field m_listCtrlDue:wxListCtrl
	Field m_radioBoxDue:wxRadioBox
	Field m_bitmapRight:wxStaticBitmap
	Field m_listBoxSelector:wxListBox
	Field m_listCtrlMainTask:wxListCtrl
	Field m_listCtrlSubTask:wxListCtrl
	Field m_textCtrlSubTaskNotes:wxTextCtrl
	Field m_button1:wxButton
	Field m_button2:wxButton
	Field m_button3:wxButton
	Field m_button4:wxButton
	Field m_button5:wxButton
	Field m_button6:wxButton
	Field m_button7:wxButton
	Field m_button8:wxButton
	Field m_button9:wxButton
	Field m_button10:wxButton
	Field m_button11:wxButton
	Field m_button12:wxButton
	Field m_statusBar:wxStatusBar
	Field m_menubar:wxMenuBar
	Field m_menu1:wxMenu
	Field m_menu31:wxMenu
	Field m_menu21:wxMenu
	Field m_menu2:wxMenu
	Field m_menu3:wxMenu
	Field m_menu4:wxMenu


	Method Create:MyFrameBase(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "", x:Int = -1, y:Int = -1, w:Int = 806, h:Int = 518, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
		Return MyFrameBase(Super.Create(parent, id, title, x, y, w, h, style))
	End Method

	Method OnInit()

		Local bSizerFrame:wxBoxSizer
		bSizerFrame = New wxBoxSizer.Create(wxVERTICAL)
		m_panel = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL)

		Local bSizerPanel:wxBoxSizer
		bSizerPanel = New wxBoxSizer.Create(wxVERTICAL)

		Local bSizeTopPortion:wxBoxSizer
		bSizeTopPortion = New wxBoxSizer.Create(wxHORIZONTAL)
		m_bitmapLeft = New wxStaticBitmap.Create(m_panel, wxID_ANY, wxBitmap.CreateFromFile("C:/C2D/BlitzBasic/Productivity/Images/Dragon-Medium.jpg", wxBITMAP_TYPE_ANY))
		bSizeTopPortion.Add(m_bitmapLeft, 0, wxALL, 5)

		Local m_radioBoxSelectorTypeChoices:String[] = [ "Radio Button" ]
		m_radioBoxSelectorType = New wxRadioBox.Create(m_panel, wxID_ANY, "wxRadioBox",,,,, m_radioBoxSelectorTypeChoices, 1, wxRA_SPECIFY_COLS)
		bSizeTopPortion.Add(m_radioBoxSelectorType, 0, wxALL, 5)

		m_listBoxNames = New wxListBox.Create(m_panel, wxID_ANY, Null)

		bSizeTopPortion.Add(m_listBoxNames, 0, wxALL, 5)

		m_listCtrlDue = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizeTopPortion.Add(m_listCtrlDue, 0, wxALL, 5)

		Local m_radioBoxDueChoices:String[] = [ "Radio Button" ]
		m_radioBoxDue = New wxRadioBox.Create(m_panel, wxID_ANY, "wxRadioBox",,,,, m_radioBoxDueChoices, 1, wxRA_SPECIFY_COLS)
		bSizeTopPortion.Add(m_radioBoxDue, 0, wxALL, 5)

		m_bitmapRight = New wxStaticBitmap.Create(m_panel, wxID_ANY, wxBitmap.CreateFromFile("C:/C2D/BlitzBasic/Productivity/Images/Dragon-Medium.jpg", wxBITMAP_TYPE_ANY))
		bSizeTopPortion.Add(m_bitmapRight, 0, wxALL, 5)

		bSizerPanel.AddSizer(bSizeTopPortion, 1, wxEXPAND, 5)


		Local bSizerBottomPortion:wxBoxSizer
		bSizerBottomPortion = New wxBoxSizer.Create(wxHORIZONTAL)
		m_listBoxSelector = New wxListBox.Create(m_panel, wxID_ANY, Null)

		bSizerBottomPortion.Add(m_listBoxSelector, 0, wxALL, 5)


		Local bSizerTasks:wxBoxSizer
		bSizerTasks = New wxBoxSizer.Create(wxHORIZONTAL)

		Local bSizerTaskLists:wxBoxSizer
		bSizerTaskLists = New wxBoxSizer.Create(wxVERTICAL)
		m_listCtrlMainTask = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizerTaskLists.Add(m_listCtrlMainTask, 1, wxALL, 5)

		m_listCtrlSubTask = New wxListCtrl.Create(m_panel, wxID_ANY,,,,, wxLC_ICON)
		bSizerTaskLists.Add(m_listCtrlSubTask, 2, wxALL, 5)

		m_textCtrlSubTaskNotes = New wxTextCtrl.Create(m_panel, wxID_ANY, "")
		m_textCtrlSubTaskNotes.SetMaxLength(0)
		bSizerTaskLists.Add(m_textCtrlSubTaskNotes, 1, wxALL, 5)

		bSizerTasks.AddSizer(bSizerTaskLists, 1, wxEXPAND, 5)


		Local bSizerTaskButtons:wxBoxSizer
		bSizerTaskButtons = New wxBoxSizer.Create(wxVERTICAL)
		m_button1 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button1, 0, wxALL, 5)

		m_button2 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button2, 0, wxALL, 5)

		m_button3 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button3, 0, wxALL, 5)

		m_button4 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button4, 0, wxALL, 5)

		m_button5 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button5, 0, wxALL, 5)

		m_button6 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button6, 0, wxALL, 5)

		m_button7 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button7, 0, wxALL, 5)

		m_button8 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button8, 0, wxALL, 5)

		m_button9 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button9, 0, wxALL, 5)

		m_button10 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button10, 0, wxALL, 5)

		m_button11 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button11, 0, wxALL, 5)

		m_button12 = New wxButton.Create(m_panel, wxID_ANY, "MyButton")
		bSizerTaskButtons.Add(m_button12, 0, wxALL, 5)

		bSizerTasks.AddSizer(bSizerTaskButtons, 1, wxEXPAND, 5)

		bSizerBottomPortion.AddSizer(bSizerTasks, 1, wxEXPAND, 5)

		bSizerPanel.AddSizer(bSizerBottomPortion, 1, wxEXPAND, 5)

		m_panel.SetSizer(bSizerPanel)
		m_panel.Layout()
		bSizerFrame.Add(m_panel, 1, wxEXPAND | wxALL, 5)

		m_statusBar = Self.CreateStatusBar(3, 0|wxST_SIZEGRIP, wxID_ANY)

		m_menubar = New wxMenuBar.Create(wxALWAYS_SHOW_SB|wxCLIP_CHILDREN)

		m_menu1 = New wxMenu.Create()

		Local m_menuItem3:wxMenuItem
		m_menuItem3 = New wxMenuItem.Create(m_menu1, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu1.AppendItem(m_menuItem3)

		m_menu31 = New wxMenu.Create()
		m_menu1.AppendMenu(-1, "MyMenu", m_menu31)

		Local m_menuItem4:wxMenuItem
		m_menuItem4 = New wxMenuItem.Create(m_menu1, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu1.AppendItem(m_menuItem4)

		m_menu21 = New wxMenu.Create()
		m_menu1.AppendMenu(-1, "MyMenu", m_menu21)

		Local m_menuItem5:wxMenuItem
		m_menuItem5 = New wxMenuItem.Create(m_menu1, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu1.AppendItem(m_menuItem5)
		m_menubar.Append(m_menu1, "MyMenu")

		m_menu2 = New wxMenu.Create()

		Local m_menuItem6:wxMenuItem
		m_menuItem6 = New wxMenuItem.Create(m_menu2, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu2.AppendItem(m_menuItem6)

		Local m_menuItem7:wxMenuItem
		m_menuItem7 = New wxMenuItem.Create(m_menu2, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu2.AppendItem(m_menuItem7)

		Local m_menuItem8:wxMenuItem
		m_menuItem8 = New wxMenuItem.Create(m_menu2, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu2.AppendItem(m_menuItem8)
		m_menubar.Append(m_menu2, "MyMenu")

		m_menu3 = New wxMenu.Create()

		Local m_menuItem9:wxMenuItem
		m_menuItem9 = New wxMenuItem.Create(m_menu3, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu3.AppendItem(m_menuItem9)

		Local m_menuItem10:wxMenuItem
		m_menuItem10 = New wxMenuItem.Create(m_menu3, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu3.AppendItem(m_menuItem10)

		Local m_menuItem11:wxMenuItem
		m_menuItem11 = New wxMenuItem.Create(m_menu3, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu3.AppendItem(m_menuItem11)
		m_menubar.Append(m_menu3, "MyMenu")

		m_menu4 = New wxMenu.Create()

		Local m_menuItem1:wxMenuItem
		m_menuItem1 = New wxMenuItem.Create(m_menu4, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu4.AppendItem(m_menuItem1)

		Local m_menuItem2:wxMenuItem
		m_menuItem2 = New wxMenuItem.Create(m_menu4, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu4.AppendItem(m_menuItem2)

		Local m_menuItem12:wxMenuItem
		m_menuItem12 = New wxMenuItem.Create(m_menu4, wxID_ANY, "MyMenuItem", "", wxITEM_NORMAL)
		m_menu4.AppendItem(m_menuItem12)
		m_menubar.Append(m_menu4, "MyMenu")
		SetMenuBar(m_menubar)

		SetSizer(bSizerFrame)
		Layout()

	End Method

End Type



fbp file
email me on glenn at c2d dot co dot nz if you would like the fbp file, although it is 11pm so i might need to get ready for bed in the next hour...
work beckons at 6am...

.

Posts are limited... you'd need to split it.

.. or post it elsewhere :-)

do you never sleep?
i have just emailed the file to you.

Anyhoo... try this for your 3 horizontal bits.

The first and last, have "proportion" set to zero.
The middle one, which you want to fill the space, set "proportion" to 1.

That should make the outer two only as wide as the control they hold.

do you never sleep?

It's only lunch-time here... ;-) (12:07)

A zero proportion means, fit to the child size.

Hmm, I'm sure someone (Vertex?) listed what the values do...

got it.
set the top portion to 1 and the bottom portion to 3, that way the top portion uses the top 1/4.
same thing for the 3 vertical parts of the bottom portion.

i was doing this for the individual controls but missed the obvious thing on the sizers themselves...

Cheers
Glenn

Yeah, it takes a bit of getting used to, but once you do it's very quick to make some quite complex layouts.

And the nice thing with sizers is that they'll shuffle themselves around when you run the same app on a different platform (or with different themes), so the layout should always look right no matter the default control sizes.

The other sizers, Grid, FlexGrid etc, help you to lay things out where you want separate columns, yet you also want the rows of controls to be lined up also.
wxCodeGen uses one on the first page to line up the labels and textfields nicely.

i basically copied the layout sequence from the wxcodegen screen.
Frame -> Sizer -> Panel -> Sizer -> sizer ->
would have had me stumped for ages without that guide.
In fact the first time i used it i couldn't lay anything out...