diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-27 15:21:47 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-27 15:21:47 -0400 |
| commit | bd44815a5480061b48106d209767e3ad6d724a13 (patch) | |
| tree | c3b779b4335cba07edf25bc76224ec2b44c8b3ad /container_unix.go | |
| parent | f9699ff93851ef962e999beef0d7b93348afda5b (diff) | |
Migrated the GTK+ backend to the new new container system in which containers are no longer full controls but are still used to hold more than one control and handle the resizing entirely on their own.
Diffstat (limited to 'container_unix.go')
| -rw-r--r-- | container_unix.go | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/container_unix.go b/container_unix.go index 90bc84b..c9ed89c 100644 --- a/container_unix.go +++ b/container_unix.go @@ -11,9 +11,12 @@ import ( // #include "gtk_unix.h" import "C" +// TODO avoid direct access to contents? type container struct { - *controlSingleWidget - container *C.GtkContainer + widget *C.GtkWidget + container *C.GtkContainer + resize func(x int, y int, width int, height int, d *sizing) + margined bool } type sizing struct { @@ -28,7 +31,7 @@ type sizing struct { func newContainer() *container { c := new(container) - c.controlSingleWidget = newControlSingleWidget(C.newContainer(unsafe.Pointer(c))) + c.widget = C.newContainer(unsafe.Pointer(c)) c.container = (*C.GtkContainer)(unsafe.Pointer(c.widget)) return c } @@ -37,26 +40,19 @@ func (c *container) parent() *controlParent { return &controlParent{c.container} } -func (c *container) allocation(margined bool) C.GtkAllocation { - var a C.GtkAllocation - - C.gtk_widget_get_allocation(c.widget, &a) - if margined { +//export containerResize +func containerResize(data unsafe.Pointer, aorig *C.GtkAllocation) { + c := (*container)(data) + d := beginResize() + // copy aorig + a := *aorig + if c.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) + c.resize(int(a.x), int(a.y), int(a.width), int(a.height), d) } const ( @@ -66,7 +62,7 @@ const ( gtkYPadding = 6 ) -func (w *window) beginResize() (d *sizing) { +func beginResize() (d *sizing) { d = new(sizing) d.xpadding = gtkXPadding d.ypadding = gtkYPadding |
