2025-02-01 11:42:31 -06:00
|
|
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
|
2024-01-18 00:08:37 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-01-28 02:20:31 -06:00
|
|
|
|
2024-01-18 00:08:37 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-18 04:10:08 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:08:37 -06:00
|
|
|
)
|
|
|
|
|
2024-01-28 14:03:06 -06:00
|
|
|
func (w *guiWidget) dumpTree(s string) {
|
2025-01-31 12:08:13 -06:00
|
|
|
// log.Log(ERROR, "dump w", w.node.WidgetId, w.WidgetType, w.String())
|
2024-01-18 00:08:37 -06:00
|
|
|
if w == nil {
|
2025-01-31 12:08:13 -06:00
|
|
|
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
|
2024-01-18 00:08:37 -06:00
|
|
|
return
|
|
|
|
}
|
2025-02-01 13:43:51 -06:00
|
|
|
w.dumpWidget("dumpTree() " + s)
|
2024-01-18 00:08:37 -06:00
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
for _, child := range w.children {
|
2024-01-28 14:03:06 -06:00
|
|
|
child.dumpTree(s)
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:43:51 -06:00
|
|
|
// a standard function to print out information about a widget
|
|
|
|
func (w *guiWidget) dumpWidget(s string) {
|
2024-01-18 00:08:37 -06:00
|
|
|
var s1 string
|
|
|
|
var pId int
|
2024-01-28 02:20:31 -06:00
|
|
|
if w.node.Parent == nil {
|
|
|
|
log.Log(INFO, "showWidgetPlacement() parent == nil", w.node.WidgetId, w.cuiName)
|
2024-01-18 00:08:37 -06:00
|
|
|
pId = 0
|
|
|
|
} else {
|
2024-01-28 02:20:31 -06:00
|
|
|
pId = w.node.Parent.WidgetId
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 = fmt.Sprintf("(wId,pId)=(%4d,%4d) ", w.node.WidgetId, pId)
|
2025-01-29 07:55:56 -06:00
|
|
|
sizeW, sizeH := w.Size()
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
|
2024-01-28 02:20:31 -06:00
|
|
|
if w.Visible() {
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
|
2024-01-18 00:08:37 -06:00
|
|
|
w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
|
|
|
|
} else {
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
2024-01-28 02:20:31 -06:00
|
|
|
if w.node.Parent != nil {
|
|
|
|
if w.node.Parent.WidgetType == widget.Grid {
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 += fmt.Sprintf("At(%3d,%3d) ", w.node.State.AtW, w.node.State.AtH)
|
2025-01-29 07:55:56 -06:00
|
|
|
} else {
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 += fmt.Sprintf(" %3s %3s ", "", "")
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
2025-01-29 07:55:56 -06:00
|
|
|
} else {
|
2025-01-31 12:08:13 -06:00
|
|
|
s1 += fmt.Sprintf(" %3s %3s ", "", "")
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
2025-01-31 12:08:13 -06:00
|
|
|
var end string
|
2024-02-05 04:28:42 -06:00
|
|
|
if w.node.WidgetType == widget.Box {
|
2025-01-31 12:08:13 -06:00
|
|
|
end = fmt.Sprintf("%5s %-8s %s", w.cuiName, w.node.WidgetType, w.node.State.Direction.String())
|
|
|
|
} else {
|
|
|
|
end = fmt.Sprintf("%5s %-8s %s", w.cuiName, w.node.WidgetType, w.String())
|
2024-02-05 04:28:42 -06:00
|
|
|
}
|
2025-01-31 12:08:13 -06:00
|
|
|
log.Log(NOW, s1, s, end)
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|