From 8f1165e0c7246a1faec655088004cce8c5e047d7 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 17 Oct 2014 20:02:34 -0400 Subject: Did most of the GTK+ migration. --- newctrl/label_unix.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 newctrl/label_unix.go (limited to 'newctrl/label_unix.go') diff --git a/newctrl/label_unix.go b/newctrl/label_unix.go new file mode 100644 index 0000000..819c0e4 --- /dev/null +++ b/newctrl/label_unix.go @@ -0,0 +1,64 @@ +// +build !windows,!darwin + +// 7 july 2014 + +package ui + +import ( + "unsafe" +) + +// #include "gtk_unix.h" +import "C" + +type label struct { + *controlSingleWidget + misc *C.GtkMisc + label *C.GtkLabel +} + +func newLabel(text string) Label { + ctext := togstr(text) + defer freegstr(ctext) + widget := C.gtk_label_new(ctext) + l := &label{ + controlSingleWidget: newControlSingleWidget(widget), + misc: (*C.GtkMisc)(unsafe.Pointer(widget)), + label: (*C.GtkLabel)(unsafe.Pointer(widget)), + } + return l +} + +/*TODO +func newStandaloneLabel(text string) Label { + l := finishNewLabel(text, true) + // standalone labels are always at the top left + C.gtk_misc_set_alignment(l.misc, 0, 0) + return l +} +*/ + +func (l *label) Text() string { + return fromgstr(C.gtk_label_get_text(l.label)) +} + +func (l *label) SetText(text string) { + ctext := togstr(text) + defer freegstr(ctext) + C.gtk_label_set_text(l.label, ctext) +} + +/*TODO +func (l *label) commitResize(c *allocation, d *sizing) { + if !l.standalone && c.neighbor != nil { + c.neighbor.getAuxResizeInfo(d) + if d.shouldVAlignTop { + // don't bother aligning it to the first line of text in the control; this is harder than it's worth (thanks gregier in irc.gimp.net/#gtk+) + C.gtk_misc_set_alignment(l.misc, 0, 0) + } else { + C.gtk_misc_set_alignment(l.misc, 0, 0.5) + } + } + basecommitResize(l, c, d) +} +*/ -- cgit v1.2.3