summaryrefslogtreecommitdiff
path: root/newctrl/control_darwin.go
blob: 330d50ce33779b364541008015ddff38f2b7c64a (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
// 30 july 2014

package ui

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

type controlParent struct {
	id C.id
}

type controlSingleObject struct {
	*controlbase
	id	C.id
}

func newControlSingleObject(id C.id) *controlSingleObject {
	c := new(controlSingleObject)
	c.controlbase = &controlbase{
		fsetParent:		c.xsetParent,
		fpreferredSize:		c.xpreferredSize,
		fresize:			c.xresize,
	}
	c.id = id
	return c
}

func (c *controlSingleObject) xsetParent(p *controlParent) {
	// redrawing the new window handled by C.parent()
	C.parent(c.id, p.id)
}

func (c *controlSingleObject) xpreferredSize(d *sizing) (int, int) {
	s := C.controlPreferredSize(c.id)
	return int(s.width), int(s.height)
}

func (c *controlSingleObject) xresize(x int, y int, width int, height int, d *sizing) {
	C.moveControl(c.id, C.intptr_t(x), C.intptr_t(y), C.intptr_t(width), C.intptr_t(height))
}

type scroller struct {
	*controlSingleObject
	scroller	*controlSingleObject
}

func newScroller(child C.id, bordered bool) *scroller {
	sid := C.newScrollView(child, toBOOL(bordered))
	s := &scroller{
		controlSingleObject:		newControlSingleObject(child),
		scroller:				newControlSingleObject(sid),
	}
	s.fsetParent = s.scroller.fsetParent
	s.fresize = s .scroller.fresize
	return s
}