From 6daa6ca8f55c86512d92fa187cdf21bc7c279a6a Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 19 Sep 2005 23:24:16 +0000 Subject: Added simple number spinners --- simplegui.mod/doc/commands.html | 26 ++++++ simplegui.mod/simplegui.bmx | 172 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) (limited to 'simplegui.mod') diff --git a/simplegui.mod/doc/commands.html b/simplegui.mod/doc/commands.html index 56b78b5..b857360 100644 --- a/simplegui.mod/doc/commands.html +++ b/simplegui.mod/doc/commands.html @@ -79,6 +79,32 @@ If i is not null then this image is drawn as a mouse cursor.
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.



diff --git a/simplegui.mod/simplegui.bmx b/simplegui.mod/simplegui.bmx index 678497b..7b5e7ef 100644 --- a/simplegui.mod/simplegui.bmx +++ b/simplegui.mod/simplegui.bmx @@ -397,6 +397,178 @@ Type TButtonList Extends TWidget End Method End Type +Rem +bbdoc: A number up/down widget for floats +EndRem +Type TNumberFloat Extends TWidget + + Rem + bbdoc: The value + EndRem + Field value:Float + + Rem + bbdoc: The increment/decrement + EndRem + Field change:Float + + Rem + bbdoc: The maximum value + EndRem + Field maxval:Float + + Rem + bbdoc: The minimum value + EndRem + Field minval:Float + + Rem + bbdoc: Create a TNumber widget. + returns: The created widget. + about: @gui is the @TGUIHandler object managing this wiget. @x and @y are its position. + about: @callback is called when the value changes. + EndRem + Function Create:TNumberFloat(gui:TGUIHandler, x:Int, y:Int, callback(w:TWidget)=Null) + Local o:TNumberFloat=New TNumberFloat + o.enabled=True + o.value=0 + o.minval=0 + o.maxval=100 + o.change=10 + o.x=x + o.y=y + o.w=TGUIFont.font.MaxHeight()*2+8 + o.h=TGUIFont.font.MaxHeight()+2 + o.callback=callback + gui.Register(o) + Return o + End Function + + Method HandleClick() + Local old:Float=value + + If MouseX()old And callback<>Null + callback(Self) + EndIf + End Method + + Method Draw() + If mouse_over + If MouseX()old And callback<>Null + callback(Self) + EndIf + End Method + + Method Draw() + If mouse_over + If MouseX()