2014-07-30 11:34:54 -05:00
|
|
|
// 30 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
// #include "objc_darwin.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type controlParent struct {
|
2014-10-02 09:05:53 -05:00
|
|
|
id C.id
|
2014-07-30 11:34:54 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
type controlSingleObject struct {
|
|
|
|
*controlbase
|
|
|
|
id C.id
|
2014-08-03 19:08:25 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
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
|
2014-08-03 19:08:25 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (c *controlSingleObject) xsetParent(p *controlParent) {
|
|
|
|
// redrawing the new window handled by C.parent()
|
|
|
|
C.parent(c.id, p.id)
|
2014-08-03 19:08:25 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (c *controlSingleObject) xpreferredSize(d *sizing) (int, int) {
|
|
|
|
s := C.controlPreferredSize(c.id)
|
|
|
|
return int(s.width), int(s.height)
|
2014-08-03 19:08:25 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
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))
|
2014-07-30 11:34:54 -05:00
|
|
|
}
|
|
|
|
|
2014-08-03 19:08:25 -05:00
|
|
|
type scroller struct {
|
2014-10-18 16:03:07 -05:00
|
|
|
*controlSingleObject
|
|
|
|
scroller *controlSingleObject
|
2014-07-30 11:34:54 -05:00
|
|
|
}
|
|
|
|
|
2014-08-10 13:37:34 -05:00
|
|
|
func newScroller(child C.id, bordered bool) *scroller {
|
2014-10-18 16:03:07 -05:00
|
|
|
sid := C.newScrollView(child, toBOOL(bordered))
|
2014-08-03 19:08:25 -05:00
|
|
|
s := &scroller{
|
2014-10-18 16:03:07 -05:00
|
|
|
controlSingleObject: newControlSingleObject(child),
|
|
|
|
scroller: newControlSingleObject(sid),
|
2014-07-30 11:34:54 -05:00
|
|
|
}
|
2014-10-18 16:03:07 -05:00
|
|
|
s.fsetParent = s.scroller.fsetParent
|
|
|
|
s.fresize = s .scroller.fresize
|
2014-07-30 11:34:54 -05:00
|
|
|
return s
|
|
|
|
}
|