2014-07-30 01:06:01 -05:00
|
|
|
// 30 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
// #include "winapi_windows.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type controlParent struct {
|
2014-10-18 16:03:07 -05:00
|
|
|
hwnd C.HWND
|
2014-07-30 01:06:01 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
// don't specify preferredSize in any of these; they're per-control
|
|
|
|
|
|
|
|
type controlSingleHWND struct {
|
|
|
|
*controlbase
|
|
|
|
hwnd C.HWND
|
2014-08-03 08:18:35 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func newControlSingleHWND(hwnd C.HWND) *controlSingleHWND {
|
|
|
|
c := new(controlSingleHWND)
|
|
|
|
c.controlbase = &controlbase{
|
2014-10-26 14:15:13 -05:00
|
|
|
fsetParent: c.xsetParent,
|
|
|
|
fresize: c.xresize,
|
|
|
|
fnTabStops: func() int {
|
2014-10-18 16:03:07 -05:00
|
|
|
// most controls count as one tab stop
|
|
|
|
return 1
|
|
|
|
},
|
2014-10-26 14:15:13 -05:00
|
|
|
fcontainerShow: func() {
|
|
|
|
C.ShowWindow(c.hwnd, C.SW_SHOW)
|
|
|
|
},
|
|
|
|
fcontainerHide: func() {
|
|
|
|
C.ShowWindow(c.hwnd, C.SW_HIDE)
|
|
|
|
},
|
2014-10-18 16:03:07 -05:00
|
|
|
}
|
|
|
|
c.hwnd = hwnd
|
|
|
|
return c
|
|
|
|
}
|
2014-08-03 08:18:35 -05:00
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (c *controlSingleHWND) xsetParent(p *controlParent) {
|
|
|
|
C.controlSetParent(c.hwnd, p.hwnd)
|
2014-08-03 08:18:35 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
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))
|
2014-08-03 08:18:35 -05:00
|
|
|
}
|
|
|
|
|
2014-07-30 01:06:01 -05:00
|
|
|
// these are provided for convenience
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
type controlSingleHWNDWithText struct {
|
|
|
|
*controlSingleHWND
|
|
|
|
textlen C.LONG
|
|
|
|
}
|
|
|
|
|
|
|
|
func newControlSingleHWNDWithText(h C.HWND) *controlSingleHWNDWithText {
|
|
|
|
return &controlSingleHWNDWithText{
|
|
|
|
controlSingleHWND: newControlSingleHWND(h),
|
|
|
|
}
|
2014-08-03 20:52:21 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
// TODO export these instead of requiring dummy declarations in each implementation
|
|
|
|
func (c *controlSingleHWNDWithText) text() string {
|
|
|
|
return getWindowText(c.hwnd)
|
2014-07-30 01:06:01 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (c *controlSingleHWNDWithText) setText(text string) {
|
2014-08-01 18:24:57 -05:00
|
|
|
t := toUTF16(text)
|
2014-10-18 16:03:07 -05:00
|
|
|
C.setWindowText(c.hwnd, t)
|
|
|
|
c.textlen = C.controlTextLength(c.hwnd, t)
|
2014-07-30 01:06:01 -05:00
|
|
|
}
|