diff options
Diffstat (limited to 'container_darwin.go')
| -rw-r--r-- | container_darwin.go | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/container_darwin.go b/container_darwin.go index b2086c4..58b7777 100644 --- a/container_darwin.go +++ b/container_darwin.go @@ -10,33 +10,44 @@ import ( import "C" type container struct { - containerbase - id C.id + *controlSingleObject } type sizing struct { sizingbase // for size calculations - // nothing for mac + // nothing on Mac OS X // for the actual resizing neighborAlign C.struct_xalignment } -func newContainer(child Control) *container { +func newContainer() *container { c := new(container) - c.id = C.newContainerView(unsafe.Pointer(c)) - c.child = child - c.child.setParent(&controlParent{c.id}) + c.controlSingleObject = newControlSingleObject(C.newContainerView(unsafe.Pointer(c))) return c } -//export containerResized -func containerResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) { - c := (*container)(unsafe.Pointer(data)) - // the origin of a view's content area is always (0, 0) - c.resize(0, 0, int(width), int(height)) +func (c *container) parent() *controlParent { + return &controlParent{c.id} +} + +func (c *container) allocation(margined bool) C.struct_xrect { + b := C.containerBounds(c.id) + if margined { + b.x += C.intptr_t(macXMargin) + b.y += C.intptr_t(macYMargin) + b.width -= C.intptr_t(macXMargin) * 2 + b.height -= C.intptr_t(macYMargin) * 2 + } + return b +} + +// we can just return these values as is +func (c *container) bounds(d *sizing) (int, int, int, int) { + b := C.containerBounds(c.id) + return int(b.x), int(b.y), int(b.width), int(b.height) } // These are based on measurements from Interface Builder. @@ -47,18 +58,14 @@ const ( macYPadding = 8 ) -func (c *container) beginResize() (d *sizing) { +func (w *window) beginResize() (d *sizing) { d = new(sizing) - if spaced { - d.xmargin = macXMargin - d.ymargintop = macYMargin - d.ymarginbottom = d.ymargintop - d.xpadding = macXPadding - d.ypadding = macYPadding - } + d.xpadding = macXPadding + d.ypadding = macYPadding return d } +/*TODO func (c *container) translateAllocationCoords(allocations []*allocation, winwidth, winheight int) { for _, a := range allocations { // winheight - y because (0,0) is the bottom-left corner of the window and not the top-left corner @@ -66,3 +73,4 @@ func (c *container) translateAllocationCoords(allocations []*allocation, winwidt a.y = (winheight - a.y) - a.height } } +*/ |
