summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/checkbox.go
blob: 5466d17947e6aa494ebfcbae1792113401b003c0 (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
65
66
67
68
69
package main

import "git.wit.org/wit/gui/toolkit"

import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"

func (t andlabsT) NewCheckbox(name string, f func()) *andlabsT {
	log(debugToolkit, "gui.Toolkit.NewCheckbox()", name)
	var newt andlabsT

	if t.broken() {
		return nil
	}

	c := ui.NewCheckbox(name)
	newt.uiCheckbox = c
	newt.uiBox = t.uiBox
	t.uiBox.Append(c, stretchy)
	// newt.Custom = f

	c.OnToggled(func(spin *ui.Checkbox) {
		// log(debugToolkit, "gui.Toolkit.NewCheckbox() clicked", name)
		newt.commonChange("Checkbox")
		/*
		if (f != nil) {
			log(debugToolkit, "Run custom() here", f)
			log(SPEW, f)
			f()
		} else {
			log(debugToolkit, "No custom() function here")
		}
		*/
	})

	return &newt
}

func (t andlabsT) Checked() bool {
	if t.broken() {
		return false
	}

	return t.uiCheckbox.Checked()
}

func NewCheckbox(parentW *toolkit.Widget, w *toolkit.Widget) {
	log(debugToolkit, "gui.andlabs.NewCheckbox()", w.Name)

	t := mapToolkits[parentW]
	if (t == nil) {
		listMap()
	}
	newt := t.NewCheckbox(w.Name, w.Custom)
	newt.Custom = w.Custom
	/*
	if (w.Custom != nil) {
		log(true, "go.andlabs.NewCheckbox() toolkit struct == nil. name=", parentW.Name, w.Name)
		log(true, "Run custom() START here", w.Custom)
		w.Custom()
		log(true, "Run custom() END")
		// exit("ran it here")
	} else {
		log(true, "No custom() function here")
		// exit("nothing here")
	}
	*/
	mapWidgetsToolkits(w, newt)
}