forked from pwiecz/go-fltk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.go
59 lines (51 loc) · 1.52 KB
/
input.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
package fltk
/*
#include <stdlib.h>
#include "input.h"
*/
import "C"
import "unsafe"
type Input struct {
widget
}
func NewInput(x, y, w, h int, text ...string) *Input {
i := &Input{}
initWidget(i, unsafe.Pointer(C.go_fltk_new_Input(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return i
}
func (i *Input) Value() string {
return C.GoString(C.go_fltk_Input_value((*C.Fl_Input)(i.ptr())))
}
func (i *Input) SetValue(value string) bool {
valueStr := C.CString(value)
defer C.free(unsafe.Pointer(valueStr))
return C.go_fltk_Input_set_value((*C.Fl_Input)(i.ptr()), valueStr) != 0
}
func (i *Input) Resize(x int, y int, w int, h int) {
C.go_fltk_Input_resize((*C.Fl_Input)(i.ptr()), C.int(x), C.int(y), C.int(w), C.int(h))
}
func (i *Input) SetInsertPosition(pos, mark int) {
C.go_fltk_Input_set_insert_position((*C.Fl_Input)(i.ptr()), C.int(pos), C.int(mark))
}
func (i *Input) InsertPosition() int {
return int(C.go_fltk_Input_insert_position((*C.Fl_Input)(i.ptr())))
}
func (i *Input) Mark() int {
return int(C.go_fltk_Input_mark((*C.Fl_Input)(i.ptr())))
}
type Output struct {
Input
}
func NewOutput(x, y, w, h int, text ...string) *Output {
i := &Output{}
initWidget(i, unsafe.Pointer(C.go_fltk_new_Output(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return i
}
type FloatInput struct {
Input
}
func NewFloatInput(x, y, w, h int, text ...string) *FloatInput {
i := &FloatInput{}
initWidget(i, unsafe.Pointer(C.go_fltk_new_Float_Input(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(text))))
return i
}