2014-08-02 00:14:09 -05:00
|
|
|
// +build !windows,!darwin
|
|
|
|
|
|
|
|
// 23 february 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "gtk_unix.h"
|
|
|
|
import "C"
|
|
|
|
|
2014-08-04 20:08:18 -05:00
|
|
|
type container struct {
|
|
|
|
containerbase
|
|
|
|
layoutwidget *C.GtkWidget
|
|
|
|
layoutcontainer *C.GtkContainer
|
|
|
|
}
|
|
|
|
|
2014-08-04 21:21:58 -05:00
|
|
|
type sizing struct {
|
|
|
|
sizingbase
|
|
|
|
|
|
|
|
// for size calculations
|
|
|
|
// gtk+ needs nothing
|
|
|
|
|
|
|
|
// for the actual resizing
|
|
|
|
shouldVAlignTop bool
|
|
|
|
}
|
|
|
|
|
2014-08-04 20:08:18 -05:00
|
|
|
func newContainer(child Control) *container {
|
2014-08-13 22:37:54 -05:00
|
|
|
c := new(container)
|
|
|
|
widget := C.newContainer(unsafe.Pointer(c))
|
|
|
|
c.layoutwidget = widget
|
|
|
|
c.layoutcontainer = (*C.GtkContainer)(unsafe.Pointer(widget))
|
2014-08-04 20:08:18 -05:00
|
|
|
c.child = child
|
|
|
|
c.child.setParent(&controlParent{c.layoutcontainer})
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2014-08-04 21:21:58 -05:00
|
|
|
func (c *container) setParent(p *controlParent) {
|
|
|
|
C.gtk_container_add(p.c, c.layoutwidget)
|
|
|
|
}
|
|
|
|
|
2014-08-04 20:08:18 -05:00
|
|
|
//export containerResizing
|
2014-08-13 22:37:54 -05:00
|
|
|
func containerResizing(data unsafe.Pointer, r *C.GtkAllocation) {
|
|
|
|
c := (*container)(data)
|
|
|
|
c.resize(int(r.x), int(r.y), int(r.width), int(r.height))
|
2014-08-04 20:08:18 -05:00
|
|
|
}
|
|
|
|
|
2014-08-02 00:14:09 -05:00
|
|
|
const (
|
|
|
|
gtkXMargin = 12
|
|
|
|
gtkYMargin = 12
|
|
|
|
gtkXPadding = 12
|
|
|
|
gtkYPadding = 6
|
|
|
|
)
|
|
|
|
|
2014-08-04 20:08:18 -05:00
|
|
|
func (c *container) beginResize() (d *sizing) {
|
2014-08-02 00:14:09 -05:00
|
|
|
d = new(sizing)
|
|
|
|
if spaced {
|
|
|
|
d.xmargin = gtkXMargin
|
2014-08-24 20:23:19 -05:00
|
|
|
d.ymargintop = gtkYMargin
|
|
|
|
d.ymarginbottom = d.ymargintop
|
2014-08-02 00:14:09 -05:00
|
|
|
d.xpadding = gtkXPadding
|
|
|
|
d.ypadding = gtkYPadding
|
|
|
|
}
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
2014-08-04 20:08:18 -05:00
|
|
|
func (c *container) translateAllocationCoords(allocations []*allocation, winwidth, winheight int) {
|
2014-08-02 00:14:09 -05:00
|
|
|
// no need for coordinate conversion with gtk+
|
|
|
|
}
|