summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controls_windows.go142
-rw-r--r--lineedit.go58
-rw-r--r--main.go9
-rw-r--r--sysdata.go1
-rw-r--r--sysdata_windows.go5
-rw-r--r--todo.md2
6 files changed, 144 insertions, 73 deletions
diff --git a/controls_windows.go b/controls_windows.go
index 8a3de3e..9b96c22 100644
--- a/controls_windows.go
+++ b/controls_windows.go
@@ -200,94 +200,94 @@ const (
_CBN_SELENDCANCEL = 10
)
-/*
// Edit control styles.
const (
// from winuser.h
- ES_LEFT = 0x0000
- ES_CENTER = 0x0001
- ES_RIGHT = 0x0002
- ES_MULTILINE = 0x0004
- ES_UPPERCASE = 0x0008
- ES_LOWERCASE = 0x0010
- ES_PASSWORD = 0x0020
- ES_AUTOVSCROLL = 0x0040
- ES_AUTOHSCROLL = 0x0080
- ES_NOHIDESEL = 0x0100
- ES_OEMCONVERT = 0x0400
- ES_READONLY = 0x0800
- ES_WANTRETURN = 0x1000
- ES_NUMBER = 0x2000
+ _ES_LEFT = 0x0000
+ _ES_CENTER = 0x0001
+ _ES_RIGHT = 0x0002
+ _ES_MULTILINE = 0x0004
+ _ES_UPPERCASE = 0x0008
+ _ES_LOWERCASE = 0x0010
+ _ES_PASSWORD = 0x0020
+ _ES_AUTOVSCROLL = 0x0040
+ _ES_AUTOHSCROLL = 0x0080
+ _ES_NOHIDESEL = 0x0100
+ _ES_OEMCONVERT = 0x0400
+ _ES_READONLY = 0x0800
+ _ES_WANTRETURN = 0x1000
+ _ES_NUMBER = 0x2000
)
// Edit control messages.
// TODO filter out messages not provided in windows 2000
const (
// from winuser.h
- EM_GETSEL = 0x00B0
- EM_SETSEL = 0x00B1
- EM_GETRECT = 0x00B2
- EM_SETRECT = 0x00B3
- EM_SETRECTNP = 0x00B4
- EM_SCROLL = 0x00B5
- EM_LINESCROLL = 0x00B6
- EM_SCROLLCARET = 0x00B7
- EM_GETMODIFY = 0x00B8
- EM_SETMODIFY = 0x00B9
- EM_GETLINECOUNT = 0x00BA
- EM_LINEINDEX = 0x00BB
- EM_SETHANDLE = 0x00BC
- EM_GETHANDLE = 0x00BD
- EM_GETTHUMB = 0x00BE
- EM_LINELENGTH = 0x00C1
- EM_REPLACESEL = 0x00C2
- EM_GETLINE = 0x00C4
- EM_LIMITTEXT = 0x00C5
- EM_CANUNDO = 0x00C6
- EM_UNDO = 0x00C7
- EM_FMTLINES = 0x00C8
- EM_LINEFROMCHAR = 0x00C9
- EM_SETTABSTOPS = 0x00CB
- EM_SETPASSWORDCHAR = 0x00CC
- EM_EMPTYUNDOBUFFER = 0x00CD
- EM_GETFIRSTVISIBLELINE = 0x00CE
- EM_SETREADONLY = 0x00CF
- EM_SETWORDBREAKPROC = 0x00D0
- EM_GETWORDBREAKPROC = 0x00D1
- EM_GETPASSWORDCHAR = 0x00D2
- EM_SETMARGINS = 0x00D3
- EM_GETMARGINS = 0x00D4
- EM_SETLIMITTEXT = EM_LIMITTEXT // [;win40 Name change]
- EM_GETLIMITTEXT = 0x00D5
- EM_POSFROMCHAR = 0x00D6
- EM_CHARFROMPOS = 0x00D7
- EM_SETIMESTATUS = 0x00D8
- EM_GETIMESTATUS = 0x00D9
+ _EM_GETSEL = 0x00B0
+ _EM_SETSEL = 0x00B1
+ _EM_GETRECT = 0x00B2
+ _EM_SETRECT = 0x00B3
+ _EM_SETRECTNP = 0x00B4
+ _EM_SCROLL = 0x00B5
+ _EM_LINESCROLL = 0x00B6
+ _EM_SCROLLCARET = 0x00B7
+ _EM_GETMODIFY = 0x00B8
+ _EM_SETMODIFY = 0x00B9
+ _EM_GETLINECOUNT = 0x00BA
+ _EM_LINEINDEX = 0x00BB
+ _EM_SETHANDLE = 0x00BC
+ _EM_GETHANDLE = 0x00BD
+ _EM_GETTHUMB = 0x00BE
+ _EM_LINELENGTH = 0x00C1
+ _EM_REPLACESEL = 0x00C2
+ _EM_GETLINE = 0x00C4
+ _EM_LIMITTEXT = 0x00C5
+ _EM_CANUNDO = 0x00C6
+ _EM_UNDO = 0x00C7
+ _EM_FMTLINES = 0x00C8
+ _EM_LINEFROMCHAR = 0x00C9
+ _EM_SETTABSTOPS = 0x00CB
+ _EM_SETPASSWORDCHAR = 0x00CC
+ _EM_EMPTYUNDOBUFFER = 0x00CD
+ _EM_GETFIRSTVISIBLELINE = 0x00CE
+ _EM_SETREADONLY = 0x00CF
+ _EM_SETWORDBREAKPROC = 0x00D0
+ _EM_GETWORDBREAKPROC = 0x00D1
+ _EM_GETPASSWORDCHAR = 0x00D2
+ _EM_SETMARGINS = 0x00D3
+ _EM_GETMARGINS = 0x00D4
+ _EM_SETLIMITTEXT = _EM_LIMITTEXT // [;win40 Name change]
+ _EM_GETLIMITTEXT = 0x00D5
+ _EM_POSFROMCHAR = 0x00D6
+ _EM_CHARFROMPOS = 0x00D7
+ _EM_SETIMESTATUS = 0x00D8
+ _EM_GETIMESTATUS = 0x00D9
)
// Edit control WM_COMMAND notifications.
// TODO filter out notifications not provided in windows 2000
const (
// from winuser.h
- EN_SETFOCUS = 0x0100
- EN_KILLFOCUS = 0x0200
- EN_CHANGE = 0x0300
- EN_UPDATE = 0x0400
- EN_ERRSPACE = 0x0500
- EN_MAXTEXT = 0x0501
- EN_HSCROLL = 0x0601
- EN_VSCROLL = 0x0602
- EN_ALIGN_LTR_EC = 0x0700
- EN_ALIGN_RTL_EC = 0x0701
- EC_LEFTMARGIN = 0x0001
- EC_RIGHTMARGIN = 0x0002
- EC_USEFONTINFO = 0xFFFF
- EMSIS_COMPOSITIONSTRING = 0x0001
- EIMES_GETCOMPSTRATONCE = 0x0001
- EIMES_CANCELCOMPSTRINFOCUS = 0x0002
- EIMES_COMPLETECOMPSTRKILLFOCUS = 0x0004
+ _EN_SETFOCUS = 0x0100
+ _EN_KILLFOCUS = 0x0200
+ _EN_CHANGE = 0x0300
+ _EN_UPDATE = 0x0400
+ _EN_ERRSPACE = 0x0500
+ _EN_MAXTEXT = 0x0501
+ _EN_HSCROLL = 0x0601
+ _EN_VSCROLL = 0x0602
+ _EN_ALIGN_LTR_EC = 0x0700
+ _EN_ALIGN_RTL_EC = 0x0701
+ _EC_LEFTMARGIN = 0x0001
+ _EC_RIGHTMARGIN = 0x0002
+ _EC_USEFONTINFO = 0xFFFF
+ _EMSIS_COMPOSITIONSTRING = 0x0001
+ _EIMES_GETCOMPSTRATONCE = 0x0001
+ _EIMES_CANCELCOMPSTRINFOCUS = 0x0002
+ _EIMES_COMPLETECOMPSTRKILLFOCUS = 0x0004
)
+/*
// Listbox styles.
const (
// from winuser.h
diff --git a/lineedit.go b/lineedit.go
new file mode 100644
index 0000000..a8c9057
--- /dev/null
+++ b/lineedit.go
@@ -0,0 +1,58 @@
+// 14 february 2014
+//package ui
+package main
+
+import (
+ "sync"
+)
+
+// A LineEdit is a control which allows you to enter a single line of text.
+type LineEdit struct {
+ // TODO Typing event
+
+ lock sync.Mutex
+ created bool
+ sysData *sysData
+ initText string
+}
+
+// NewLineEdit makes a new LineEdit with the specified text.
+func NewLineEdit(text string) *LineEdit {
+ return &LineEdit{
+ sysData: mksysdata(c_lineedit),
+ initText: text,
+ }
+}
+
+// TODO SetText
+
+// Text returns the LineEdit's text.
+func (l *LineEdit) Text() (string, error) {
+ l.lock.Lock()
+ defer l.lock.Unlock()
+
+ if l.created {
+ return l.sysData.text()
+ }
+ return l.initText, nil
+}
+
+// TODO adorn errors with what failed
+func (l *LineEdit) make(window *sysData) error {
+ l.lock.Lock()
+ defer l.lock.Unlock()
+
+ err := l.sysData.make(l.initText, 300, 300, window)
+ if err != nil {
+ return err
+ }
+ l.created = true
+ return nil
+}
+
+func (l *LineEdit) setRect(x int, y int, width int, height int) error {
+ l.lock.Lock()
+ defer l.lock.Unlock()
+
+ return l.sysData.setRect(x, y, width, height)
+}
diff --git a/main.go b/main.go
index 81e48fa..e541bd4 100644
--- a/main.go
+++ b/main.go
@@ -12,7 +12,8 @@ func main() {
c := NewCheckbox("Check Me")
cb1 := NewCombobox(true, "You can edit me!", "Yes you can!", "Yes you will!")
cb2 := NewCombobox(false, "You can't edit me!", "No you can't!", "No you won't!")
- s := NewStack(Vertical, b, c, cb1, cb2)
+ e := NewLineEdit("Enter text here too")
+ s := NewStack(Vertical, b, c, cb1, cb2, e)
err := w.Open(s)
if err != nil {
panic(err)
@@ -32,7 +33,11 @@ mainloop:
if err != nil {
panic(err)
}
- err = w.SetTitle(fmt.Sprintf("%v | %s | %s", c.Checked(), cs1, cs2))
+ et, err := e.Text()
+ if err != nil {
+ panic(err)
+ }
+ err = w.SetTitle(fmt.Sprintf("%v | %s | %s | %s", c.Checked(), cs1, cs2, et))
if err != nil {
panic(err)
}
diff --git a/sysdata.go b/sysdata.go
index 1f46ac9..4b60676 100644
--- a/sysdata.go
+++ b/sysdata.go
@@ -43,6 +43,7 @@ const (
c_button
c_checkbox
c_combobox
+ c_lineedit
nctypes
)
diff --git a/sysdata_windows.go b/sysdata_windows.go
index 07a387d..a3aeab0 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -56,6 +56,11 @@ var classTypes = [nctypes]*classData{
insertAfterMsg: _CB_INSERTSTRING,
deleteMsg: _CB_DELETESTRING,
},
+ c_lineedit: &classData{
+ name: "EDIT",
+ style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
+ xstyle: 0 | controlxstyle,
+ },
}
func (s *sysData) addChild(child *sysData) _HMENU {
diff --git a/todo.md b/todo.md
index dee0e32..ae09000 100644
--- a/todo.md
+++ b/todo.md
@@ -6,6 +6,8 @@ so I don't forget:
- determine if a selection in a non-editable combobox has been made
- see if we really need to track errors on Combobox.Selection()
- in fact, see if we really need to track errors on a lot of things...
+- password entry fields, character-limited entry fields, numeric entry fields, multiline entry fields
+ - possible rename of LineEdit?
super ultra important things:
- the windows build appears to be unstable: