Function Reference

Function GUINotify( s:String, i:TImage=Null ) Displays a notification alert with the supplied string.

The string s can be split into multiple lines using the '|' character. If i is not null then this image is drawn as a mouse cursor.



Function GUIYesNo:Int( s:String, i:TImage=Null ) Displays a yes/no alert with the supplied string.

Returns: True if Yes selected, otherwise False.

The string s can be split into multiple lines using the '|' character. If i is not null then this image is drawn as a mouse cursor.



Function GUIMenu( title:String, options:String[], x:Int, y:Int, i:TImage=Null ) Displays a pop-up menu.

Returns: The index of the selected option, -1 for none.

title is the menu title, options the options to display and x and y specify its position. If i is not null then this image is drawn as a mouse cursor.



Type Reference

Type TGUIFont Defines the TBitmapFont to be used by the GUI.

Global font:TBitmapFont The font to use.



Type TWidget Abstract The base widget type.

Field enabled:Int If true the widget is displayed and can be used.


Field text:String The text displayed in the widget.


Field x:Int The X co-ordinate of the widget.


Field y:Int The Y co-ordinate of the widget.


Field w:Int The width of the widget.


Field h:Int The height of the widget.


Field callback(w:TWidget) Callback to call when clicked.


Field mouse_over:Int True if the mouse is over this widget, False otherwise.


Field owner:TGUIHandler The TGUIHandler that owns this widget.


Method HandleKey( k:Int ) Override this accept keypresses


Method MouseEnter() Override this for when the mouse enters. Call this parent version to handle mouse_over too.


Method MouseLeave() Override this for when the mouse leaves. Call this parent version to handle mouse_over too.


Method HandleClick() Override to handle a mouse button press.


Method Draw() Must be provided by a widget to draw itself.


Function DrawBox( x:Int, y:Int, w:Int, h:Int ) Helper to draw a wireframe rectangle.


Function Draw3DBox( x:Int, y:Int, w:Int, h:Int, invert:Int, size:Int=2 ) Helper to draw a 3D rectangle.



Type TLabel Extends TWidget The label widget (simply displays the supplied string)

Function Create:TLabel( gui:TGUIHandler,x:Int, y:Int, text:String ) Create a TLabel widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x and y are its position and text is the text to display in the label.




Type TText Extends TWidget The text entry widget

Function Create:TText( gui:TGUIHandler,x:Int, y:Int, text:String, maxlen:Int, callback(w:TWidget)=Null ) Create a TText widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x and y are its position and text is the initial text in the widget. maxlen is the maximum number of characters allowed. callback is called when RETURN is pressed in the text field.




Type TCheckbox Extends TWidget The checkbox widget

Field checked:Int True if the box is checked, False otherwise.


Function Create:TCheckbox( gui:TGUIHandler, x:Int, y:Int, text:String, callback(w:TWidget)=Null ) Create a TCheckox widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x and y are its position and text is the text to display by the checkbox. callback is called when the checkbox is toggled.




Type TButton Extends TWidget The button widget

Function Create:TButton( gui:TGUIHandler, x:Int, y:Int, w:Int, h:Int, text:String, callback(w:TWidget) ) Create a TButton widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x, y, w and h are its position and size, and text is the text to display in the button. callback is called when the button is pressed.




Type TButtonList Extends TWidget A drop down list type widget

Field selected:Int The selected item.


Function Create:TButtonList( gui:TGUIHandler, x:Int, y:Int, options:String[], selected:Int, callback(w:TWidget) ) Create a TButtonList widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x and y are its position. options are the options for the list and selected is the currently selected item. callback is called when the selection changes.




Type TNumberFloat Extends TWidget A number up/down widget for floats

Field value:Float The value


Field change:Float The increment/decrement


Field maxval:Float The maximum value


Field minval:Float The minimum value


Function Create:TNumberFloat( gui:TGUIHandler, x:Int, y:Int, callback(w:TWidget)=Null ) Create a TNumber widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x and y are its position. callback is called when the value changes.




Type TNumberInt Extends TWidget A number up/down widget for ints

Field value:Int The value


Field change:Int The increment/decrement


Field maxval:Int The maximum value


Field minval:Int The minimum value


Function Create:TNumberInt( gui:TGUIHandler, x:Int, y:Int, callback(w:TWidget)=Null ) Create a TNumber widget.

Returns: The created widget.

gui is the TGUIHandler object managing this wiget. x and y are its position. callback is called when the value changes.




Type TGUIHandler Handles the GUI.

Method Register( w:TWidget ) Register a widget.

Widgets call this themselves.



Method Clear() Remove all widgets.


Method SetEnable( state:Int ) Sets the enable state of all widgets.

If state is true then all widgets are enabled, otherwise all widgets are disabled



Method SetFocus( w:TWidget ) Sets the keyboard focus to the supplied widget. Pass null for no focus.


Method GetFocus:TWidget() Gets the keyboard focus.

Returns: The currently focused TWidget, or null for no focus.



Method Clicked:TWidget() Gets the last clicked widget.

Returns: The last clicked TWidget. Null is returned if this is called again before another widget is clicked.



Method EventLoop() Perform the event loop and pass any necessary events.

KeyHit(KEY_MOUSELEFT) and GetChar() are used to consume events for the interface.



Function Create:TGUIHandler() Create a GUI Handler.

Returns: The GUI Hanbler.




Module Information

Framework (Very) Simple GUI
Copyright Public Domain
Author Ian Cowburn
Version $Revision$