diff options
| author | Pietro Gagliardi <[email protected]> | 2018-08-11 21:29:20 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2018-08-11 21:29:20 -0400 |
| commit | 68ffb808678159b8810c8ed093c0458316d3f8f2 (patch) | |
| tree | 5bda3855b4b6cafc1f39bdbc66204a44493896e3 /label.go | |
| parent | 5ab5777d4cbfe6490760ef4e618bd5fe80a20bea (diff) | |
More control migration.
Diffstat (limited to 'label.go')
| -rw-r--r-- | label.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/label.go b/label.go new file mode 100644 index 0000000..cac7680 --- /dev/null +++ b/label.go @@ -0,0 +1,44 @@ +// 12 december 2015 + +package ui + +import ( + "unsafe" +) + +// #include "ui.h" +import "C" + +// Label is a Control that represents a line of text that cannot be +// interacted with. +type Label struct { + ControlBase + l *C.uiLabel +} + +// NewLabel creates a new Label with the given text. +func NewLabel(text string) *Label { + l := new(Label) + + ctext := C.CString(text) + l.l = C.uiNewLabel(ctext) + freestr(ctext) + + l.ControlBase = NewControlBase(l, uintptr(unsafe.Pointer(l.l))) + return l +} + +// Text returns the Label's text. +func (l *Label) Text() string { + ctext := C.uiLabelText(l.l) + text := C.GoString(ctext) + C.uiFreeText(ctext) + return text +} + +// SetText sets the Label's text to text. +func (l *Label) SetText(text string) { + ctext := C.CString(text) + C.uiLabelSetText(l.l, ctext) + freestr(ctext) +} |
