From b343aeaba65b6bafec58584510ea29ad65ac8737 Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 27 Sep 2005 23:23:51 +0000 Subject: Added SetFloat() to TText --- simplegui.mod/simplegui.bmx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/simplegui.mod/simplegui.bmx b/simplegui.mod/simplegui.bmx index a7ca95c..79ba7eb 100644 --- a/simplegui.mod/simplegui.bmx +++ b/simplegui.mod/simplegui.bmx @@ -264,6 +264,27 @@ Type TText Extends TWidget gui.Register(o) Return o End Function + + Rem + bbdoc: Set the text to a floating point value. + about: @v is the floating point value (a double to cover both types). This value will be placed in the text + about: field with trailing zeros (and trailing dot if an integer) removed. + EndRem + Method SetFloat(v:Double) + Local s:String=v + + If s.Find(".")<>-1 + While s.length>1 And s[s.length-1]=Asc("0") + s=s[..s.length-1] + Wend + + While s.length>1 And s[s.length-1]=Asc(".") + s=s[..s.length-1] + Wend + EndIf + + text=s + End Method Method HandleClick() owner.SetFocus(Self) @@ -915,6 +936,9 @@ Function GUIMenu(title:String, options:String[], x:Int, y:Int, i:TImage=Null) Local gui:TGUIHandler=TGUIHandler.Create() + x=Max(0,Min(x,GraphicsWidth()-w)) + y=Max(0,Min(y,GraphicsHeight()-h)) + Local label:TLabel=TLabel.Create(gui,x+5,y+2,title) Local button:TButton[]=New TButton[options.length] @@ -958,6 +982,8 @@ about: @gui is the GUI handler and widgets to display as a dialog., @ok is the c about: If @i is not null then this image is drawn as a mouse cursor. EndRem Function GUIDialog(gui:TGUIHandler, ok:TWidget, cancel:TWidget, i:TImage=Null) + FlushKeys() + Local back:TImage=CreateImage(GraphicsWidth(),GraphicsHeight(),1,0) GrabImage(back,0,0) -- cgit v1.2.3