diff options
| author | Pietro Gagliardi <[email protected]> | 2015-12-11 20:37:59 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-12-11 20:37:59 -0500 |
| commit | f8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch) | |
| tree | 82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /prev/control_windows.go | |
| parent | e34c561ed5bedeb180437ec165882b98d70d38c1 (diff) | |
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'prev/control_windows.go')
| -rw-r--r-- | prev/control_windows.go | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/prev/control_windows.go b/prev/control_windows.go new file mode 100644 index 0000000..8661e50 --- /dev/null +++ b/prev/control_windows.go @@ -0,0 +1,69 @@ +// 30 july 2014 + +package ui + +// #include "winapi_windows.h" +import "C" + +type controlParent struct { + hwnd C.HWND +} + +// don't specify preferredSize in any of these; they're per-control + +type controlSingleHWND struct { + *controlbase + hwnd C.HWND +} + +func newControlSingleHWND(hwnd C.HWND) *controlSingleHWND { + c := new(controlSingleHWND) + c.controlbase = &controlbase{ + fsetParent: c.xsetParent, + fresize: c.xresize, + fnTabStops: func() int { + // most controls count as one tab stop + return 1 + }, + fcontainerShow: func() { + C.ShowWindow(c.hwnd, C.SW_SHOW) + }, + fcontainerHide: func() { + C.ShowWindow(c.hwnd, C.SW_HIDE) + }, + } + c.hwnd = hwnd + return c +} + +func (c *controlSingleHWND) xsetParent(p *controlParent) { + C.controlSetParent(c.hwnd, p.hwnd) +} + +func (c *controlSingleHWND) xresize(x int, y int, width int, height int, d *sizing) { + C.moveWindow(c.hwnd, C.int(x), C.int(y), C.int(width), C.int(height)) +} + +// these are provided for convenience + +type controlSingleHWNDWithText struct { + *controlSingleHWND + textlen C.LONG +} + +func newControlSingleHWNDWithText(h C.HWND) *controlSingleHWNDWithText { + return &controlSingleHWNDWithText{ + controlSingleHWND: newControlSingleHWND(h), + } +} + +// TODO export these instead of requiring dummy declarations in each implementation +func (c *controlSingleHWNDWithText) text() string { + return getWindowText(c.hwnd) +} + +func (c *controlSingleHWNDWithText) setText(text string) { + t := toUTF16(text) + C.setWindowText(c.hwnd, t) + c.textlen = C.controlTextLength(c.hwnd, t) +} |
