summaryrefslogtreecommitdiff
path: root/basicLabel.go
blob: 36915e2c6209af3621f91e2352c366ce3d2ec6a3 (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
/*
A Labeled label:

-----------------------------
|            |              |
|   Food:    |    Apple     |
|            |              |
-----------------------------
*/
package gadgets

import (
	"go.wit.com/gui"
	"go.wit.com/log"
)

type Node gui.Node

type BasicLabel struct {
	p *gui.Node // parent widget
	l *gui.Node // label widget
	v *gui.Node // value widget

	value string
	label string

	Custom func()
}

/*
func (n *BasicLabel) Get() string {
	return n.value
}

func (n *BasicLabel) Set(value string) *BasicLabel {
	log.Log(INFO, "BasicLabel.Set() =", value)
	if (n.v != nil) {
		n.v.Set(value)
	}
	n.value = value
	return n
}
*/

func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
	var n *gui.Node
	n = (*gui.Node)(ngui)
	d := BasicLabel{
		p:     n,
		value: "",
	}

	// various timeout settings
	d.l = n.NewLabel(name)
	d.v = n.NewLabel("")
	d.v.Custom = func() {
		d.value = d.v.String()
		log.Log(INFO, "BasicLabel.Custom() user changed value to =", d.value)
	}

	return &d
}