From 95815841aa7574f5fd91d11795ceacaa4b7fa5fa Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 4 Aug 2014 21:27:35 -0400 Subject: [PATCH] Merged cases of C.moveWindow() on Windows containers to one place (container_windows.go) as a method on container. --- redo/container_windows.go | 5 +++++ redo/tab_windows.go | 4 +--- redo/window_windows.go | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/redo/container_windows.go b/redo/container_windows.go index 06fbb5b..b79a79f 100644 --- a/redo/container_windows.go +++ b/redo/container_windows.go @@ -52,6 +52,11 @@ func (c *container) setParent(p *controlParent) { C.controlSetParent(c.hwnd, p.hwnd) } +// this is needed because Windows won't move/resize a child window for us +func (c *container) move(r *C.RECT) { + C.moveWindow(c.hwnd, C.int(r.left), C.int(r.top), C.int(r.right - r.left), C.int(r.bottom - r.top)) +} + //export storeContainerHWND func storeContainerHWND(data unsafe.Pointer, hwnd C.HWND) { c := (*container)(data) diff --git a/redo/tab_windows.go b/redo/tab_windows.go index 3456502..c16cdb4 100644 --- a/redo/tab_windows.go +++ b/redo/tab_windows.go @@ -106,9 +106,7 @@ func (t *tab) commitResize(c *allocation, d *sizing) { // don't resize just the current tab; resize all tabs! for _, c := range t.tabs { // because each widget is actually a child of the Window, the origin is the one we calculated above - // we use moveWindow() rather than calling resize() directly - // TODO - C.moveWindow(c.hwnd, C.int(r.left), C.int(r.top), C.int(r.right - r.left), C.int(r.bottom - r.top)) + c.move(&r) } // and now resize the tab control itself basecommitResize(t, c, d) diff --git a/redo/window_windows.go b/redo/window_windows.go index 2c391c8..3a551c2 100644 --- a/redo/window_windows.go +++ b/redo/window_windows.go @@ -88,8 +88,7 @@ func storeWindowHWND(data unsafe.Pointer, hwnd C.HWND) { func windowResize(data unsafe.Pointer, r *C.RECT) { w := (*window)(data) // the origin of the window's content area is always (0, 0), but let's use the values from the RECT just to be safe - // TODO - C.moveWindow(w.container.hwnd, C.int(r.left), C.int(r.top), C.int(r.right - r.left), C.int(r.bottom - r.top)) + w.container.move(r) } //export windowClosing