예제 #1
0
파일: tree.go 프로젝트: linux-mac/gxui
func (t *Tree) CreateExpandButton(theme gxui.Theme, node *TreeInternalNode) gxui.Button {
	btn := theme.CreateButton()
	btn.SetMargin(math.Spacing{L: 2, R: 2, T: 1, B: 1})
	btn.OnClick(func(ev gxui.MouseEvent) {
		if ev.Button == gxui.MouseButtonLeft {
			if node.IsExpanded() {
				node.Collapse()
			} else {
				node.Expand()
			}
		}
	})
	node.OnExpandedChanged(func(e bool) {
		if e {
			btn.SetText("-")
		} else {
			btn.SetText("+")
		}
	})
	if node.IsExpanded() {
		btn.SetText("-")
	} else {
		btn.SetText("+")
	}
	return btn
}
예제 #2
0
파일: tree.go 프로젝트: henrylee2cn/gxui
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
}
예제 #3
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
}
예제 #4
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
}
예제 #5
0
파일: tree.go 프로젝트: 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
}
예제 #6
0
파일: main.go 프로젝트: nulijiabei/gxui
// 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
}
예제 #7
0
파일: tree.go 프로젝트: linux-mac/gxui
func (t *Tree) CreateExpandButton(theme gxui.Theme, node *mixins.TreeInternalNode) gxui.Button {
	img := theme.CreateImage()
	imgSize := math.Size{W: 10, H: 10}

	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 {
			if node.IsExpanded() {
				node.Collapse()
			} else {
				node.Expand()
			}
		}
	})
	btn.AddChild(img)

	updateStyle := func() {
		canvas := theme.Driver().CreateCanvas(imgSize)
		switch {
		case !btn.IsMouseDown(gxui.MouseButtonLeft) && node.IsExpanded():
			canvas.DrawPolygon(expandedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray70))
		case !btn.IsMouseDown(gxui.MouseButtonLeft) && !node.IsExpanded():
			canvas.DrawPolygon(collapsedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray70))
		case node.IsExpanded():
			canvas.DrawPolygon(expandedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray30))
		case !node.IsExpanded():
			canvas.DrawPolygon(collapsedPoly, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray30))
		}
		canvas.Complete()
		img.SetCanvas(canvas)
	}
	btn.OnMouseDown(func(gxui.MouseEvent) { updateStyle() })
	btn.OnMouseUp(func(gxui.MouseEvent) { updateStyle() })
	node.OnExpandedChanged(func(e bool) { updateStyle() })
	updateStyle()
	return btn
}
예제 #8
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
}
예제 #9
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
}