How do I create a big calculator using buttons?

BlitzPlus Forums/BlitzPlus Beginners Area/How do I create a big calculator using buttons?

I want to put a big calculator type layout on my screen, with big keys, a different coloured background for each key and a BIG centred text showing the number (and to store the number in a variable when clicked). I'm sure I need to know how to use gadgets/panels and the button feature etc. but I'm struggling to find some decent tutorials on it. So:

- Can anyone advise on how to set up calculator (preferably with code)
- can anyone point me towards a good basic tutorial on Events/panels/gadgets (I'm aware of the one from the BlitzPlus Homepage) - are there any others around?

Many thanks

About the background for keys: blitz buttons are simply the buttons of your OS .. there're no native imagebuttons.. (tho I've seen something once in some topic, but it was using external stuff iirc..)

window=CreateWindow("calc example - CS_TBL",0,0,384,384)

button0=CreateButton("0",20,264,24,24,window)
buttondot=CreateButton(".",44,264,24,24,window)
buttonis=CreateButton("=",68,264,48,24,window)
button1=CreateButton("1",20,240,24,24,window)
button2=CreateButton("2",44,240,24,24,window)
button3=CreateButton("3",68,240,24,24,window)
button4=CreateButton("4",20,216,24,24,window)
button5=CreateButton("5",44,216,24,24,window)
button6=CreateButton("6",68,216,24,24,window)
button7=CreateButton("7",20,192,24,24,window)
button8=CreateButton("8",44,192,24,24,window)
button9=CreateButton("9",68,192,24,24,window)

buttonmin=CreateButton("-",92,192,24,24,window)
buttonplus=CreateButton("+",92,216,24,48,window)
buttonmul=CreateButton("*",116,192,24,24,window)
buttondiv=CreateButton("/",116,216,24,24,window)
buttonmod=CreateButton("%",116,240,24,24,window)
buttonexp=CreateButton("^",116,264,24,24,window)
buttonbracketopen=CreateButton("(",140,192,24,24,window)
buttonbracketclose=CreateButton(")",140,216,24,24,window)
buttonback=CreateButton("<-",140,240,24,24,window)
buttonclear=CreateButton("C",140,264,24,24,window)

Global cmd$

Global display=CreateTextField(20,160,96,24,window)

Repeat
	WaitEvent()
	If EventID()=$803 quit=True
	
	If EventID()=$401
		If EventSource()=button0 addcmd "0"
		If EventSource()=button1 addcmd "1"
		If EventSource()=button2 addcmd "2"
		If EventSource()=button3 addcmd "3"
		If EventSource()=button4 addcmd "4"
		If EventSource()=button5 addcmd "5"
		If EventSource()=button6 addcmd "6"
		If EventSource()=button7 addcmd "7"
		If EventSource()=button8 addcmd "8"
		If EventSource()=button9 addcmd "9"
		If EventSource()=buttonmin addcmd "-"
		If EventSource()=buttonplus addcmd "+"
		If EventSource()=buttonmul addcmd "*"
		If EventSource()=buttondiv addcmd "/"
		If EventSource()=buttonexp addcmd "^"
		If EventSource()=buttonbracketopen addcmd "("
		If EventSource()=buttonbracketclose addcmd ")"
		If EventSource()=buttonclear addcmd "clear"
		If EventSource()=buttonback addcmd "bs"
		If EventSource()=buttonis
			; find the eval# function in the codearchives, and use it on cmd$
			; put the result in the display using: "updatedisplay result$"
		EndIf
	EndIf
Until quit
End

Function addcmd(s$)
	Select s$
		Case "clear"
			cmd$=""
		Case "bs'
			cmd$=Left$(cmd$,Len(cmd$)-1)
		Default
			cmd$=cmd$+s$
	End Select
	updatedisplay(cmd$)
End Function

Function updatedisplay(s$)
	SetGadgetText display,s$
End Function


Thank you very much - very useful - if you happen to remember the background solution and font size please could you let me know. Thanks again for your time and quick response.

As far as the font size goes:
window=CreateWindow("calc example - WolRon",0,0,384,384)

font = LoadFont("Arial", 34)

button0=CreateButton("0",120,244,48,48,window)
SetGadgetFont button0, font
buttondot=CreateButton(".",168,244,48,48,window)
SetGadgetFont buttondot, font
buttonis=CreateButton("=",216,244,96,48,window)
SetGadgetFont buttonis, font
Repeat
	WaitEvent()
	If EventID()=$803 quit=True
Until quit
End