2014-08-02 21:35:58 -05:00
|
|
|
// +build !windows,!darwin
|
|
|
|
|
|
|
|
// 7 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "gtk_unix.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type label struct {
|
2014-10-18 16:03:07 -05:00
|
|
|
*controlSingleWidget
|
2014-10-02 09:05:53 -05:00
|
|
|
misc *C.GtkMisc
|
|
|
|
label *C.GtkLabel
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func newLabel(text string) Label {
|
2014-08-02 21:35:58 -05:00
|
|
|
ctext := togstr(text)
|
|
|
|
defer freegstr(ctext)
|
|
|
|
widget := C.gtk_label_new(ctext)
|
|
|
|
l := &label{
|
2014-10-18 16:03:07 -05:00
|
|
|
controlSingleWidget: newControlSingleWidget(widget),
|
2014-10-02 09:05:53 -05:00
|
|
|
misc: (*C.GtkMisc)(unsafe.Pointer(widget)),
|
|
|
|
label: (*C.GtkLabel)(unsafe.Pointer(widget)),
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
|
|
|
return l
|
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
/*TODO
|
2014-08-02 21:35:58 -05:00
|
|
|
func newStandaloneLabel(text string) Label {
|
2014-08-05 19:47:56 -05:00
|
|
|
l := finishNewLabel(text, true)
|
|
|
|
// standalone labels are always at the top left
|
|
|
|
C.gtk_misc_set_alignment(l.misc, 0, 0)
|
|
|
|
return l
|
2014-08-02 21:35:58 -05:00
|
|
|
}
|
2014-10-18 16:03:07 -05:00
|
|
|
*/
|
2014-08-02 21:35:58 -05:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
/*TODO
|
2014-08-03 15:28:21 -05:00
|
|
|
func (l *label) commitResize(c *allocation, d *sizing) {
|
2014-08-02 21:35:58 -05:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2014-08-03 15:28:21 -05:00
|
|
|
basecommitResize(l, c, d)
|
|
|
|
}
|
2014-10-18 16:03:07 -05:00
|
|
|
*/
|