// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( log "go.wit.com/log" "go.wit.com/toolkits/tree" "go.wit.com/widget" ) var fakeStartWidth int = me.FakeW var fakeStartHeight int = me.TabH + me.FramePadH // setup fake labels for non-visible things off screen func setFake(n *tree.Node) { var w *guiWidget w = n.TK.(*guiWidget) w.isFake = true w.gocuiSetWH(fakeStartWidth, fakeStartHeight) fakeStartHeight += w.gocuiSize.Height() // TODO: use the actual max hight of the terminal window if fakeStartHeight > 24 { fakeStartHeight = me.TabH fakeStartWidth += me.FakeW } } // set the widget start width & height // func (n *node) addWidget(n *tree.Node) { func addWidget(n *tree.Node) { var tk *guiWidget tk = n.TK.(*guiWidget) log.Log(INFO, "setStartWH() w.id =", n.WidgetId, "n.name", n.String()) switch n.WidgetType { case widget.Root: log.Log(INFO, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.String()) tk.color = &colorRoot setFake(n) return case widget.Flag: tk.color = &colorFlag setFake(n) return case widget.Window: tk.frame = false tk.labelN = tk.GetText() + " X" // tk.color = &colorWindow tk.setColor(&colorWindow) me.newWindowTrigger <- tk redoWindows(0, 0) hideHelp() showHelp() return case widget.Stdout: tk.labelN = "moreSTDOUT" n.State.ProgName = "moreSTDOUT" n.State.Label = "moreSTDOUT" return case widget.Tab: tk.color = &colorTab return case widget.Button: tk.color = &colorButton return case widget.Checkbox: tk.color = &colorCheckbox tk.labelN = "X " + n.State.Label return case widget.Dropdown: tk.color = &colorDropdown return case widget.Textbox: n.State.Label = "TEXTBOX" tk.labelN = " " + n.State.Label tk.color = &colorDropdown return case widget.Combobox: tk.color = &colorCombobox return case widget.Box: tk.color = &colorBox tk.isFake = true setFake(n) return case widget.Grid: tk.color = &colorGrid tk.isFake = true setFake(n) return case widget.Group: tk.color = &colorGroup tk.frame = false return case widget.Label: tk.color = &colorLabel tk.frame = false return default: /* if n.IsCurrent() { n.updateCurrent() } */ } tk.dumpWidget("addWidget()unknown") }