summaryrefslogtreecommitdiff
path: root/textbox_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-23 16:54:21 -0400
committerPietro Gagliardi <[email protected]>2014-10-23 16:54:21 -0400
commit92c7598d9d0b1ec8a68f55c8a8a9e46ca1a1db50 (patch)
treed8c36c8223ace0b75990e3e2d4514a929ae79f7f /textbox_windows.go
parentba31d13c6d961545037cf0572c717e2643893180 (diff)
Added Textbox and implemented it on Windows.
Diffstat (limited to 'textbox_windows.go')
-rw-r--r--textbox_windows.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/textbox_windows.go b/textbox_windows.go
new file mode 100644
index 0000000..0a68052
--- /dev/null
+++ b/textbox_windows.go
@@ -0,0 +1,40 @@
+// 23 october 2014
+
+package ui
+
+// #include "winapi_windows.h"
+import "C"
+
+type textbox struct {
+ *controlSingleHWNDWithText
+}
+
+// TODO autohide scrollbars
+func newTextbox() Textbox {
+ hwnd := C.newControl(editclass,
+ // TODO ES_AUTOHSCROLL/ES_AUTOVSCROLL as well?
+ // TODO word wrap
+ C.ES_LEFT | C.ES_MULTILINE | C.ES_NOHIDESEL | C.ES_WANTRETURN | C.WS_HSCROLL | C.WS_VSCROLL,
+ C.WS_EX_CLIENTEDGE)
+ t := &textbox{
+ controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
+ }
+ t.fpreferredSize = t.xpreferredSize
+ C.controlSetControlFont(t.hwnd)
+ return t
+}
+
+func (t *textbox) Text() string {
+ return t.text()
+}
+
+func (t *textbox) SetText(text string) {
+ t.setText(text)
+}
+
+// just reuse the preferred textfield width
+// TODO allow alternate widths
+// TODO current height probably can be better calculated
+func (t *textbox) xpreferredSize(d *sizing) (width, height int) {
+ return fromdlgunitsX(textfieldWidth, d), fromdlgunitsY(textfieldHeight, d) * 3
+}