summaryrefslogtreecommitdiff
path: root/debug.go
blob: 63c196b3b390a30663b6faaab109aef77987d54e (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
package main

import (
	"fmt"

	"go.wit.com/log"
	"go.wit.com/widget"
)

func (w *guiWidget) dumpTree(s string) {
	// log.Log(ERROR, "dumpTree w", w.node.WidgetId, w.WidgetType, w.String())
	if w == nil {
		log.Log(ERROR, "dumpTree w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
		return
	}
	w.showWidgetPlacement("dumpTree() " + s)

	for _, child := range w.children {
		child.dumpTree(s)
	}
}

func (w *guiWidget) showWidgetPlacement(s string) {
	var s1 string
	var pId int
	if w.node.Parent == nil {
		log.Log(INFO, "showWidgetPlacement() parent == nil", w.node.WidgetId, w.cuiName)
		pId = 0
	} else {
		pId = w.node.Parent.WidgetId
	}
	s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.node.WidgetId, pId)
	if w.Visible() {
		sizeW, sizeH := w.Size()
		s1 += fmt.Sprintf("size=(%2d,%2d)", sizeW, sizeH)
		s1 += fmt.Sprintf("gocui=(%2d,%2d,%2d,%2d)",
			w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
	} else {
		sizeW, sizeH := w.Size()
		s1 += fmt.Sprintf("size=(%2d,%2d)", sizeW, sizeH)
		s1 += fmt.Sprintf("                 ")
	}
	if w.node.Parent != nil {
		if w.node.Parent.WidgetType == widget.Grid {
			s1 += fmt.Sprintf("At(%2d,%2d) ", w.node.State.AtW, w.node.State.AtH)
		}
	}
	tmp := "." + w.String() + ". " + w.cuiName
	if w.node.WidgetType == widget.Box {
		tmp = "." + w.node.State.Direction.String() + ". " + w.cuiName
	}
	log.Log(NOW, s1, s, w.node.WidgetType, ",", tmp) //
}