2024-01-18 00:08:37 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
2024-01-18 04:10:08 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:08:37 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func (w *guiWidget) Width() int {
|
|
|
|
if w.frame {
|
|
|
|
return w.gocuiSize.w1 - w.gocuiSize.w0
|
|
|
|
}
|
|
|
|
return w.gocuiSize.w1 - w.gocuiSize.w0 - 1
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *guiWidget) Height() int {
|
|
|
|
if w.frame {
|
|
|
|
return w.gocuiSize.h1 - w.gocuiSize.h0
|
|
|
|
}
|
|
|
|
return w.gocuiSize.h1 - w.gocuiSize.h0 - 1
|
|
|
|
}
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
|
|
|
|
w := len(widget.GetString(tk.value))
|
|
|
|
lines := strings.Split(widget.GetString(tk.value), "\n")
|
2024-01-18 00:08:37 -06:00
|
|
|
h := len(lines)
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
// tk := n.tk
|
2024-01-18 00:08:37 -06:00
|
|
|
if tk.isFake {
|
|
|
|
tk.gocuiSize.w0 = sizeW
|
|
|
|
tk.gocuiSize.h0 = sizeH
|
|
|
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW
|
|
|
|
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if tk.frame {
|
|
|
|
tk.gocuiSize.w0 = sizeW
|
|
|
|
tk.gocuiSize.h0 = sizeH
|
|
|
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW
|
|
|
|
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH
|
|
|
|
} else {
|
|
|
|
tk.gocuiSize.w0 = sizeW - 1
|
|
|
|
tk.gocuiSize.h0 = sizeH - 1
|
|
|
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + 1
|
|
|
|
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func redoWindows(nextW int, nextH int) {
|
2024-01-28 02:20:31 -06:00
|
|
|
wRoot := me.treeRoot.TK.(*guiWidget)
|
|
|
|
for _, win := range wRoot.children {
|
|
|
|
if win.node.WidgetType != widget.Window {
|
2024-01-18 00:08:37 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
var tabs bool
|
2024-01-28 02:20:31 -06:00
|
|
|
for _, child := range win.children {
|
|
|
|
if child.node.WidgetType == widget.Tab {
|
2024-01-18 00:08:37 -06:00
|
|
|
tabs = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if tabs {
|
|
|
|
// window is tabs. Don't show it as a standard button
|
2024-01-28 02:20:31 -06:00
|
|
|
win.frame = false
|
|
|
|
win.hasTabs = true
|
2024-01-18 00:08:37 -06:00
|
|
|
} else {
|
2024-01-28 02:20:31 -06:00
|
|
|
win.frame = false
|
|
|
|
win.hasTabs = false
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
win.gocuiSetWH(nextW, nextH)
|
|
|
|
win.deleteView()
|
|
|
|
win.showView()
|
2024-01-18 00:08:37 -06:00
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
sizeW := win.Width() + me.WindowPadW
|
|
|
|
sizeH := win.Height()
|
2024-01-18 00:08:37 -06:00
|
|
|
nextW += sizeW
|
2024-01-28 02:20:31 -06:00
|
|
|
log.Log(NOW, "redoWindows() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, win.String())
|
2024-01-18 00:08:37 -06:00
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
if win.hasTabs {
|
|
|
|
win.redoTabs(me.TabW, me.TabH)
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
func (p *guiWidget) redoTabs(nextW int, nextH int) {
|
|
|
|
for _, w := range p.children {
|
|
|
|
if w.node.WidgetType != widget.Tab {
|
2024-01-18 00:08:37 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
w.frame = true
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
w.gocuiSetWH(nextW, nextH)
|
|
|
|
w.deleteView()
|
2024-01-18 00:08:37 -06:00
|
|
|
// setCurrentTab(n)
|
|
|
|
// if (len(w.cuiName) < 4) {
|
|
|
|
// w.cuiName = "abcd"
|
|
|
|
// }
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
w.showView()
|
2024-01-18 00:08:37 -06:00
|
|
|
|
|
|
|
sizeW := w.Width() + me.TabPadW
|
|
|
|
sizeH := w.Height()
|
2024-01-28 02:20:31 -06:00
|
|
|
log.Log(NOW, "redoTabs() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, w.String())
|
2024-01-18 00:08:37 -06:00
|
|
|
nextW += sizeW
|
|
|
|
}
|
|
|
|
}
|
2024-01-28 11:44:36 -06:00
|
|
|
|
|
|
|
func (p *guiWidget) drawWindow(nextW int, nextH int) {
|
|
|
|
for _, w := range p.children {
|
|
|
|
w.frame = true
|
|
|
|
|
|
|
|
w.gocuiSetWH(nextW, nextH)
|
|
|
|
w.deleteView()
|
|
|
|
// setCurrentTab(n)
|
|
|
|
// if (len(w.cuiName) < 4) {
|
|
|
|
// w.cuiName = "abcd"
|
|
|
|
// }
|
|
|
|
|
|
|
|
w.showView()
|
|
|
|
|
|
|
|
sizeW := w.Width() + me.TabPadW
|
|
|
|
sizeH := w.Height()
|
|
|
|
log.Log(NOW, "redoTabs() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, w.String())
|
|
|
|
nextW += sizeW
|
|
|
|
}
|
|
|
|
}
|