From 649b52b6ef273c2ea5a4cf881835a7fd61bd4df1 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 28 Oct 2014 11:01:02 -0400 Subject: Set up the absolute basic Spinbox and implemented it on GTK+. This is easy as it's one control on GTK+; now we have to do it on Windows and Mac OS X. And on those platforms, those are two separate controls (a standard edit control and an up-down/NSSpinner). --- spinbox_unix.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spinbox_unix.go (limited to 'spinbox_unix.go') diff --git a/spinbox_unix.go b/spinbox_unix.go new file mode 100644 index 0000000..33ac2f3 --- /dev/null +++ b/spinbox_unix.go @@ -0,0 +1,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 +} -- cgit v1.2.3