diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-02 22:35:58 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-02 22:35:58 -0400 |
| commit | d018953d7ef1b276cc3229e04ba6fc75018c888a (patch) | |
| tree | 3f980a017ca498bf499ff9c5e6a53210606b12f9 /redo/textfield_windows.go | |
| parent | 1f6bcde3d9ddcab921f2f4347148f6784ca36a14 (diff) | |
Split all the Control implementations into their own files and renamed the containerctrls implementation files to say tab instead as they only hold Tab. This is the first part of what should hopefully be the final restructuring.
Diffstat (limited to 'redo/textfield_windows.go')
| -rw-r--r-- | redo/textfield_windows.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/redo/textfield_windows.go b/redo/textfield_windows.go new file mode 100644 index 0000000..d325a18 --- /dev/null +++ b/redo/textfield_windows.go @@ -0,0 +1,50 @@ +// 15 july 2014 + +package ui + +// #include "winapi_windows.h" +import "C" + +type textField struct { + *controlbase +} + +var editclass = toUTF16("EDIT") + +func startNewTextField(style C.DWORD) *textField { + c := newControl(editclass, + style | C.ES_AUTOHSCROLL | C.ES_LEFT | C.ES_NOHIDESEL | C.WS_TABSTOP, + C.WS_EX_CLIENTEDGE) // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog) + C.controlSetControlFont(c.hwnd) + t := &textField{ + controlbase: c, + } + t.fpreferredSize = t.textfieldpreferredSize + return t +} + +func newTextField() *textField { + return startNewTextField(0) +} + +func newPasswordField() *textField { + return startNewTextField(C.ES_PASSWORD) +} + +func (t *textField) Text() string { + return t.text() +} + +func (t *textField) SetText(text string) { + t.setText(text) +} + +const ( + // from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing + textfieldWidth = 107 // this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary + textfieldHeight = 14 +) + +func (t *textField) textfieldpreferredSize(d *sizing) (width, height int) { + return fromdlgunitsX(textfieldWidth, d), fromdlgunitsY(textfieldHeight, d) +} |
