summaryrefslogtreecommitdiff
path: root/spinbox_darwin.go
blob: 515c8e8ae7c6739688a8785d85da05bd374d33a2 (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
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
60
61
62
63
64
65
66
67
68
// 28 october 2014

package ui

import (
	"unsafe"
)

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

// interface builder notes
// - the tops of the alignment rects should be identical
// - spinner properties: auto repeat
// - http://stackoverflow.com/questions/702829/integrate-nsstepper-with-nstextfield we'll need to bind the int value :S
// 	- TODO experiment with a dummy project
// - http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/059-NSStepper-NSTextField.pl
// - http://www.youtube.com/watch?v=ZZSHU-O7HVo
// - http://andrehoffmann.wordpress.com/tag/nsstepper/ ?
// TODO
// - proper spacing between edit and spinner: Interface Builder isn't clear; NSDatePicker doesn't spill the beans

type spinbox struct {
	id	C.id
}

func newSpinbox() Spinbox {
	s := new(spinbox)
	s.id = C.newSpinbox(unsafe.Pointer(s))
	return s
}

func (s *spinbox) textfield() C.id {
	return C.spinboxTextField(s.id)
}

func (s *spinbox) stepper() C.id {
	return C.spinboxStepper(s.id)
}

func (s *spinbox) setParent(p *controlParent) {
	C.parent(s.textfield(), p.id)
	C.parent(s.stepper(), p.id)
}

func (s *spinbox) preferredSize(d *sizing) (width, height int) {
	// TODO
	return 20, 20
}

func (s *spinbox) resize(x int, y int, width int, height int, d *sizing) {
	// TODO
	C.moveControl(s.textfield(), C.intptr_t(x), C.intptr_t(y), C.intptr_t(width - 20), C.intptr_t(height))
	C.moveControl(s.stepper(), C.intptr_t(x + width - 15), C.intptr_t(y), C.intptr_t(15), C.intptr_t(height))
}

func (s *spinbox) nTabStops() int {
	// TODO does the stepper count?
	return 1
}

func (s *spinbox) containerShow() {
	// only provided for the Windows backend
}

func (s *spinbox) containerHide() {
	// only provided for the Windows backend
}