summaryrefslogtreecommitdiff
path: root/toolkit/gocui/checkbox.go
blob: 5568ee33b20f99fd4975c40fcf7b399a679454a0 (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
package main

import (
//	"github.com/awesome-gocui/gocui"
	"git.wit.org/wit/gui/toolkit"
)

func (w *cuiWidget) setCheckbox(b bool) {
	if (w.widgetType != toolkit.Checkbox) {
		return
	}
	if (b) {
		w.b = b
		w.text = "X " + w.name
	} else {
		w.b = b
		w.text = "  " + w.name
	}
	t := len(w.text) + 1
	w.gocuiSize.w1 = w.gocuiSize.w0 + t

	w.realWidth = w.gocuiSize.Width() + me.PadW
	w.realHeight = w.gocuiSize.Height() + me.PadH

	if w.frame {
		w.realWidth += me.FramePadW
		w.realHeight += me.FramePadH
	}

	w.deleteView()
	w.showView()
}