diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-14 15:17:35 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-14 15:17:35 -0400 |
| commit | eef3e1136b51112c23620b150ffcf03caddc0ff9 (patch) | |
| tree | a80096f1c580d23975032dd38aa7fd86700fb4ac /newctrl/control_windows.go | |
| parent | aad6e4c699614d9911df16d0b3bf86b10db5087c (diff) | |
Started the new recontainerization..
Diffstat (limited to 'newctrl/control_windows.go')
| -rw-r--r-- | newctrl/control_windows.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/newctrl/control_windows.go b/newctrl/control_windows.go new file mode 100644 index 0000000..106727b --- /dev/null +++ b/newctrl/control_windows.go @@ -0,0 +1,61 @@ +// 30 july 2014 + +package ui + +// #include "winapi_windows.h" +import "C" + +type controlParent struct { + hwnd C.HWND +} +type sizing struct { + // TODO +} + +// 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.setParent, + fresize: c.resize, + } + c.hwnd = hwnd + return c +} + +func (c *controlSingleHWND) setParent(p *controlParent) { + C.controlSetParent(c.hwnd, p.hwnd) +} + +func (c *controlSingleHWND) resize(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), + } +} + +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) +} |
