2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
import (
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
"git.wit.org/wit/gui/toolkit"
|
|
|
|
)
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
func newLabel(parentW *toolkit.Widget, w *toolkit.Widget) {
|
|
|
|
var newt *andlabsT
|
|
|
|
log(debugToolkit, "NewLabel()", w.Name)
|
2022-11-14 14:30:28 -06:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
t := mapToolkits[parentW]
|
|
|
|
if (t == nil) {
|
2023-03-01 11:35:36 -06:00
|
|
|
listMap(debugError)
|
|
|
|
log(debugError, "ERROR newLabel() listMap()")
|
|
|
|
log(debugError, "ERROR FFFFFFFFFFFF listMap()")
|
|
|
|
log(debugError, "ERROR FFFFFFFFFFFF listMap()")
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
|
|
|
}
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
log(debugToolkit, "NewLabel()", w.Name)
|
2022-10-21 11:40:08 -05:00
|
|
|
if t.broken() {
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
2022-10-16 10:09:16 -05:00
|
|
|
}
|
2022-11-14 14:30:28 -06:00
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
newt = new(andlabsT)
|
|
|
|
|
2023-03-03 14:41:38 -06:00
|
|
|
c := ui.NewLabel(w.Name)
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.uiLabel = c
|
|
|
|
|
2022-10-19 13:23:22 -05:00
|
|
|
newt.uiBox = t.uiBox
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.tw = w
|
|
|
|
if (defaultBehavior) {
|
|
|
|
t.uiBox.Append(c, stretchy)
|
|
|
|
}
|
|
|
|
|
|
|
|
mapWidgetsToolkits(w, newt)
|
|
|
|
}
|
2022-10-16 10:09:16 -05:00
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
// This routine is very specific to this toolkit
|
|
|
|
// It's annoying and has to be copied to each widget when there are changes
|
|
|
|
// it could be 'simplfied' maybe or made to be more generic, but this is as far as I've gotten
|
|
|
|
// it's probably not worth working much more on this toolkit, the andlabs/ui has been great and got me here!
|
|
|
|
// but it's time to write direct GTK, QT, macos and windows toolkit plugins
|
|
|
|
// -- jcarr 2023/03/09
|
|
|
|
|
2023-03-01 11:35:36 -06:00
|
|
|
func doLabel(p *toolkit.Widget, c *toolkit.Widget) {
|
|
|
|
if broken(c) {
|
|
|
|
return
|
|
|
|
}
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugChange, "Going to attempt:", c.Action)
|
2023-03-01 11:35:36 -06:00
|
|
|
if (c.Action == "New") {
|
|
|
|
newLabel(p, c)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ct := mapToolkits[c]
|
|
|
|
if (ct == nil) {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
|
2023-03-01 11:35:36 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if ct.broken() {
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Label() ct.broken", ct)
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
if (ct.uiLabel == nil) {
|
|
|
|
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Label() uiLabel == nil", ct)
|
2023-03-01 11:35:36 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
switch c.Action {
|
|
|
|
case "Enable":
|
|
|
|
ct.uiLabel.Enable()
|
|
|
|
case "Disable":
|
|
|
|
ct.uiLabel.Disable()
|
|
|
|
case "Show":
|
|
|
|
ct.uiLabel.Show()
|
|
|
|
case "Hide":
|
|
|
|
ct.uiLabel.Hide()
|
2023-03-12 08:47:16 -05:00
|
|
|
case "SetText":
|
|
|
|
ct.uiLabel.SetText(c.S)
|
2023-03-01 11:35:36 -06:00
|
|
|
case "Set":
|
|
|
|
ct.uiLabel.SetText(c.S)
|
|
|
|
default:
|
2023-03-12 08:47:16 -05:00
|
|
|
log(debugError, "Can't do", c.Action, "to a Label")
|
2023-03-01 11:35:36 -06:00
|
|
|
}
|
2022-10-16 10:09:16 -05:00
|
|
|
}
|