summaryrefslogtreecommitdiff
path: root/AAA_GOFILES/label.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2018-08-11 16:18:01 -0400
committerPietro Gagliardi <[email protected]>2018-08-11 16:18:01 -0400
commit308e253e0f7873710bf77312d7a12c576aaa9781 (patch)
treefd20704da886ce82a3621ec1502897a8766b11be /AAA_GOFILES/label.go
parent0f75ebb5fa7a12bd1df26622ed3f5544a9d1d32b (diff)
Moved the existing .go files out of the way and replaced ui.h with the alpha4 ui.h.
Diffstat (limited to 'AAA_GOFILES/label.go')
-rw-r--r--AAA_GOFILES/label.go85
1 files changed, 85 insertions, 0 deletions
diff --git a/AAA_GOFILES/label.go b/AAA_GOFILES/label.go
new file mode 100644
index 0000000..e143d50
--- /dev/null
+++ b/AAA_GOFILES/label.go
@@ -0,0 +1,85 @@
+// 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. TODO rest of documentation.
+type Label struct {
+ c *C.uiControl
+ 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)
+ l.c = (*C.uiControl)(unsafe.Pointer(l.l))
+ freestr(ctext)
+
+ return l
+}
+
+// Destroy destroys the Label.
+func (l *Label) Destroy() {
+ C.uiControlDestroy(l.c)
+}
+
+// LibuiControl returns the libui uiControl pointer that backs
+// the Window. This is only used by package ui itself and should
+// not be called by programs.
+func (l *Label) LibuiControl() uintptr {
+ return uintptr(unsafe.Pointer(l.c))
+}
+
+// Handle returns the OS-level handle associated with this Label.
+// On Windows this is an HWND of a standard Windows API STATIC
+// class (as provided by Common Controls version 6).
+// On GTK+ this is a pointer to a GtkLabel.
+// On OS X this is a pointer to a NSTextField.
+func (l *Label) Handle() uintptr {
+ return uintptr(C.uiControlHandle(l.c))
+}
+
+// Show shows the Label.
+func (l *Label) Show() {
+ C.uiControlShow(l.c)
+}
+
+// Hide hides the Label.
+func (l *Label) Hide() {
+ C.uiControlHide(l.c)
+}
+
+// Enable enables the Label.
+func (l *Label) Enable() {
+ C.uiControlEnable(l.c)
+}
+
+// Disable disables the Label.
+func (l *Label) Disable() {
+ C.uiControlDisable(l.c)
+}
+
+// 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)
+}