2014-07-30 11:34:54 -05:00
|
|
|
// 30 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
// #include "objc_darwin.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type controlbase struct {
|
|
|
|
*controldefs
|
|
|
|
id C.id
|
|
|
|
}
|
|
|
|
|
|
|
|
type controlParent struct {
|
|
|
|
id C.id
|
|
|
|
}
|
|
|
|
|
|
|
|
func newControl(id C.id) *controlbase {
|
|
|
|
c := new(controlbase)
|
|
|
|
c.id = id
|
|
|
|
c.controldefs = new(controldefs)
|
|
|
|
c.fsetParent = func(p *controlParent) {
|
|
|
|
// redrawing the new window handled by C.parent()
|
|
|
|
C.parent(c.id, p.id)
|
|
|
|
}
|
|
|
|
c.fcontainerShow = func() {
|
|
|
|
C.controlSetHidden(c.id, C.NO)
|
|
|
|
}
|
|
|
|
c.fcontainerHide = func() {
|
|
|
|
C.controlSetHidden(c.id, C.YES)
|
|
|
|
}
|
2014-07-30 19:38:01 -05:00
|
|
|
c.fallocate = baseallocate(c)
|
2014-07-30 11:34:54 -05:00
|
|
|
c.fpreferredSize = func(d *sizing) (int, int) {
|
2014-08-02 07:04:44 -05:00
|
|
|
s := C.controlPrefSize(c.id)
|
|
|
|
return int(s.width), int(s.height)
|
2014-07-30 11:34:54 -05:00
|
|
|
}
|
|
|
|
c.fcommitResize = func(a *allocation, d *sizing) {
|
|
|
|
C.moveControl(c.id, C.intptr_t(a.x), C.intptr_t(a.y), C.intptr_t(a.width), C.intptr_t(a.height))
|
|
|
|
}
|
|
|
|
c.fgetAuxResizeInfo = func(d *sizing) {
|
2014-08-02 08:47:57 -05:00
|
|
|
d.neighborAlign = C.alignmentInfo(c.id, C.frame(c.id))
|
2014-07-30 11:34:54 -05:00
|
|
|
}
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
type scrolledcontrol struct {
|
|
|
|
*controlbase
|
|
|
|
scroller *controlbase
|
|
|
|
}
|
|
|
|
|
|
|
|
func newScrolledControl(id C.id) *scrolledcontrol {
|
|
|
|
scroller := C.newScrollView(id)
|
|
|
|
s := &scrolledcontrol{
|
|
|
|
controlbase: newControl(id),
|
|
|
|
scroller: newControl(scroller),
|
|
|
|
}
|
|
|
|
s.fsetParent = s.scroller.fsetParent
|
|
|
|
s.fcommitResize = s.scroller.fcommitResize
|
|
|
|
return s
|
|
|
|
}
|