From 1095719d84a6ac5f90eefe8e23913f3e09ad692d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 13:33:54 -0400 Subject: Migrated more controls. --- label.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 label.go (limited to 'label.go') diff --git a/label.go b/label.go new file mode 100644 index 0000000..09d0b3c --- /dev/null +++ b/label.go @@ -0,0 +1,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) +} -- cgit v1.2.3