summaryrefslogtreecommitdiff
path: root/redo/window_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'redo/window_windows.go')
-rw-r--r--redo/window_windows.go42
1 files changed, 2 insertions, 40 deletions
diff --git a/redo/window_windows.go b/redo/window_windows.go
index 341f226..3306613 100644
--- a/redo/window_windows.go
+++ b/redo/window_windows.go
@@ -5,24 +5,16 @@ package ui
import (
"fmt"
"syscall"
- "unsafe"
)
// #include "winapi_windows.h"
import "C"
type window struct {
- hwnd C.HWND
+ *layout
shownbefore bool
-
- closing *event
-
- *sizer
}
-const windowclassname = ""
-var windowclassptr = syscall.StringToUTF16Ptr(windowclassname)
-
func makeWindowWindowClass() error {
var errmsg *C.char
@@ -35,21 +27,13 @@ func makeWindowWindowClass() error {
func newWindow(title string, width int, height int, control Control) *window {
w := &window{
- // hwnd set in WM_CREATE handler
- closing: newEvent(),
- sizer: new(sizer),
- }
- 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))
+ layout: newLayout(title, width, height, C.FALSE, control),
}
// 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.child = control
- w.child.setParent(&controlParent{w.hwnd})
return w
}
@@ -82,25 +66,3 @@ 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 := (*window)(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
- w.resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top))
-}
-
-//export windowClosing
-func windowClosing(data unsafe.Pointer) {
- w := (*window)(data)
- close := w.closing.fire()
- if close {
- C.windowClose(w.hwnd)
- }
-}