diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-18 17:03:07 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-18 17:03:07 -0400 |
| commit | 62048303a34f6cac733798651adb53b640e2114a (patch) | |
| tree | b03994dfe1d5cfbc94be65075f3345a45166bbef /window_windows.go | |
| parent | 8c8b642adbed274133b6e9d975c7ca8786300d2c (diff) | |
Merged new container/sizing stuff.
Diffstat (limited to 'window_windows.go')
| -rw-r--r-- | window_windows.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/window_windows.go b/window_windows.go index e20206e..8537be8 100644 --- a/window_windows.go +++ b/window_windows.go @@ -17,7 +17,8 @@ type window struct { closing *event - *container + child Control + margined bool } func makeWindowWindowClass() error { @@ -32,19 +33,15 @@ func makeWindowWindowClass() error { func newWindow(title string, width int, height int, control Control) *window { w := &window{ - // hwnd set in WM_CREATE handler closing: newEvent(), - container: newContainer(control), - } - hwnd := C.newWindow(toUTF16(title), C.int(width), C.int(height), unsafe.Pointer(w)) - if hwnd != w.hwnd { - panic(fmt.Errorf("inconsistency: hwnd returned by CreateWindowEx() (%p) and hwnd stored in Window (%p) differ", hwnd, w.hwnd)) + child: control, } + w.hwnd = C.newWindow(toUTF16(title), C.int(width), C.int(height), unsafe.Pointer(w)) 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.container.setParent(w.hwnd) + w.child.setParent(&controlParent{w.hwnd}) return w } @@ -78,17 +75,22 @@ func (w *window) OnClosing(e func() bool) { w.closing.setbool(e) } -//export storeWindowHWND -func storeWindowHWND(data unsafe.Pointer, hwnd C.HWND) { - w := (*window)(data) - w.hwnd = hwnd +func (w *window) Margined() bool { + return w.margined +} + +func (w *window) SetMargined(margined bool) { + w.margined = margined } //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 - w.container.move(r) + d := w.beginResize() + if w.margined { + marginRectDLU(r, marginDialogUnits, marginDialogUnits, marginDialogUnits, marginDialogUnits, d) + } + w.child.resize(int(r.left), int (r.top), int(r.right - r.left), int(r.bottom - r.top), d) } //export windowClosing |
