summaryrefslogtreecommitdiff
path: root/label.go
blob: 09d0b3c90bff919a30f092d3fbb8813ae9562433 (plain)
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
// 12 december 2015

package ui

import (
	"unsafe"
)

// #include "pkgui.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)
}