Ejemplo n.º 1
0
func (p *AlertDialog) Init() *AlertDialog {
	p.Dialog = ui.NewDialog()
	p.SetWindowTitle("Alert Dialog")

	vbox := ui.NewVBoxLayout()

	p.SetLayout(vbox)

	btn := ui.NewButton()
	btn.SetText("OK")
	btn.OnClicked(func() {
		p.Close()
	})

	p.btn = btn

	lbl := ui.NewLabel()
	p.lbl = lbl

	vbox.AddWidget(lbl)
	//	vbox.AddStretch(0)
	vbox.AddWidget(btn)

	return p
}
Ejemplo n.º 2
0
func (p *MainWindow) createStdTab() *ui.Widget {
	w := ui.NewWidget()
	vbox := ui.NewVBoxLayout()
	w.SetLayout(vbox)

	ed := ui.NewLineEdit()
	ed.SetInputMask("0000-00-00")
	ed.SetText("2012-01-12")

	lbl := ui.NewLabel()
	lbl.SetText("Label")
	btn := ui.NewButton()
	btn.SetText("Button")
	chk := ui.NewCheckBox()
	chk.SetText("CheckBox")
	radio := ui.NewRadio()
	radio.SetText("Radio")
	cmb := ui.NewComboBox()
	cmb.AddItem("001")
	cmb.AddItem("002")
	cmb.AddItem("003")
	cmb.SetCurrentIndex(2)
	fmt.Println(cmb.CurrentIndex())
	cmb.OnCurrentIndexChanged(func(v int) {
		fmt.Println(cmb.ItemText(v))
	})

	slider := ui.NewSlider()
	slider.SetTickInterval(50)
	slider.SetTickPosition(ui.TicksBothSides)
	slider.SetSingleStep(1)

	scl := ui.NewScrollBar()
	fmt.Println(slider.Range())

	dial := ui.NewDial()

	dial.SetNotchesVisible(true)
	dial.SetNotchTarget(10)
	fmt.Println(dial.NotchSize())

	vbox.AddWidget(ed)
	vbox.AddWidget(lbl)
	vbox.AddWidget(btn)
	vbox.AddWidget(chk)
	vbox.AddWidget(radio)
	vbox.AddWidget(cmb)
	vbox.AddWidget(slider)
	vbox.AddWidget(scl)
	vbox.AddWidget(dial)
	vbox.AddStretch(0)
	return w
}
Ejemplo n.º 3
0
func (p *MainWindow) createToolBox() ui.IWidget {
	tb := ui.NewToolBox()
	tb.AddItem(ui.NewButtonWithText("button"), "btn", nil)
	tb.AddItem(ui.NewLabelWithText("Label\nInfo"), "Label", nil)
	pixmap := ui.NewPixmapWithFile("images/liteide128.png")
	//defer pixmap.Close()
	lbl := ui.NewLabel()
	lbl.SetPixmap(pixmap)
	tb.AddItem(lbl, "Lalel Pixmap", nil)
	buf, err := ioutil.ReadFile("images/liteide128.png")
	if err == nil {
		pixmap2 := ui.NewPixmapWithData(buf)
		tb.AddItem(ui.NewLabelWithPixmap(pixmap2), "Lalel Pixmap2", nil)
	}
	return tb
}
Ejemplo n.º 4
0
func (p *MainWindow) createMyTab() *ui.Widget {
	w := ui.NewWidget()
	vbox := ui.NewVBoxLayout()
	hbox := ui.NewHBoxLayout()
	my := new(MyWidget).Init()
	lbl := ui.NewLabel()
	lbl.SetText("this is custome widget - draw lines")
	btn := ui.NewButton()
	btn.SetText("Clear")
	btn.OnClicked(func() {
		my.Clear()
	})
	hbox.AddWidget(lbl)
	hbox.AddWidgetWith(btn, 0, ui.AlignRight)
	vbox.AddLayout(hbox)
	vbox.AddWidgetWith(my, 1, 0)
	w.SetLayout(vbox)
	return w
}
Ejemplo n.º 5
0
func main_ui() {
	ui.OnInsertObject(func(item interface{}) {
		fmt.Println("add item", item)
	})
	ui.OnRemoveObject(func(item interface{}) {
		fmt.Println("remove item", item)
	})

	w := ui.NewWidget()
	defer w.Close()

	w.SetWindowTitle("This is a test")
	fmt.Println(w.WindowTitle())

	vbox := ui.NewVBoxLayout()
	fmt.Println(vbox)
	w.SetLayout(vbox)

	lbl := ui.NewLabel()
	lbl.SetText("<h2><i>Hello</i> <font color=blue><a href=\"ui\">UI</a></font></h2>")
	lbl.OnLinkActivated(fnTEST)
	vbox.AddWidget(lbl)
	vbox.AddStretch(0)

	//runtime.GC()

	btn := ui.NewButton()
	btn.SetText("WbcdefgwqABCDEFQW")
	font := btn.Font()
	defer font.Close()
	font.SetPointSize(16)
	btn.SetFont(font)
	fmt.Println("f3->", btn.Font())

	btn2 := ui.NewButton()
	font.SetPointSize(18)
	btn2.SetAttr("text", "WbcdefgwqABCDEFQW")
	btn2.SetAttr("font", font)

	btn.OnClicked(func() {
		fmt.Println(btn)
		btn.Close()
	})
	btn.OnCloseEvent(func(e *ui.CloseEvent) {
		fmt.Println("Close", e)
	})
	btn3 := ui.NewButton()
	btn3.SetText("Exit")
	btn3.OnClicked(func() {
		ui.Exit(0)
	})

	l := w.Layout()
	fmt.Println("ll", l)
	l.AddWidget(btn)
	l.AddWidget(btn2)
	l.AddWidget(btn3)
	//vbox.AddWidget(btn)
	f := btn2.Attr("parent")
	fmt.Println("parent->", f, f == nil)

	fmt.Println(btn.Font())

	w.OnResizeEvent(func(e *ui.ResizeEvent) {
		fmt.Println(e)
	})

	w.OnPaintEvent(func(ev *ui.PaintEvent) {
		fnPaint(ev, w)
	})

	//w.Show()
	w.SetVisible(true)
	<-exit
}