diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-03 21:52:21 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-03 21:52:21 -0400 |
| commit | 2c107d7057fec9d8c6fc1b694e28cea824668a3d (patch) | |
| tree | 9b7cd1f2d0d7df1f7af8f179fc23f9ab21b8db8e /redo/control_windows.go | |
| parent | 0fb45ba84d7a948508b30e0b140910ae906b4d9d (diff) | |
Converted the new Windows Control code to use interfaces instead of controlbase, just like the GTK+ and Mac OS X backends do now.
Diffstat (limited to 'redo/control_windows.go')
| -rw-r--r-- | redo/control_windows.go | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/redo/control_windows.go b/redo/control_windows.go index ac3297e..ac57527 100644 --- a/redo/control_windows.go +++ b/redo/control_windows.go @@ -6,46 +6,30 @@ package ui import "C" type controlPrivate interface { - // TODO + hwnd() C.HWND Control } -type controlbase struct { - hwnd C.HWND - parent C.HWND // for Tab and Group - textlen C.LONG -} - type controlParent struct { hwnd C.HWND } -func newControl(class C.LPWSTR, style C.DWORD, extstyle C.DWORD) *controlbase { - c := new(controlbase) - // TODO rename to newWidget - c.hwnd = C.newWidget(class, style, extstyle) - return c -} - -// TODO for maximum correctness these shouldn't take controlbases... but then the amount of duplicated code would skyrocket - -func basesetParent(c *controlbase, p *controlParent) { - C.controlSetParent(c.hwnd, p.hwnd) - c.parent = p.hwnd +func basesetParent(c controlPrivate, p *controlParent) { + C.controlSetParent(c.hwnd(), p.hwnd) } -func basecontainerShow(c *controlbase) { - C.ShowWindow(c.hwnd, C.SW_SHOW) +func basecontainerShow(c controlPrivate) { + C.ShowWindow(c.hwnd(), C.SW_SHOW) } -func basecontainerHide(c *controlbase) { - C.ShowWindow(c.hwnd, C.SW_HIDE) +func basecontainerHide(c controlPrivate) { + C.ShowWindow(c.hwnd(), C.SW_HIDE) } // don't specify basepreferredSize; it is custom on ALL controls -func basecommitResize(c *controlbase, a *allocation, d *sizing) { - C.moveWindow(c.hwnd, C.int(a.x), C.int(a.y), C.int(a.width), C.int(a.height)) +func basecommitResize(c controlPrivate, a *allocation, d *sizing) { + C.moveWindow(c.hwnd(), C.int(a.x), C.int(a.y), C.int(a.width), C.int(a.height)) } func basegetAuxResizeInfo(c controlPrivate, d *sizing) { @@ -54,12 +38,19 @@ func basegetAuxResizeInfo(c controlPrivate, d *sizing) { // these are provided for convenience -func (c *controlbase) text() string { - return getWindowText(c.hwnd) +type textableControl interface { + controlPrivate + textlen() C.LONG + settextlen(C.LONG) +} + +func baseText(c textableControl) string { + return getWindowText(c.hwnd()) } -func (c *controlbase) setText(text string) { +func baseSetText(c textableControl, text string) { + hwnd := c.hwnd() t := toUTF16(text) - C.setWindowText(c.hwnd, t) - c.textlen = C.controlTextLength(c.hwnd, t) + C.setWindowText(hwnd, t) + c.settextlen(C.controlTextLength(hwnd, t)) } |
