Beispiel #1
0
func makeExpander(dir string) gwu.Expander {
	e := gwu.NewExpander()
	e.SetHeader(gwu.NewLabel(dir))
	e.Style().SetPaddingLeft("20")
	expanderDir[e] = dir
	return e
}
Beispiel #2
0
func buildExpanderDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	l := gwu.NewLabel("Click on the Expander's header.")
	l.Style().SetColor(gwu.CLR_GREEN)
	p.Add(l)
	p.AddVSpace(5)
	e := gwu.NewExpander()
	e.SetHeader(gwu.NewLabel("I'm an Expander."))
	e.SetContent(gwu.NewLabel("I'm the content of the Expander."))
	p.Add(e)
	e.AddEHandlerFunc(func(ev gwu.Event) {
		if e.Expanded() {
			l.SetText("You expanded it.")
		} else {
			l.SetText("You collapsed it.")
		}
		ev.MarkDirty(l)
	}, gwu.ETYPE_STATE_CHANGE)

	p.AddVSpace(20)
	var ee gwu.Expander
	for i := 4; i >= 0; i-- {
		e2 := gwu.NewExpander()
		e2.SetHeader(gwu.NewLabel("I hide embedded expanders. #" + strconv.Itoa(i)))
		if i == 4 {
			e2.SetContent(gwu.NewLabel("No more."))
		} else {
			e2.SetContent(ee)
		}
		ee = e2
	}
	p.Add(ee)

	return p
}