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 {
|
2014-10-18 16:03:07 -05:00
|
|
|
*controlSingleWidget
|
|
|
|
container *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-18 16:03:07 -05:00
|
|
|
// gtk+ needs nothing
|
2014-08-04 21:21:58 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func newContainer() *container {
|
2014-08-13 22:37:54 -05:00
|
|
|
c := new(container)
|
2014-10-18 16:03:07 -05:00
|
|
|
c.controlSingleWidget = newControlSingleWidget(C.newContainer(unsafe.Pointer(c)))
|
|
|
|
c.container = (*C.GtkContainer)(unsafe.Pointer(c.widget))
|
2014-08-04 20:08:18 -05:00
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (c *container) parent() *controlParent {
|
|
|
|
return &controlParent{c.container}
|
2014-08-04 21:21:58 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (c *container) allocation(margined bool) C.GtkAllocation {
|
|
|
|
var a C.GtkAllocation
|
|
|
|
|
|
|
|
C.gtk_widget_get_allocation(c.widget, &a)
|
|
|
|
if margined {
|
|
|
|
a.x += C.int(gtkXMargin)
|
|
|
|
a.y += C.int(gtkYMargin)
|
|
|
|
a.width -= C.int(gtkXMargin) * 2
|
|
|
|
a.height -= C.int(gtkYMargin) * 2
|
|
|
|
}
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
// we can just return these values as is
|
|
|
|
// note that allocations of a widget on GTK+ have their origin in the /window/ origin
|
|
|
|
func (c *container) bounds(d *sizing) (int, int, int, int) {
|
|
|
|
var a C.GtkAllocation
|
|
|
|
|
|
|
|
C.gtk_widget_get_allocation(c.widget, &a)
|
|
|
|
return int(a.x), int(a.y), int(a.width), int(a.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-10-18 16:03:07 -05:00
|
|
|
func (w *window) beginResize() (d *sizing) {
|
2014-08-02 00:14:09 -05:00
|
|
|
d = new(sizing)
|
2014-10-18 16:03:07 -05:00
|
|
|
d.xpadding = gtkXPadding
|
|
|
|
d.ypadding = gtkYPadding
|
2014-08-02 00:14:09 -05:00
|
|
|
return d
|
|
|
|
}
|