From 474436e9f6e84f26edd08bfcff16d62a3cd40175 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 15 Jul 2014 14:04:20 -0400 Subject: [PATCH] Implemented window resize handling on Mac OS X. Now for actually setting child controls and resizing them. --- redo/window_darwin.go | 9 ++++++++- redo/window_darwin.m | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/redo/window_darwin.go b/redo/window_darwin.go index c3d4521..be9ceec 100644 --- a/redo/window_darwin.go +++ b/redo/window_darwin.go @@ -4,6 +4,7 @@ package ui import ( "unsafe" +"fmt" ) // #include "objc_darwin.h" @@ -123,7 +124,13 @@ func windowClosing(xw unsafe.Pointer) C.BOOL { } return C.NO } - + +//export windowResized +func windowResized(xw unsafe.Pointer, width C.uintptr_t, height C.uintptr_t) { + w := (*window)(unsafe.Pointer(xw)) +_=w//TODO + fmt.Printf("new size %d x %d\n", width, height) +} // TODO for testing func newButton(string) *Request { return nil } diff --git a/redo/window_darwin.m b/redo/window_darwin.m index d0b1347..426f353 100644 --- a/redo/window_darwin.m +++ b/redo/window_darwin.m @@ -20,6 +20,16 @@ return windowClosing(self->gowin); } +- (void)windowDidResize:(NSNotification *)n +{ + NSWindow *w; + NSRect r; + + w = toNSWindow([n object]); + r = [[w contentView] frame]; + windowResized(self->gowin, (uintptr_t) r.size.width, (uintptr_t) r.size.height); +} + @end id newWindow(intptr_t width, intptr_t height)