-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckbox.go
87 lines (76 loc) · 1.96 KB
/
checkbox.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
package newt
/*
#cgo pkg-config: libnewt
#cgo LDFLAGS: -lnewt
#include <stdio.h>
#include <stdlib.h>
#include <newt.h>
*/
import "C"
import (
"unsafe"
)
/* Components */
func Checkbox(left, top int, text string, defValue, seq string, result *ResultStr) Component {
var c Component
t := C.CString(text)
var s *C.char
if seq == "" {
s = nil
} else {
s = C.CString(seq)
}
defer C.free(unsafe.Pointer(t))
defer C.free(unsafe.Pointer(s))
c.c = C.newtCheckbox(C.int(left), C.int(top), t, C.char(defValue[0]), s, result.value)
c.t = GRID_COMPONENT
c.ct = CMP_CHECKBOX
return c
}
func CheckboxGetValue(c Component) int {
if c.ct == CMP_CHECKBOX {
return int(C.newtCheckboxGetValue(c.c))
} else {
return -1
}
}
func CheckboxSetValue(c Component, value int) {
if c.ct == CMP_CHECKBOX {
C.newtCheckboxSetValue(c.c, C.char(value))
}
}
func CheckboxSetFlags(c Component, flags int, sense uint32) {
if c.ct == CMP_CHECKBOX {
C.newtCheckboxSetFlags(c.c, C.int(flags), sense)
}
}
func Radiobutton(left, top int, text string, isDefault int, prevButton *Component) Component {
var c Component
t := C.CString(text)
defer C.free(unsafe.Pointer(t))
if prevButton == nil {
c.c = C.newtRadiobutton(C.int(left), C.int(top), t, C.int(isDefault), nil)
} else {
c.c = C.newtRadiobutton(C.int(left), C.int(top), t, C.int(isDefault), prevButton.c)
}
c.t = GRID_COMPONENT
c.ct = CMP_RADIOBUTTON
return c
}
func RadioGetCurrent(setMember Component) Component {
if setMember.ct == CMP_RADIOBUTTON {
var c Component
c.c = C.newtRadioGetCurrent(setMember.c)
c.t = GRID_COMPONENT
c.ct = CMP_RADIOBUTTON
return c
} else {
var c Component
return c
}
}
func RadioSetCurrent(setMember Component) {
if setMember.ct == CMP_RADIOBUTTON {
C.newtRadioSetCurrent(setMember.c)
}
}