summaryrefslogtreecommitdiff
path: root/toolkit/gocui/debug.go
blob: 26690677e222bbf20f8b4dadfa748a576144cc42 (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
70
71
72
73
package main

import (
	"fmt"
	"git.wit.org/wit/gui/toolkit"
)

func (n *node) dumpTree(draw bool) {
	w := n.tk
	if (w == nil) {
		return
	}
	n.showWidgetPlacement(logNow, "dumpTree()")

	for _, child := range n.children {
		child.dumpTree(draw)
	}
}

func (n *node) showWidgetPlacement(b bool, s string) {
	if (n == nil) {
		log(logError, "WTF w == nil")
		return
	}
	w := n.tk

	var s1 string
	var pId int
	if (n.parent == nil) {
		log(logVerbose, "showWidgetPlacement() parent == nil", n.WidgetId, w.cuiName)
		pId = 0
	} else {
		pId = n.parent.WidgetId
	}
	s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", n.WidgetId, pId)
	if n.Visible() {
		s1 += fmt.Sprintf("gocui=(%2d,%2d)(%2d,%2d,%2d,%2d)",
			w.gocuiSize.Width(), w.gocuiSize.Height(),
			w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
	} else {
		s1 += fmt.Sprintf("                          ")
	}
	if (n.parent != nil) {
		if (n.parent.WidgetType == toolkit.Grid) {
			s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH)
		}
	}
	tmp := "." + n.Name + "."
	log(b, s1, s, n.WidgetType, ",", tmp) // , "text=", w.text)
}

func (n *node) dumpWidget(pad string) {
	log(true, "node:", pad, n.WidgetId, "At(", n.AtW, n.AtH, ") ,", n.WidgetType, ", n.Name =", n.Name, ", n.Text =", n.Text)
}

func (n *node) listWidgets() {
	if (n == nil) {
		return
	}

	var pad string
	for i := 0; i < me.depth; i++ {
		pad = pad + "    "
	}
	n.dumpWidget(pad)

	for _, child := range n.children {
		me.depth += 1
		child.listWidgets()
		me.depth -= 1
	}
	return
}