summaryrefslogtreecommitdiff
path: root/spinbox_unix.go
blob: 33ac2f3ee5d3bd6d5978ced3dbc1bd11c9cd73a8 (plain)
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
// +build !windows,!darwin

// 28 october 2014

package ui

import (
	"unsafe"
)

// #include "gtk_unix.h"
import "C"

// TODO preferred width may be too wide

type spinbox struct {
	*controlSingleWidget
	spinbutton	*C.GtkSpinButton
}

func newSpinbox() Spinbox {
	widget := C.gtk_spin_button_new_with_range(0, 100, 1)
	s := &spinbox{
		controlSingleWidget:	newControlSingleWidget(widget),
		spinbutton:			(*C.GtkSpinButton)(unsafe.Pointer(widget)),
	}
	C.gtk_spin_button_set_digits(s.spinbutton, 0)				// integers
	C.gtk_spin_button_set_numeric(s.spinbutton, C.TRUE)		// digits only
	return s
}