Added labels.
This commit is contained in:
parent
681afdf0ad
commit
9070eae214
|
@ -371,54 +371,54 @@ const (
|
|||
LBN_SETFOCUS = 4
|
||||
LBN_KILLFOCUS = 5
|
||||
)
|
||||
*/
|
||||
|
||||
// Static control styles.
|
||||
const (
|
||||
// from winuser.h
|
||||
SS_LEFT = 0x00000000
|
||||
SS_CENTER = 0x00000001
|
||||
SS_RIGHT = 0x00000002
|
||||
SS_ICON = 0x00000003
|
||||
SS_BLACKRECT = 0x00000004
|
||||
SS_GRAYRECT = 0x00000005
|
||||
SS_WHITERECT = 0x00000006
|
||||
SS_BLACKFRAME = 0x00000007
|
||||
SS_GRAYFRAME = 0x00000008
|
||||
SS_WHITEFRAME = 0x00000009
|
||||
SS_USERITEM = 0x0000000A
|
||||
SS_SIMPLE = 0x0000000B
|
||||
SS_LEFTNOWORDWRAP = 0x0000000C
|
||||
SS_OWNERDRAW = 0x0000000D
|
||||
SS_BITMAP = 0x0000000E
|
||||
SS_ENHMETAFILE = 0x0000000F
|
||||
SS_ETCHEDHORZ = 0x00000010
|
||||
SS_ETCHEDVERT = 0x00000011
|
||||
SS_ETCHEDFRAME = 0x00000012
|
||||
SS_TYPEMASK = 0x0000001F
|
||||
SS_REALSIZECONTROL = 0x00000040
|
||||
SS_NOPREFIX = 0x00000080
|
||||
SS_NOTIFY = 0x00000100
|
||||
SS_CENTERIMAGE = 0x00000200
|
||||
SS_RIGHTJUST = 0x00000400
|
||||
SS_REALSIZEIMAGE = 0x00000800
|
||||
SS_SUNKEN = 0x00001000
|
||||
SS_EDITCONTROL = 0x00002000
|
||||
SS_ENDELLIPSIS = 0x00004000
|
||||
SS_PATHELLIPSIS = 0x00008000
|
||||
SS_WORDELLIPSIS = 0x0000C000
|
||||
SS_ELLIPSISMASK = 0x0000C000
|
||||
_SS_LEFT = 0x00000000
|
||||
_SS_CENTER = 0x00000001
|
||||
_SS_RIGHT = 0x00000002
|
||||
_SS_ICON = 0x00000003
|
||||
_SS_BLACKRECT = 0x00000004
|
||||
_SS_GRAYRECT = 0x00000005
|
||||
_SS_WHITERECT = 0x00000006
|
||||
_SS_BLACKFRAME = 0x00000007
|
||||
_SS_GRAYFRAME = 0x00000008
|
||||
_SS_WHITEFRAME = 0x00000009
|
||||
_SS_USERITEM = 0x0000000A
|
||||
_SS_SIMPLE = 0x0000000B
|
||||
_SS_LEFTNOWORDWRAP = 0x0000000C
|
||||
_SS_OWNERDRAW = 0x0000000D
|
||||
_SS_BITMAP = 0x0000000E
|
||||
_SS_ENHMETAFILE = 0x0000000F
|
||||
_SS_ETCHEDHORZ = 0x00000010
|
||||
_SS_ETCHEDVERT = 0x00000011
|
||||
_SS_ETCHEDFRAME = 0x00000012
|
||||
_SS_TYPEMASK = 0x0000001F
|
||||
_SS_REALSIZECONTROL = 0x00000040
|
||||
_SS_NOPREFIX = 0x00000080
|
||||
_SS_NOTIFY = 0x00000100
|
||||
_SS_CENTERIMAGE = 0x00000200
|
||||
_SS_RIGHTJUST = 0x00000400
|
||||
_SS_REALSIZEIMAGE = 0x00000800
|
||||
_SS_SUNKEN = 0x00001000
|
||||
_SS_EDITCONTROL = 0x00002000
|
||||
_SS_ENDELLIPSIS = 0x00004000
|
||||
_SS_PATHELLIPSIS = 0x00008000
|
||||
_SS_WORDELLIPSIS = 0x0000C000
|
||||
_SS_ELLIPSISMASK = 0x0000C000
|
||||
)
|
||||
|
||||
// Static control messages and WM_COMMAND notifications.
|
||||
const (
|
||||
// from winuser.h
|
||||
STM_SETICON = 0x0170
|
||||
STM_GETICON = 0x0171
|
||||
STM_SETIMAGE = 0x0172
|
||||
STM_GETIMAGE = 0x0173
|
||||
STN_CLICKED = 0
|
||||
STN_DBLCLK = 1
|
||||
STN_ENABLE = 2
|
||||
STN_DISABLE = 3
|
||||
_STM_SETICON = 0x0170
|
||||
_STM_GETICON = 0x0171
|
||||
_STM_SETIMAGE = 0x0172
|
||||
_STM_GETIMAGE = 0x0173
|
||||
_STN_CLICKED = 0
|
||||
_STN_DBLCLK = 1
|
||||
_STN_ENABLE = 2
|
||||
_STN_DISABLE = 3
|
||||
)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// 14 february 2014
|
||||
//package ui
|
||||
package main
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// A Label is a static line of text used to mark other controls.
|
||||
type Label struct {
|
||||
lock sync.Mutex
|
||||
created bool
|
||||
sysData *sysData
|
||||
initText string
|
||||
}
|
||||
|
||||
// NewLabel creates a new Label with the specified text.
|
||||
func NewLabel(text string) *Label {
|
||||
return &Label{
|
||||
sysData: mksysdata(c_label),
|
||||
initText: text,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO SetText()/Text()?
|
||||
|
||||
// TODO adorn error messages
|
||||
func (l *Label) make(window *sysData) error {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
return l.sysData.make(l.initText, 300, 300, window)
|
||||
}
|
||||
|
||||
func (l *Label) 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)
|
||||
}
|
3
main.go
3
main.go
|
@ -13,7 +13,8 @@ func main() {
|
|||
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!")
|
||||
e := NewLineEdit("Enter text here too")
|
||||
s := NewStack(Vertical, b, c, cb1, cb2, e)
|
||||
l := NewLabel("This is a label")
|
||||
s := NewStack(Vertical, b, c, cb1, cb2, e, l)
|
||||
err := w.Open(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -44,6 +44,7 @@ const (
|
|||
c_checkbox
|
||||
c_combobox
|
||||
c_lineedit
|
||||
c_label
|
||||
nctypes
|
||||
)
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ var classTypes = [nctypes]*classData{
|
|||
style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
||||
xstyle: 0 | controlxstyle,
|
||||
},
|
||||
c_label: &classData{
|
||||
name: "STATIC",
|
||||
style: _SS_NOPREFIX | controlstyle,
|
||||
xstyle: 0 | controlxstyle,
|
||||
},
|
||||
}
|
||||
|
||||
func (s *sysData) addChild(child *sysData) _HMENU {
|
||||
|
|
Loading…
Reference in New Issue