diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-04 11:05:39 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-04 11:05:39 -0400 |
| commit | 950548563dfc284f913e78895eeead6e8a14553a (patch) | |
| tree | 9064e9bf73c4b4bc0cb0a1efc47818adccaecfe5 /redo/layout_windows.go | |
| parent | 2c107d7057fec9d8c6fc1b694e28cea824668a3d (diff) | |
Split apart the Windows Window code so that the same window class can be used for both top-level windows and tab pages (next commit). This makes things slightly messy in the short term, but this will all be cleaned up soon, and has the advantage of taking care of the sizer mess~
Diffstat (limited to 'redo/layout_windows.go')
| -rw-r--r-- | redo/layout_windows.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/redo/layout_windows.go b/redo/layout_windows.go new file mode 100644 index 0000000..58f7872 --- /dev/null +++ b/redo/layout_windows.go @@ -0,0 +1,58 @@ +// 4 august 2014 + +package ui + +// TODO clean this up relative to window_windows.go + +import ( + "fmt" + "unsafe" +) + +// #include "winapi_windows.h" +import "C" + +type layout struct { + hwnd C.HWND + + closing *event + + *sizer +} + +func newLayout(title string, width int, height int, child C.BOOL, control Control) *layout { + l := &layout{ + // hwnd set in WM_CREATE handler + closing: newEvent(), + sizer: new(sizer), + } + hwnd := C.newWindow(toUTF16(title), C.int(width), C.int(height), child, unsafe.Pointer(l)) + if hwnd != l.hwnd { + panic(fmt.Errorf("inconsistency: hwnd returned by CreateWindowEx() (%p) and hwnd stored in window/layout (%p) differ", hwnd, l.hwnd)) + } + l.child = control + l.child.setParent(&controlParent{l.hwnd}) + return l +} + +//export storeWindowHWND +func storeWindowHWND(data unsafe.Pointer, hwnd C.HWND) { + l := (*layout)(data) + l.hwnd = hwnd +} + +//export windowResize +func windowResize(data unsafe.Pointer, r *C.RECT) { + l := (*layout)(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 + l.resize(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) + } +} |
