summaryrefslogtreecommitdiff
path: root/simplegui/test.bmx
blob: f0ecc487cae2481ac095af3320cf5c67ac87597b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
' $Id$

Import noddybox.simplegui
Import noddybox.bitmapfont

Incbin "font.bmf"

Const SCRW=800
Const SCRH=600

SetGraphicsDriver GLMax2DDriver()
Graphics SCRW,SCRH,32,60' Or HARDSYNC

font:TBitmapFont=TBitmapFont.Load("incbin::font.bmf",0)

TGUIFont.font=font

Global gui:TGUIHandler=TGUIHandler.Create()

Global label1:TLabel=TLabel.Create(gui,0,0,"Text 1:  ")
Global label2:TLabel=TLabel.Create(gui,0,20,"Text 2:  ")
Global text1:TText=TText.Create(gui,label1.w,0,"Text entry 1",20,TextCallback)
Global text2:TText=TText.Create(gui,label2.w,20,"Text entry 2",30)
Global check1:TCheckbox=TCheckbox.Create(gui,400,0,"Check 1",CheckCallback)
Global check2:TCheckbox=TCheckbox.Create(gui,400,20,"Check 2")
Global button1:TButton=TButton.Create(gui,0,360,100,30,"Button 1",ButtonCallback)
Global button2:TButton=TButton.Create(gui,110,360,100,30,"Quit",ButtonCallback)

SetBlend(ALPHABLEND)

Global quit=False

While Not KeyHit(KEY_ESCAPE) And Not quit
	Cls
	
	gui.EventLoop()
	
	If KeyHit(KEY_MOUSERIGHT)
		Menu()
	EndIf
	
	Flip
	FlushMem
Wend

EndGraphics
End

Function TextCallback(w:TWidget)
	GUINotify(w.Text)
End Function

Function CheckCallback(w:TWidget)
	Local c:TCheckbox=TCheckbox(w)
	
	check2.enabled=c.checked
	text2.enabled=c.checked
	button2.enabled=c.checked
End Function

Function ButtonCallback(w:TWidget)
	If w.text="Quit"
		quit=GUIYesNo("Really quit this really rather impressive (cough) demo?")
	Else
		GUINotify(w.text + " pressed")
	EndIf
End Function


Function Menu()
	Local opt:Int=GUIMenu("A long long Menu",["Option 1","Option 2","Option 3"],MouseX(),MouseY())
	
	If opt>-1
		GUINotify("Selected " + opt)
	EndIf
End Function