window setTitle()

This commit is contained in:
Jeff Carr 2025-02-08 07:29:42 -06:00
parent fefa99920b
commit 83b4d7142a
1 changed files with 30 additions and 1 deletions

View File

@ -11,6 +11,24 @@ import (
"go.wit.com/widget" "go.wit.com/widget"
) )
func (tk *guiWidget) setTitle(s string) {
if tk.node.WidgetType != widget.Window {
return
}
if tk.v == nil {
return
}
rect := tk.gocuiSize
rect.w1 = rect.w0 + tk.full.Width() + 1
// rect.h1 = rect.h0 + 1
me.baseGui.SetView(tk.v.Name(), rect.w0, rect.h0, rect.w1, rect.h1, 0)
tk.v.Clear()
f := "%-" + fmt.Sprintf("%d", tk.full.Width()-3) + "s %s"
tmp := tk.node.GetLabel() + " " + tk.v.Name() + " " + f
labelN := fmt.Sprintf(f, tmp, "XX")
tk.v.WriteString(labelN)
}
func (tk *guiWidget) redrawWindow(w int, h int) { func (tk *guiWidget) redrawWindow(w int, h int) {
if tk.node.WidgetType != widget.Window { if tk.node.WidgetType != widget.Window {
return return
@ -22,7 +40,8 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
// pin the window to (w,h) // pin the window to (w,h)
tk.gocuiSize.w0 = w tk.gocuiSize.w0 = w
tk.gocuiSize.h0 = h tk.gocuiSize.h0 = h
tk.gocuiSize.w1 = w + len(tk.GetText()) tk.gocuiSize.w1 = w + len(tk.node.GetLabel())
tk.labelN = tk.node.GetLabel() + " XX"
tk.force.w0 = w tk.force.w0 = w
tk.force.w1 = w tk.force.w1 = w
tk.force.h0 = h tk.force.h0 = h
@ -92,6 +111,16 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
// so we have to redraw the widgets in the window anyway and then they will appear above he frame // so we have to redraw the widgets in the window anyway and then they will appear above he frame
tk.hideWidgets() tk.hideWidgets()
tk.showWidgets() tk.showWidgets()
/*
tk.gocuiSize.w1 = tk.gocuiSize.w0 + tk.full.Width()
f := "%-" + fmt.Sprintf("%d", tk.full.Width()) + "s %s"
tk.labelN = fmt.Sprintf(f, tk.node.GetLabel(), "XX")
log.Info("f =", f)
log.Info("label =", tk.labelN)
tk.dumpWidget(fmt.Sprintf("label"))
*/
tk.setTitle(tk.node.GetLabel() + " jwc")
} }
// re-draws the buttons for each of the windows // re-draws the buttons for each of the windows