diff options
| author | Pietro Gagliardi <[email protected]> | 2018-08-26 09:55:07 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2018-08-26 09:55:07 -0400 |
| commit | 62ac2527732a01dfa6bd2c9523215c0ba3816641 (patch) | |
| tree | 84244a69e048f79e4d9f134c121f4cf581200986 /spinbox.go | |
| parent | a5a00c644c08a6e0f52740c3f2a280977929a285 (diff) | |
Moved all the Go files out of the way again, this time so we can migrate them to more proper cgo usage.
Diffstat (limited to 'spinbox.go')
| -rw-r--r-- | spinbox.go | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/spinbox.go b/spinbox.go deleted file mode 100644 index 27dd287..0000000 --- a/spinbox.go +++ /dev/null @@ -1,58 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doSpinboxOnChanged(uiSpinbox *, void *); -// // see golang/go#19835 -// typedef void (*spinboxCallback)(uiSpinbox *, void *); -import "C" - -// Spinbox is a Control that represents a space where the user can -// enter integers. The space also comes with buttons to add or -// subtract 1 from the integer. -type Spinbox struct { - ControlBase - s *C.uiSpinbox - onChanged func(*Spinbox) -} - -// NewSpinbox creates a new Spinbox. If min >= max, they are swapped. -func NewSpinbox(min int, max int) *Spinbox { - s := new(Spinbox) - - s.s = C.uiNewSpinbox(C.int(min), C.int(max)) - - C.uiSpinboxOnChanged(s.s, C.spinboxCallback(C.doSpinboxOnChanged), nil) - - s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s))) - return s -} - -// Value returns the Spinbox's current value. -func (s *Spinbox) Value() int { - return int(C.uiSpinboxValue(s.s)) -} - -// SetValue sets the Spinbox's current value to value. -func (s *Spinbox) SetValue(value int) { - C.uiSpinboxSetValue(s.s, C.int(value)) -} - -// OnChanged registers f to be run when the user changes the value -// of the Spinbox. Only one function can be registered at a time. -func (s *Spinbox) OnChanged(f func(*Spinbox)) { - s.onChanged = f -} - -//export doSpinboxOnChanged -func doSpinboxOnChanged(ss *C.uiSpinbox, data unsafe.Pointer) { - s := ControlFromLibui(uintptr(unsafe.Pointer(ss))).(*Spinbox) - if s.onChanged != nil { - s.onChanged(s) - } -} |
