SetDefault

One of the most boring thing in MaxGUI is doing thing manually.

An example? Apply SetGadgetLayout to a bunch of gadgets.

If you have 2 or 3 gadgets this is a trivial job. But when you have 10 or 20 gadgets it becames quite tediuos!

So I decided (again :P) to hack MaxGUI to allow some ‘default’ behaviours.

I’ve implemented a new command SetGadgetDefault:Int(key$,[value])

The idea is to pass to MaxGUI a command-key (in the form of a string) and the parameters (in the form of an INT array).

The things is at an early stage, but at the moment I’ve implemented

  • LAYOUT
  • FGCOLOR
  • BGCOLOR

You can use SetGadgetDefault(“layout”,[EDGE_ALIGNED,EDGE_ALIGNED,0,0]) (for example) and since now every gadget you create will automatically set the layout desired. And of course every other ‘default’ you have created (and activated).

Handy, it isn’t?

Once you call SetGadgetDefault() that specific ‘default-condition’ is activated. To disable (or reactivate it) you need to use GadgetDefault(key,0|1) (where 0 = off, 1 = on).

This is an example of the new commands in action

SuperStrict
Import maxgui.drivers


Global window:tgadget=		CreateWindow("Main",100,100,300,300,,WINDOW_RESIZABLE|WINDOW_TITLEBAR|WINDOW_CENTER)

Local BTN:TGADGET[5]

setgadgetdefault("layout",[EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,0])
setgadgetdefault("fgcolor",[200,100,10])

btn[0]=	CreateButton("Auto 1",10,100,100,30,window)
btn[1]=	CreateButton("Auto 2",10,150,100,30,window)
GADGETDEFAULT("fgcolor",0) 'disable default foreground color...
btn[2]=	CreateButton("Auto 3",10,200,100,30,window)
btn[3]=	CreateButton("Auto 4",10,250,100,30,window)

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_APPTERMINATE, EVENT_WINDOWCLOSE
			End
	End Select
Forever

Of course these commands require to change MaxGUI (in particular driver.bmx and win32maxguiex.bmx).

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close