summaryrefslogtreecommitdiff
path: root/prev/label_unix.go
blob: 819c0e47c8f16cb6b911d9fab6756e5473175210 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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)
}
*/