-
Notifications
You must be signed in to change notification settings - Fork 25
/
input_choice.go
65 lines (55 loc) · 1.76 KB
/
input_choice.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
package fltk
/*
#include <stdlib.h>
#include "input_choice.h"
*/
import "C"
import "unsafe"
type InputChoice struct {
Group
input *Input
menuButton *MenuButton
deletionHandlerId uintptr
}
func NewInputChoice(x, y, w, h int, text ...string) *InputChoice {
c := &InputChoice{}
inputChoice := C.go_fltk_new_Input_Choice(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))
initWidget(c, unsafe.Pointer(inputChoice))
c.input = &Input{}
initUnownedWidget(c.input, unsafe.Pointer(C.go_fltk_Input_Choice_input((*C.Fl_Input_Choice)(inputChoice))))
c.menuButton = &MenuButton{}
initUnownedWidget(c.menuButton, unsafe.Pointer(C.go_fltk_Input_Choice_menubutton((*C.Fl_Input_Choice)(inputChoice))))
c.deletionHandlerId = c.addDeletionHandler(c.onDelete)
return c
}
func (c *InputChoice) onDelete() {
c.input.onDelete()
c.menuButton.onDelete()
if c.deletionHandlerId > 0 {
globalCallbackMap.unregister(c.deletionHandlerId)
}
c.deletionHandlerId = 0
}
func (c *InputChoice) Clear() {
C.go_fltk_Input_Choice_clear((*C.Fl_Input_Choice)(c.ptr()))
}
func (c *InputChoice) Value() string {
return C.GoString(C.go_fltk_Input_Choice_value((*C.Fl_Input_Choice)(c.ptr())))
}
func (c *InputChoice) SetValue(label string) {
labelStr := C.CString(label)
defer C.free(unsafe.Pointer(labelStr))
C.go_fltk_Input_Choice_set_value((*C.Fl_Input_Choice)(c.ptr()), labelStr)
}
func (c *InputChoice) SetValueIndex(index int) {
C.go_fltk_Input_Choice_set_value_index((*C.Fl_Input_Choice)(c.ptr()), C.int(index))
}
func (c *InputChoice) UpdateMenuButton() bool {
return C.go_fltk_Input_Choice_update_menubutton((*C.Fl_Input_Choice)(c.ptr())) == 1
}
func (c *InputChoice) Input() *Input {
return c.input
}
func (c *InputChoice) MenuButton() *MenuButton {
return c.menuButton
}