-
Notifications
You must be signed in to change notification settings - Fork 6
/
toy.nim
62 lines (45 loc) · 1.3 KB
/
toy.nim
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
# Test & show the new high level wrapper
import uing
proc main*() =
var mainwin: Window
var menu = newMenu("File")
menu.addItem("Open", proc(_: MenuItem, win: Window) =
let filename = win.openFile()
if filename.len == 0:
win.error("No file selected", "Don't be alarmed!")
else:
win.msgBox("File selected", filename)
)
menu.addItem("Save", proc(_: MenuItem, win: Window) =
let filename = win.saveFile()
if filename.len == 0:
win.error("No file selected", "Don't be alarmed!")
else:
win.msgBox("File selected (don't worry, it's still there)", filename)
)
menu.addQuitItem(
proc(): bool =
mainwin.destroy()
return true
)
menu = newMenu("Edit")
menu.addCheckItem("Checkable Item")
menu.addSeparator()
disable menu.addItem("Disabled Item")
menu.addPreferencesItem()
menu = newMenu("Help")
menu.addItem("Help")
menu.addAboutItem()
mainwin = newWindow("libui-ng Control Gallery", 640, 480, true)
mainwin.margined = true
let box = newVerticalBox(true)
mainwin.child = box
let group = newGroup("Basic Controls", true)
box.add group
let inner = newVerticalBox(true)
group.child = inner
inner.add newButton("Button", proc(_: Button) = mainwin.error("Error", "Rotec"))
show mainwin
mainLoop()
init()
main()