forked from pwiecz/go-fltk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.go
97 lines (81 loc) · 2.42 KB
/
button.go
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package fltk
/*
#include "button.h"
*/
import "C"
import "unsafe"
type Button struct {
widget
}
func NewButton(x, y, w, h int, text ...string) *Button {
b := &Button{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}
func (b *Button) Value() bool {
return C.go_fltk_Button_value((*C.Fl_Button)(b.ptr())) != C.char(0)
}
func (b *Button) SetValue(val bool) {
if val {
C.go_fltk_Button_set_value((*C.Fl_Button)(b.ptr()), 1)
} else {
C.go_fltk_Button_set_value((*C.Fl_Button)(b.ptr()), 0)
}
}
func (b *Button) SetDownBox(box BoxType) {
C.go_fltk_Button_set_down_box((*C.Fl_Button)(b.ptr()), C.int(box))
}
func (b *Button) SetShortcut(shortcut int) {
C.go_fltk_Button_set_shortcut((*C.Fl_Button)(b.ptr()), C.int(shortcut))
}
func (b *Button) Shortcut() int {
return int(C.go_fltk_Button_shortcut((*C.Fl_Button)(b.ptr())))
}
type CheckButton struct {
Button
}
func NewCheckButton(x, y, w, h int, text ...string) *CheckButton {
b := &CheckButton{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Check_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}
type RadioButton struct {
Button
}
func NewRadioButton(x, y, w, h int, text ...string) *RadioButton {
b := &RadioButton{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Radio_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}
type RadioRoundButton struct {
Button
}
func NewRadioRoundButton(x, y, w, h int, text ...string) *RadioRoundButton {
b := &RadioRoundButton{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Radio_Round_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}
type ReturnButton struct {
Button
}
func NewReturnButton(x, y, w, h int, text ...string) *ReturnButton {
b := &ReturnButton{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Return_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}
type ToggleButton struct {
Button
}
func NewToggleButton(x, y, w, h int, text ...string) *ToggleButton {
b := &ToggleButton{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Toggle_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}
type LightButton struct {
Button
}
func NewLightButton(x, y, w, h int, text ...string) *LightButton {
b := &LightButton{}
initWidget(b, unsafe.Pointer(C.go_fltk_new_Light_Button(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return b
}