-
Notifications
You must be signed in to change notification settings - Fork 0
/
label.go
69 lines (52 loc) · 1.28 KB
/
label.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2010 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build windows
package walk
type Label struct {
static
textChangedPublisher EventPublisher
}
func NewLabel(parent Container) (*Label, error) {
return NewLabelWithStyle(parent, 0)
}
func NewLabelWithStyle(parent Container, style uint32) (*Label, error) {
l := new(Label)
if err := l.init(l, parent); err != nil {
return nil, err
}
l.SetTextAlignment(AlignNear)
l.MustRegisterProperty("Text", NewProperty(
func() interface{} {
return l.Text()
},
func(v interface{}) error {
return l.SetText(assertStringOr(v, ""))
},
l.textChangedPublisher.Event()))
return l, nil
}
func (l *Label) asStatic() *static {
return &l.static
}
func (l *Label) TextAlignment() Alignment1D {
return l.textAlignment1D()
}
func (l *Label) SetTextAlignment(alignment Alignment1D) error {
if alignment == AlignDefault {
alignment = AlignNear
}
return l.setTextAlignment1D(alignment)
}
func (l *Label) Text() string {
return l.text()
}
func (l *Label) SetText(text string) error {
if changed, err := l.setText(text); err != nil {
return err
} else if !changed {
return nil
}
l.textChangedPublisher.Publish()
return nil
}