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 (d directory) Create(theme gxui.Theme, index int) gxui.Control {
	path := d.subdirs[index]
	_, name := filepath.Split(path)

	l := theme.CreateLabel()
	l.SetText(name)
	l.SetColor(directoryColor)
	return l
}
Example #3
0
File: main.go Project: langxj/gxui
// Create implements gxui.TreeNode.
func (d directory) Create(theme gxui.Theme) gxui.Control {
	_, name := filepath.Split(d.path)
	if name == "" {
		name = d.path
	}
	l := theme.CreateLabel()
	l.SetText(name)
	l.SetColor(directoryColor)
	return l
}
Example #4
0
File: main.go Project: langxj/gxui
func (a *filesAdapter) Create(theme gxui.Theme, index int) gxui.Control {
	path := a.files[index]
	_, name := filepath.Split(path)
	label := theme.CreateLabel()
	label.SetText(name)
	if fi, err := os.Stat(path); err == nil && fi.IsDir() {
		label.SetColor(directoryColor)
	} else {
		label.SetColor(fileColor)
	}
	return label
}
Example #5
0
// Create a PanelHolder with a 3 panels
func panelHolder(name string, theme gxui.Theme) gxui.PanelHolder {
	label := func(text string) gxui.Label {
		label := theme.CreateLabel()
		label.SetText(text)
		return label
	}

	holder := theme.CreatePanelHolder()
	holder.AddPanel(label(name+" 0 content"), name+" 0 panel")
	holder.AddPanel(label(name+" 1 content"), name+" 1 panel")
	holder.AddPanel(label(name+" 2 content"), name+" 2 panel")
	return holder
}
Example #6
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 #7
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 #8
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 #9
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 #10
0
// Create a PanelHolder with a 3 panels
func panelHolder(name string, theme gxui.Theme) gxui.PanelHolder {
	label := func(text string) gxui.Label {
		label := theme.CreateLabel()
		label.SetText(text)
		return label
	}

	holder := theme.CreatePanelHolder()
	holder.AddPanel(label(name+" Tout"), name+" Tous mes fichiers")
	holder.AddPanel(label(name+" Cours"), name+" Mes cours")
	holder.AddPanel(label(name+" Musique"), name+" Ma musique")
	holder.AddPanel(label(name+" Photos"), name+" Mes photos")
	holder.AddPanel(label(name+" Vidéos"), name+" Mes vidéos")
	return holder
}
Example #11
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 #12
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
}
// CreateIcon is create icon control
func CreateIcon(theme gxui.Theme, icon rune, size int) gxui.Label {
	if theme == nil || size < 0 {
		return nil
	}
	control := theme.CreateLabel()
	font, ok := MaterialIconFonts[size]
	if !ok {
		var err error
		font, err = theme.Driver().CreateFont(MaterialIcon, size)
		if err != nil {
			return nil
		}
		MaterialIconFonts[size] = font
	}
	control.SetFont(font)
	control.SetText(string(icon))
	return control
}
Example #14
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 #15
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 #16
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 #17
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
}
Example #18
0
func (n node) Create(theme gxui.Theme, index int) gxui.Control {
	label := theme.CreateLabel()
	label.SetText(n.children[index].name)
	return label
}
Example #19
0
File: main.go Project: langxj/gxui
// Override directory.Create so that the full root is shown, unaltered.
func (a directoryAdapter) Create(theme gxui.Theme, index int) gxui.Control {
	l := theme.CreateLabel()
	l.SetText(a.subdirs[index])
	l.SetColor(directoryColor)
	return l
}
Example #20
0
func makeResultText(theme gxui.Theme) gxui.Label {
	label := theme.CreateLabel()
	label.SetText("This is result label.")
	return label

}