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
|
2014-10-02 09:05:53 -05:00
|
|
|
layoutwidget *C.GtkWidget
|
|
|
|
layoutcontainer *C.GtkContainer
|
2014-08-04 20:08:18 -05:00
|
|
|
}
|
|
|
|
|
2014-08-04 21:21:58 -05:00
|
|
|
type sizing struct {
|
|
|
|
sizingbase
|
|
|
|
|
|
|
|
// for size calculations
|
|
|
|
// gtk+ needs nothing
|
|
|
|
|
|
|
|
// for the actual resizing
|
2014-10-02 09:05:53 -05:00
|
|
|
shouldVAlignTop bool
|
2014-08-04 21:21:58 -05:00
|
|
|
}
|
|
|
|
|
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 (
|
2014-10-02 09:05:53 -05:00
|
|
|
gtkXMargin = 12
|
|
|
|
gtkYMargin = 12
|
2014-08-02 00:14:09 -05:00
|
|
|
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)
|
2014-10-12 10:54:58 -05:00
|
|
|
if spaced {
|
2014-08-02 00:14:09 -05:00
|
|
|
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+
|
|
|
|
}
|