Gadget Alignment Problem

BlitzMax Forums/BlitzMax Beginners Area/Gadget Alignment Problem

kenshin(Posted 2006) [#1]
I've been trying to get an auto gadget alignment setup working properly. Here's the code I'm playing with:
Local window:tgadget=CreateWindow("Profile Manager",(GadgetWidth(Desktop())-320)/2,(GadgetHeight(Desktop())-240)/2,320,240,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE )
Local MainTabber:tgadget=CreateTabber(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout MainTabber,1,1,1,1 
AddGadgetItem MainTabber,"Profiles",False,-1,""
AddGadgetItem MainTabber,"System Info",False,-1,""
AddGadgetItem MainTabber,"Credits",False,-1,""
Local panel:tgadget=CreatePanel(0,0,ClientWidth(window),ClientHeight(window),MainTabber,PANEL_ACTIVE)
Local pwidth:Int = ClientWidth(panel)
SetGadgetLayout panel,1,1,1,1
Local listbox:tgadget=CreateListBox(2,1,pwidth/3,ClientHeight(panel)-27,panel)
SetGadgetLayout listbox,EDGE_ALIGNED,EDGE_RELATIVE,EDGE_ALIGNED,EDGE_ALIGNED
Local ProfilesTabber:tgadget=CreateTabber((GadgetWidth(panel)/3)+4,1,((ClientWidth(panel)/3)*2)-10,ClientHeight(panel)-27,panel)
SetGadgetLayout ProfilesTabber,EDGE_RELATIVE,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED 
AddGadgetItem ProfilesTabber,"Graphics",False,-1,""
AddGadgetItem ProfilesTabber,"Sound",False,-1,""
AddGadgetItem ProfilesTabber,"Controls",False,-1,""

While True
	WaitEvent 
	Print CurrentEvent.ToString()
	Print
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend

It works fine until I want to resize the window. When I do this, the small space between the listbox and the tabber changes. What I'd like to have is a listbox that takes 1/3 width and a tabber that takes the other 2/3 width, but when I resize the window the space between the 2 gadgets remains constant (like 4 pixels or so).

Hope I've explained the problem clearly enough. Is there any way to do this?


kenshin(Posted 2006) [#2]
OK, this works properly:
Local window:tgadget=CreateWindow("Profile Manager",(GadgetWidth(Desktop())-320)/2,(GadgetHeight(Desktop())-240)/2,320,240,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE )
Local MainTabber:tgadget=CreateTabber(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout MainTabber,1,1,1,1 
AddGadgetItem MainTabber,"Profiles",False,-1,""
AddGadgetItem MainTabber,"System Info",False,-1,""
AddGadgetItem MainTabber,"Credits",False,-1,""
Local panel:tgadget=CreatePanel(0,0,ClientWidth(window),ClientHeight(window),MainTabber,PANEL_ACTIVE)
Local pwidth:Int = ClientWidth(panel)
SetGadgetLayout panel,1,1,1,1
Local listbox:tgadget=CreateListBox(1,1,((ClientWidth(panel)*1)/3),ClientHeight(panel)-27,panel)
SetGadgetLayout listbox,EDGE_ALIGNED,EDGE_RELATIVE,EDGE_ALIGNED,EDGE_ALIGNED
Local ProfilesTabber:tgadget=CreateTabber(((ClientWidth(panel)*1)/3)+3,1,ClientWidth(panel)-GadgetWidth(listbox)-9,ClientHeight(panel)-27,panel)
SetGadgetLayout ProfilesTabber,EDGE_RELATIVE,EDGE_RELATIVE,EDGE_ALIGNED,EDGE_ALIGNED 
AddGadgetItem ProfilesTabber,"Graphics",False,-1,""
AddGadgetItem ProfilesTabber,"Sound",False,-1,""
AddGadgetItem ProfilesTabber,"Controls",False,-1,""

While True
	WaitEvent 
	Print CurrentEvent.ToString()
	Print
	Select EventID()
		Case EVENT_WINDOWSIZE
			SetGadgetShape listbox,1,1,((ClientWidth(panel)*1)/3),ClientHeight(panel)-27
			SetGadgetShape ProfilesTabber,((ClientWidth(panel)*1)/3)+3,1,ClientWidth(panel)-GadgetWidth(listbox)-9,ClientHeight(panel)-27
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend

Looks like I have to use SetGadgetShape every time the window is resized.