gocui/tab.go

119 lines
2.4 KiB
Go

package main
import (
"strings"
"go.wit.com/widget"
)
/*
func (w *guiWidget) RealWidth() 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
}
*/
func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
w := len(widget.GetString(tk.value))
lines := strings.Split(widget.GetString(tk.value), "\n")
h := len(lines)
// tk := n.tk
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 (w *guiWidget) redoWindows(nextW int, nextH int) {
var startW int = nextW
var startH int = nextH
for _, child := range w.children {
if child.node.WidgetType != widget.Window {
continue
}
child.frame = false
child.hasTabs = false
child.gocuiSetWH(nextW, nextH)
child.deleteView()
child.showView()
sizeW := child.gocuiSize.Width()
nextW += sizeW + 4
child.redoWindows(startW+3, startH+2)
}
}
/*
func (p *guiWidget) redoTabs(nextW int, nextH int) {
for _, w := range p.children {
if w.node.WidgetType != widget.Tab {
continue
}
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
}
}
*/
/*
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.gocuiSize.Width() + me.TabPadW
sizeH := w.gocuiSize.Height()
log.Log(NOW, "redoTabs() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, w.String())
nextW += sizeW
}
}
*/