100 lines
1.8 KiB
Go
100 lines
1.8 KiB
Go
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"go.wit.com/widget"
|
|
)
|
|
|
|
// expands the gocuiSize rectangle to fit
|
|
// all the text in tk.labelN
|
|
func (tk *guiWidget) textResize() {
|
|
var w, h int = 0, 0
|
|
|
|
for _, s := range strings.Split(tk.labelN, "\n") {
|
|
s = strings.TrimSpace(s)
|
|
// log.Log(INFO, "textResize() len =", len(s), i, s)
|
|
if w < len(s) {
|
|
w = len(s)
|
|
}
|
|
h += 1
|
|
}
|
|
|
|
// this is old code. now move this somewhere smarter
|
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW // TODO: move this FramePadW out of here
|
|
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH // TODO: fix this size computation
|
|
}
|
|
|
|
// deletes every view
|
|
func (w *guiWidget) hideWindow() {
|
|
if w == nil {
|
|
return
|
|
}
|
|
w.Hide()
|
|
for _, child := range w.children {
|
|
child.hideWindow()
|
|
}
|
|
}
|
|
|
|
func (w *guiWidget) hideWidgets() {
|
|
if w == nil {
|
|
return
|
|
}
|
|
switch w.node.WidgetType {
|
|
case widget.Root:
|
|
case widget.Flag:
|
|
case widget.Window:
|
|
case widget.Box:
|
|
case widget.Grid:
|
|
default:
|
|
w.Hide()
|
|
}
|
|
for _, child := range w.children {
|
|
child.hideWidgets()
|
|
}
|
|
}
|
|
|
|
func hideFake() {
|
|
var w *guiWidget
|
|
w = me.treeRoot.TK.(*guiWidget)
|
|
w.hideFake()
|
|
}
|
|
|
|
func showFake() {
|
|
var w *guiWidget
|
|
w = me.treeRoot.TK.(*guiWidget)
|
|
w.showFake()
|
|
}
|
|
|
|
func (w *guiWidget) hideFake() {
|
|
if w.isFake {
|
|
w.Hide()
|
|
}
|
|
for _, child := range w.children {
|
|
child.hideFake()
|
|
}
|
|
}
|
|
|
|
// shows the 'fake' widgets for widgets that
|
|
// are not normally displayed (like a grid widget)
|
|
func (w *guiWidget) showFake() {
|
|
if w.isFake {
|
|
w.drawView()
|
|
w.dumpWidget("in showFake()")
|
|
}
|
|
for _, child := range w.children {
|
|
child.showFake()
|
|
}
|
|
}
|
|
|
|
func (w *guiWidget) showWidgets() {
|
|
w.Show()
|
|
|
|
for _, child := range w.children {
|
|
child.showWidgets()
|
|
}
|
|
}
|