2020-05-03 11:30:20 +02:00
|
|
|
package kernel
|
2020-11-12 01:57:05 +01:00
|
|
|
|
2020-05-03 11:30:20 +02:00
|
|
|
import "os"
|
2020-11-12 01:43:46 +01:00
|
|
|
import "colors"
|
2020-05-03 11:30:20 +02:00
|
|
|
|
2020-11-12 01:43:46 +01:00
|
|
|
const (
|
|
|
|
Btn1=2;
|
|
|
|
Btn2=3;
|
|
|
|
BtnExit=1;
|
|
|
|
)
|
|
|
|
|
2021-07-13 18:16:46 +02:00
|
|
|
type Button struct { // structure gui button
|
|
|
|
label string
|
|
|
|
x int
|
|
|
|
y int
|
|
|
|
id int
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewButton() Button {
|
|
|
|
object := Button{"Text",0,0,Btn1} // default data
|
|
|
|
return object
|
|
|
|
}
|
|
|
|
|
|
|
|
func (button *Button) make() {
|
|
|
|
os.CreateButton(button.x, button.y, len(button.label)*15, 30, button.id, colors.Blue);
|
|
|
|
os.WriteText(button.x,button.y, 0x11000000 | colors.White, button.label)
|
|
|
|
}
|
|
|
|
|
2020-11-12 01:43:46 +01:00
|
|
|
func RedrawAll(bar_pos int){
|
2021-07-12 14:28:41 +02:00
|
|
|
os.Redraw(1)
|
2021-07-13 18:16:46 +02:00
|
|
|
os.Window(500,250,420,200, "Example GoLang")
|
2020-11-12 01:43:46 +01:00
|
|
|
os.DrawLine(32, 80, 150, 80, colors.Green)
|
2021-07-12 14:28:41 +02:00
|
|
|
os.DrawBar(bar_pos, 90, 100, 30, colors.Red);
|
2021-07-13 18:16:46 +02:00
|
|
|
|
|
|
|
b1 := NewButton()
|
|
|
|
b1.label = " <- "
|
|
|
|
b1.x = 32
|
|
|
|
b1.y = 128
|
|
|
|
b1.id = Btn1
|
|
|
|
b1.make()
|
|
|
|
|
|
|
|
b2 := NewButton()
|
|
|
|
b2.label = " -> "
|
|
|
|
b2.x = 310
|
|
|
|
b2.y = 128
|
|
|
|
b2.id = Btn2
|
|
|
|
b2.make()
|
2020-11-12 01:43:46 +01:00
|
|
|
}
|
2020-05-03 11:30:20 +02:00
|
|
|
|
2021-07-13 18:16:46 +02:00
|
|
|
func Main() {
|
|
|
|
var pos = 160;
|
2021-07-12 14:28:41 +02:00
|
|
|
//time := os.GetTime()
|
|
|
|
//os.DebugOutStr("Time: ")
|
|
|
|
//os.DebugOutHex(time)
|
2020-11-12 01:43:46 +01:00
|
|
|
for true {
|
|
|
|
switch os.Event() {
|
2021-07-13 18:16:46 +02:00
|
|
|
case os.EVENT_REDRAW:
|
2020-11-12 01:43:46 +01:00
|
|
|
RedrawAll(pos)
|
|
|
|
break
|
|
|
|
case os.EVENT_BUTTON:
|
2021-07-13 18:16:46 +02:00
|
|
|
switch os.GetButtonID() {
|
|
|
|
case Btn1:
|
|
|
|
pos-=32
|
|
|
|
RedrawAll(pos)
|
|
|
|
break
|
|
|
|
case Btn2:
|
|
|
|
pos+=32
|
|
|
|
RedrawAll(pos);
|
|
|
|
break
|
|
|
|
case BtnExit:
|
|
|
|
os.Exit()
|
|
|
|
}
|
2020-05-03 11:30:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|