Example #1
0
File: main.go Project: langxj/gxui
// Color picker uses the customAdapter for driving a list
func colorPicker(theme gxui.Theme) gxui.Control {
	layout := theme.CreateLinearLayout()
	layout.SetDirection(gxui.TopToBottom)

	label0 := theme.CreateLabel()
	label0.SetText("Color palette:")
	layout.AddChild(label0)

	adapter := &customAdapter{}

	list := theme.CreateList()
	list.SetAdapter(adapter)
	list.SetOrientation(gxui.Horizontal)
	layout.AddChild(list)

	label1 := theme.CreateLabel()
	label1.SetMargin(math.Spacing{T: 30})
	label1.SetText("Selected color:")
	layout.AddChild(label1)

	selected := theme.CreateImage()
	selected.SetExplicitSize(math.Size{W: 32, H: 32})
	layout.AddChild(selected)

	list.OnSelectionChanged(func(item gxui.AdapterItem) {
		if item != nil {
			control := list.ItemControl(item)
			selected.SetBackgroundBrush(control.(gxui.Image).BackgroundBrush())
		}
	})

	return layout
}
Example #2
0
func (defaultTreeControlCreator) Create(theme gxui.Theme, control gxui.Control, node *TreeToListNode) gxui.Control {
	ll := theme.CreateLinearLayout()
	ll.SetDirection(gxui.LeftToRight)

	btn := theme.CreateButton()
	btn.SetBackgroundBrush(gxui.TransparentBrush)
	btn.SetBorderPen(gxui.CreatePen(1, gxui.Gray30))
	btn.SetMargin(math.Spacing{L: 2, R: 2, T: 1, B: 1})
	btn.OnClick(func(ev gxui.MouseEvent) {
		if ev.Button == gxui.MouseButtonLeft {
			node.ToggleExpanded()
		}
	})

	update := func() {
		btn.SetVisible(!node.IsLeaf())
		if node.IsExpanded() {
			btn.SetText("-")
		} else {
			btn.SetText("+")
		}
	}
	update()

	gxui.WhileAttached(btn, node.OnChange, update)

	ll.AddChild(btn)
	ll.AddChild(control)
	ll.SetPadding(math.Spacing{L: 16 * node.Depth()})
	return ll
}
Example #3
0
func transactions(theme gxui.Theme) gxui.Control {
	layout := theme.CreateLinearLayout()

	font := theme.DefaultFont()

	label := theme.CreateLabel()
	label.SetFont(font)
	label.SetText("Transactions")

	layout.AddChild(label)

	return layout
}
Example #4
0
func receive(theme gxui.Theme) gxui.Control {
	layout := theme.CreateLinearLayout()

	font := theme.DefaultFont()

	label := theme.CreateLabel()
	label.SetFont(font)
	label.SetText("receive")

	layout.AddChild(label)

	return layout
}
Example #5
0
File: main.go Project: langxj/gxui
// Number picker uses the gxui.DefaultAdapter for driving a list
func numberPicker(theme gxui.Theme, overlay gxui.BubbleOverlay) gxui.Control {
	items := []string{
		"zero", "one", "two", "three", "four", "five",
		"six", "seven", "eight", "nine", "ten",
		"eleven", "twelve", "thirteen", "fourteen", "fifteen",
		"sixteen", "seventeen", "eighteen", "nineteen", "twenty",
	}

	adapter := gxui.CreateDefaultAdapter()
	adapter.SetItems(items)

	layout := theme.CreateLinearLayout()
	layout.SetDirection(gxui.TopToBottom)

	label0 := theme.CreateLabel()
	label0.SetText("Numbers:")
	layout.AddChild(label0)

	dropList := theme.CreateDropDownList()
	dropList.SetAdapter(adapter)
	dropList.SetBubbleOverlay(overlay)
	layout.AddChild(dropList)

	list := theme.CreateList()
	list.SetAdapter(adapter)
	list.SetOrientation(gxui.Vertical)
	layout.AddChild(list)

	label1 := theme.CreateLabel()
	label1.SetMargin(math.Spacing{T: 30})
	label1.SetText("Selected number:")
	layout.AddChild(label1)

	selected := theme.CreateLabel()
	layout.AddChild(selected)

	dropList.OnSelectionChanged(func(item gxui.AdapterItem) {
		if list.Selected() != item {
			list.Select(item)
		}
	})

	list.OnSelectionChanged(func(item gxui.AdapterItem) {
		if dropList.Selected() != item {
			dropList.Select(item)
		}
		selected.SetText(fmt.Sprintf("%s - %d", item, adapter.ItemIndex(item)))
	})

	return layout
}
Example #6
0
// mixins.TextBox overrides
func (t *CodeEditor) CreateLine(theme gxui.Theme, index int) (TextBoxLine, gxui.Control) {
	lineNumber := theme.CreateLabel()
	lineNumber.SetText(fmt.Sprintf("%.4d", index+1)) // Displayed lines start at 1

	line := &CodeEditorLine{}
	line.Init(line, theme, t, index)

	layout := theme.CreateLinearLayout()
	layout.SetDirection(gxui.LeftToRight)
	layout.AddChild(lineNumber)
	layout.AddChild(line)

	return line, layout
}
Example #7
0
func makeDataField(theme gxui.Theme, label string) *dataField {
	df := new(dataField)
	df.label = theme.CreateLabel()
	df.label.SetText(label)
	df.input = theme.CreateTextBox()
	df.err = theme.CreateLabel()
	df.err.SetColor(gxui.Red)
	df.layout = theme.CreateLinearLayout()
	df.layout.SetDirection(gxui.LeftToRight)
	df.layout.AddChild(df.label)
	df.layout.AddChild(df.input)
	df.layout.AddChild(df.err)

	return df
}
Example #8
0
func (p *PanelHolder) Init(outer PanelHolderOuter, theme gxui.Theme) {
	p.Container.Init(outer, theme)

	p.outer = outer
	p.theme = theme

	p.tabLayout = theme.CreateLinearLayout()
	p.tabLayout.SetDirection(gxui.LeftToRight)
	p.Container.AddChild(p.tabLayout)
	p.SetMargin(math.Spacing{L: 1, T: 2, R: 1, B: 1})
	p.SetMouseEventTarget(true) // For drag-drop targets

	// Interface compliance test
	_ = gxui.PanelHolder(p)
}
Example #9
0
func overview(theme gxui.Theme) gxui.Control {
	layout := theme.CreateLinearLayout()
	layout.SetPadding(math.ZeroSpacing)
	layout.SetMargin(math.ZeroSpacing)
	layout.SetSize(math.Size{W: 400, H: 400})

	font := theme.DefaultFont()

	label := theme.CreateLabel()
	label.SetFont(font)
	label.SetText("Overview")
	layout.AddChild(label)

	textBox := theme.CreateTextBox()
	textBox.SetFont(font)
	textBox.SetText("")
	textBox.SetDesiredWidth(800)

	button := theme.CreateButton()
	button.SetHorizontalAlignment(gxui.AlignCenter)
	button.SetText("Test")
	button.OnClick(func(gxui.MouseEvent) { test() })
	layout.AddChild(button)

	button2 := theme.CreateButton()
	button2.SetHorizontalAlignment(gxui.AlignCenter)
	button2.SetText("GetAddresses")
	button2.OnClick(func(gxui.MouseEvent) {
		balances := getAddressesString()
		textBox.SetText(balances)
	})
	layout.AddChild(button2)

	button3 := theme.CreateButton()
	button3.SetHorizontalAlignment(gxui.AlignCenter)
	button3.SetText("GetBalances")
	button3.OnClick(func(gxui.MouseEvent) {
		balances := getBalancesString()
		textBox.SetText(balances)
	})
	layout.AddChild(button3)

	layout.AddChild(textBox)

	return layout
}
Example #10
0
File: tree.go Project: langxj/gxui
func (treeControlCreator) Create(theme gxui.Theme, control gxui.Control, node *mixins.TreeToListNode) gxui.Control {
	img := theme.CreateImage()
	imgSize := math.Size{W: 10, H: 10}

	ll := theme.CreateLinearLayout()
	ll.SetDirection(gxui.LeftToRight)

	btn := theme.CreateButton()
	btn.SetBackgroundBrush(gxui.TransparentBrush)
	btn.SetBorderPen(gxui.CreatePen(1, gxui.Gray30))
	btn.SetMargin(math.Spacing{L: 1, R: 1, T: 1, B: 1})
	btn.OnClick(func(ev gxui.MouseEvent) {
		if ev.Button == gxui.MouseButtonLeft {
			node.ToggleExpanded()
		}
	})
	btn.AddChild(img)

	update := func() {
		expanded := node.IsExpanded()
		canvas := theme.Driver().CreateCanvas(imgSize)
		btn.SetVisible(!node.IsLeaf())
		switch {
		case !btn.IsMouseDown(gxui.MouseButtonLeft) && expanded:
			canvas.DrawPolygon(expandedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray70))
		case !btn.IsMouseDown(gxui.MouseButtonLeft) && !expanded:
			canvas.DrawPolygon(collapsedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray70))
		case expanded:
			canvas.DrawPolygon(expandedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray30))
		case !expanded:
			canvas.DrawPolygon(collapsedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray30))
		}
		canvas.Complete()
		img.SetCanvas(canvas)
	}
	btn.OnMouseDown(func(gxui.MouseEvent) { update() })
	btn.OnMouseUp(func(gxui.MouseEvent) { update() })
	update()

	gxui.WhileAttached(btn, node.OnChange, update)

	ll.AddChild(btn)
	ll.AddChild(control)
	ll.SetPadding(math.Spacing{L: 16 * node.Depth()})
	return ll
}
Example #11
0
func (a TreeToListAdapter) Create(theme gxui.Theme, index int) gxui.Control {
	n, i, d := a.root.FindByIndex(index)
	child := n.Child(i)
	toggle := a.createExpandButton(theme, child)
	toggle.SetVisible(!child.IsLeaf())

	child.OnExpandedChanged(func(e bool) {
		a.DataChanged()
	})

	control := n.node.Create(theme, i)

	layout := theme.CreateLinearLayout()
	layout.SetPadding(math.Spacing{L: d * 16})
	layout.SetDirection(gxui.LeftToRight)
	layout.AddChild(toggle)
	layout.AddChild(control)
	return layout
}
Example #12
0
// Create implements gxui.TreeNode.
func (n *node) Create(theme gxui.Theme) gxui.Control {
	layout := theme.CreateLinearLayout()
	layout.SetDirection(gxui.LeftToRight)

	label := theme.CreateLabel()
	label.SetText(n.name)

	textbox := theme.CreateTextBox()
	textbox.SetText(n.name)
	textbox.SetPadding(math.ZeroSpacing)
	textbox.SetMargin(math.ZeroSpacing)

	addButton := theme.CreateButton()
	addButton.SetText("+")
	addButton.OnClick(func(gxui.MouseEvent) { n.add("<new>") })

	edit := func() {
		layout.RemoveAll()
		layout.AddChild(textbox)
		layout.AddChild(addButton)
		gxui.SetFocus(textbox)
	}

	commit := func() {
		n.name = textbox.Text()
		label.SetText(n.name)
		layout.RemoveAll()
		layout.AddChild(label)
		layout.AddChild(addButton)
	}

	// When the user clicks the label, replace it with an editable text-box
	label.OnClick(func(gxui.MouseEvent) { edit() })

	// When the text-box loses focus, replace it with a label again.
	textbox.OnLostFocus(commit)

	layout.AddChild(label)
	layout.AddChild(addButton)
	return layout
}
Example #13
0
func Createwinsewa(Theme gxui.Theme, arrdata []data.Anakkost) Winsewa {
	var hasil Winsewa
	Layoutbase := Theme.CreateLinearLayout()
	layoutbutton := Theme.CreateLinearLayout()
	layoutbutton.SetDirection(gxui.LeftToRight)
	layoutjumlah := Theme.CreateLinearLayout()
	layoutjumlah.SetDirection(gxui.LeftToRight)

	hasil.Window = Theme.CreateWindow(500, 500, "SEWA")
	hasil.Daftaruianakkost = Semuabaris(Theme, arrdata)

	hasil.buttonsave = Theme.CreateButton()
	hasil.buttonsave.SetText("SAVE")
	btnjumlah := Theme.CreateButton()
	btnjumlah.SetText("JUMLAHKAN")

	labeljumlah := Theme.CreateLabel()
	labeljumlah.SetText("Jumlah:")
	labelnama := Theme.CreateLabel()
	labelnama.SetText("NAMA")
	labelsewa := Theme.CreateLabel()
	labelsewa.SetText("SEWA")
	labelcatatan := Theme.CreateLabel()
	labelcatatan.SetText("CATATAN")

	btnjumlah.OnClick(jumlahonclick)

	tbjumlah = Theme.CreateTextBox()

	var buttonsaveclick = func(e gxui.MouseEvent) {
		Save(hasil)
	}
	hasil.buttonsave.OnClick(buttonsaveclick)

	layoutjumlah.AddChild(btnjumlah)
	layoutjumlah.AddChild(labeljumlah)
	layoutjumlah.AddChild(tbjumlah)
	layoutbutton.AddChild(hasil.buttonsave)
	Layoutbase.AddChild(layoutbutton)
	Layoutbase.AddChild(layoutjumlah)

	LayoutTB := Theme.CreateTableLayout()
	numberrow := len(hasil.Daftaruianakkost) + 1
	LayoutTB.SetGrid(3, numberrow)

	LayoutTB.SetChildAt(0, 0, 1, 1, labelnama)
	LayoutTB.SetChildAt(1, 0, 1, 1, labelsewa)
	LayoutTB.SetChildAt(2, 0, 1, 1, labelcatatan)
	Layoutbase.AddChild(LayoutTB)

	for i := 0; i < len(hasil.Daftaruianakkost); i++ {
		LayoutTB.SetChildAt(0, i+1, 1, 1, hasil.Daftaruianakkost[i].TBNama)
		LayoutTB.SetChildAt(1, i+1, 1, 1, hasil.Daftaruianakkost[i].TBSewa)
		LayoutTB.SetChildAt(2, i+1, 1, 1, hasil.Daftaruianakkost[i].TBCatatan)
	}
	hasil.Window.AddChild(Layoutbase)
	return hasil
}
Example #14
0
func Createwinsetoran(Theme gxui.Theme, arrdata []data.Setoran) Winsetoran {
	var hasil Winsetoran
	hasil.Window = Theme.CreateWindow(500, 500, "SETORAN")
	layoutbase := Theme.CreateLinearLayout()
	layoutbutton := Theme.CreateLinearLayout()
	layoutbutton.SetDirection(gxui.LeftToRight)
	layoutjumlah := Theme.CreateLinearLayout()
	layoutjumlah.SetDirection(gxui.LeftToRight)

	hasil.buttonsave = Theme.CreateButton()
	hasil.buttonsave.SetText("SAVE")
	var buttonsaveclick = func(e gxui.MouseEvent) {
		Save(hasil)
	}
	hasil.buttonsave.OnClick(buttonsaveclick)

	hasil.Daftarsetoran = Semuabaris(Theme, arrdata)
	layoutbutton.AddChild(hasil.buttonsave)
	layoutbase.AddChild(layoutbutton)

	layouttabel := Theme.CreateTableLayout()
	row := len(hasil.Daftarsetoran)
	layouttabel.SetGrid(2, row+1)

	tbjumlah = Theme.CreateTextBox()
	buttonjumlah := Theme.CreateButton()
	buttonjumlah.SetText("JUMLAHKAN")
	buttonjumlah.OnClick(jumlahonclick)

	labelcatatan := Theme.CreateLabel()
	labelcatatan.SetText("CATATAN")
	labeljumlah := Theme.CreateLabel()
	labeljumlah.SetText("JUMLAH")
	labelhasiljumlah := Theme.CreateLabel()
	labelhasiljumlah.SetText("JUMLAH:")

	layoutjumlah.AddChild(buttonjumlah)
	layoutjumlah.AddChild(labelhasiljumlah)
	layoutjumlah.AddChild(tbjumlah)
	layouttabel.SetChildAt(0, 0, 1, 1, labelcatatan)
	layouttabel.SetChildAt(1, 0, 1, 1, labeljumlah)
	for i := 0; i < len(hasil.Daftarsetoran); i++ {
		layouttabel.SetChildAt(0, i+1, 1, 1, hasil.Daftarsetoran[i].TBCatatan)
		layouttabel.SetChildAt(1, i+1, 1, 1, hasil.Daftarsetoran[i].TBJumlah)
	}
	layoutbase.AddChild(layoutjumlah)
	layoutbase.AddChild(layouttabel)
	hasil.Window.AddChild(layoutbase)
	return hasil
}
Example #15
0
func Createwindashboard(theme gxui.Theme) gxui.Window {
	window := theme.CreateWindow(500, 500, "Dashboard")
	layoutdashboard := theme.CreateLinearLayout()
	layoutbutton := theme.CreateLinearLayout()
	layoutbutton.SetDirection(gxui.LeftToRight)
	layoutbutton.SetHorizontalAlignment(gxui.AlignLeft)
	layouttahun := theme.CreateLinearLayout()
	layouttahun.SetDirection(gxui.LeftToRight)
	layouttahun.SetHorizontalAlignment(gxui.AlignLeft)
	layoutbulan := theme.CreateLinearLayout()
	layoutbulan.SetDirection(gxui.LeftToRight)
	layoutbulan.SetHorizontalAlignment(gxui.AlignLeft)
	layoutsavenload := theme.CreateLinearLayout()
	layoutsavenload.SetDirection(gxui.LeftToRight)
	layoutsavenload.SetHorizontalAlignment(gxui.AlignLeft)
	layoutdir := theme.CreateLinearLayout()
	layoutdir.SetDirection(gxui.LeftToRight)
	layoutdir.SetHorizontalAlignment(gxui.AlignLeft)

	btneditsewa := theme.CreateButton()
	btneditsewa.SetText("Edit Sewa")
	btneditsewa.OnClick(Btneditsewabulananonclick)
	btneditpengeluaran := theme.CreateButton()
	btneditpengeluaran.SetText("Edit Pengeluaran")
	btneditpengeluaran.OnClick(Btneditpengeluaranonclick)
	btneditsetoran := theme.CreateButton()
	btneditsetoran.SetText("Edit Setoran")
	btneditsetoran.OnClick(Btneditsetoranonclick)
	btnsave := theme.CreateButton()
	btnsave.SetText("SAVE")
	btnload := theme.CreateButton()
	btnload.SetText("LOAD")

	btnsave.OnClick(Btnsaveonclick)
	btnload.OnClick(Btnloadonclick)

	tbtahun = theme.CreateTextBox()
	tbbulan = theme.CreateTextBox()
	tbdirectory = theme.CreateTextBox()

	labeltahun := theme.CreateLabel()
	labeltahun.SetText("TAHUN")
	labelbulan := theme.CreateLabel()
	labelbulan.SetText("BULAN")
	labeldirectory := theme.CreateLabel()
	labeldirectory.SetText("DIRECTORY")

	layoutbutton.AddChild(btneditsewa)
	layoutbutton.AddChild(btneditpengeluaran)
	layoutbutton.AddChild(btneditsetoran)
	layouttahun.AddChild(labeltahun)
	layouttahun.AddChild(tbtahun)
	layoutbulan.AddChild(labelbulan)
	layoutbulan.AddChild(tbbulan)
	layoutsavenload.AddChild(btnsave)
	layoutsavenload.AddChild(btnload)
	layoutdir.AddChild(labeldirectory)
	layoutdir.AddChild(tbdirectory)

	layoutdashboard.AddChild(layoutbutton)
	layoutdashboard.AddChild(layoutdir)
	layoutdashboard.AddChild(layouttahun)
	layoutdashboard.AddChild(layoutbulan)
	layoutdashboard.AddChild(layoutsavenload)

	window.AddChild(layoutdashboard)

	return window
}