summaryrefslogtreecommitdiff
path: root/basicctrls.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-30 12:16:42 -0400
committerPietro Gagliardi <[email protected]>2014-10-30 12:17:09 -0400
commit6428b17b7f92abbb84ef61361dd9ee2a3ebcae9f (patch)
tree19398ed7987ae93a162c3300a40b2fa416d75832 /basicctrls.go
parentb28781f281a7a65a89e4d7c830c773f6382fb6fb (diff)
Started fleshing out the Spinbox interface. Added Value() and SetValue(); implemented on GTK+. Added min and max to the constructor; implemented on GTK+.
Diffstat (limited to 'basicctrls.go')
-rw-r--r--basicctrls.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/basicctrls.go b/basicctrls.go
index 4029d4e..8e4e926 100644
--- a/basicctrls.go
+++ b/basicctrls.go
@@ -143,8 +143,7 @@ func NewTextbox() Textbox {
// Spinbox is a Control that provides a text entry field that accepts integers and up and down buttons to increment and decrement those values.
// This control is in its preliminary state.
// TODO everything:
-// - TODO set increment
-// - TODO set step
+// - TODO set increment? (work on windows)
// - TODO set page step?
// - TODO wrapping
// - TODO set/get integer value
@@ -152,9 +151,19 @@ func NewTextbox() Textbox {
// - TODO ensuring values entered in text box stay within bounds
type Spinbox interface {
Control
+
+ // Value and SetValue get and set the current value of the Spinbox, respectively.
+ // For SetValue, if the new value is outside the current range of the Spinbox, it is set to the nearest extremity.
+ Value() int
+ SetValue(value int)
}
-// NewSpinbox creates a new Spinbox.
-func NewSpinbox() Spinbox {
- return newSpinbox()
+// NewSpinbox creates a new Spinbox with the given minimum and maximum.
+// The initial value will be the minimum value.
+// NewSpinbox() panics if min > max.
+func NewSpinbox(min int, max int) Spinbox {
+ if min > max {
+ panic("min > max in NewSpinbox()")
+ }
+ return newSpinbox(min, max)
}