diff options
Diffstat (limited to 'redo/window_windows.go')
| -rw-r--r-- | redo/window_windows.go | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/redo/window_windows.go b/redo/window_windows.go index 3306613..9cf98d0 100644 --- a/redo/window_windows.go +++ b/redo/window_windows.go @@ -11,8 +11,12 @@ import ( import "C" type window struct { - *layout + hwnd C.HWND shownbefore bool + + closing *event + + *layout } func makeWindowWindowClass() error { @@ -27,13 +31,20 @@ func makeWindowWindowClass() error { func newWindow(title string, width int, height int, control Control) *window { w := &window{ - layout: newLayout(title, width, height, C.FALSE, control), + // hwnd set in WM_CREATE handler + closing: newEvent(), + layout: newLayout(control), + } + hwnd := C.newWindow(toUTF16(title), C.int(width), C.int(height), unsafe.Pointer(w)) + if hwnd != l.hwnd { + panic(fmt.Errorf("inconsistency: hwnd returned by CreateWindowEx() (%p) and hwnd stored in Window (%p) differ", hwnd, w.hwnd)) } // TODO keep? hresult := C.EnableThemeDialogTexture(w.hwnd, C.ETDT_ENABLE | C.ETDT_USETABTEXTURE) if hresult != C.S_OK { panic(fmt.Errorf("error setting tab background texture on Window; HRESULT: 0x%X", hresult)) } + w.layout.setParent(&controlParent{w.hwnd}) return w } @@ -66,3 +77,26 @@ func (w *window) Close() { func (w *window) OnClosing(e func() bool) { w.closing.setbool(e) } + +//export storeWindowHWND +func storeWindowHWND(data unsafe.Pointer, hwnd C.HWND) { + w := (*wiindow)(data) + w.hwnd = hwnd +} + +//export windowResize +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.layout.hwnd, int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top)) +} + +//export windowClosing +func windowClosing(data unsafe.Pointer) { + l := (*layout)(data) + close := l.closing.fire() + if close { + C.windowClose(l.hwnd) + } +} |
