diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-22 13:57:32 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-22 13:57:32 -0400 |
| commit | c7268f8feed749a385d171409ac99430d88d348a (patch) | |
| tree | 8c8185e6b054626a0d53c1a42efff41ba1481e47 /redo/area_windows.go | |
| parent | 93b1d3428a3102d92064bd9362405f1e4250a35d (diff) | |
Began implementing Area.OpenTextFieldAt() on Windows.
Diffstat (limited to 'redo/area_windows.go')
| -rw-r--r-- | redo/area_windows.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/redo/area_windows.go b/redo/area_windows.go index 1ab3156..e2f4fb6 100644 --- a/redo/area_windows.go +++ b/redo/area_windows.go @@ -18,6 +18,8 @@ type area struct { _hwnd C.HWND clickCounter *clickCounter + + textfield C.HWND } func makeAreaWindowClass() error { @@ -37,6 +39,8 @@ func newArea(ab *areabase) Area { } a._hwnd = C.newArea(unsafe.Pointer(a)) a.SetSize(a.width, a.height) + a.textfield = C.newAreaTextField(a._hwnd) + C.controlSetControlFont(a.textfield) return a } @@ -67,6 +71,31 @@ func (a *area) RepaintAll() { C.SendMessageW(a._hwnd, C.msgAreaRepaintAll, 0, 0) } +// TODO somehow use textfield.preferredSIze() here +func (a *area) OpenTextFieldAt(x, y int) { + if x < 0 || x >= a.width || y < 0 || y >= a.height { + panic(fmt.Errorf("point (%d,%d) outside Area in Area.OpenTextFieldAt()", x, y)) + } + C.moveWindow(a.textfield, C.int(x), C.int(y), C.int(200), C.int(20)) + C.ShowWindow(a.textfield, C.SW_SHOW) + // TODO SetFocus +} + +func (a *area) TextFieldText() string { + return getWindowText(a.textfield) +} + +func (a *area) SetTextFieldText(text string) { + t := toUTF16(text) + C.setWindowText(a.textfield, t) + // TODO +// c.settextlen(C.controlTextLength(hwnd, t)) +} + +func (a *area) OnTextFieldDismissed(f func()) { + // TODO +} + //export doPaint func doPaint(xrect *C.RECT, hscroll C.int, vscroll C.int, data unsafe.Pointer, dx *C.intptr_t, dy *C.intptr_t) unsafe.Pointer { a := (*area)(data) |
