当前位置: 首页>>代码示例>>Golang>>正文


Golang Widget.SetProperty方法代码示例

本文整理汇总了Golang中github.com/js-arias/sparta.Widget.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:Golang Widget.SetProperty方法的具体用法?Golang Widget.SetProperty怎么用?Golang Widget.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/js-arias/sparta.Widget的用法示例。


在下文中一共展示了Widget.SetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: trViewInitList

func trViewInitList(m, tv sparta.Widget) {
	l, err := localDB.List(jdh.Trees, new(jdh.Values))
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", cmd.ErrStr(err))
		return
	}
	data := &trList{}
	for {
		phy := &jdh.Phylogeny{}
		if err := l.Scan(phy); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", cmd.ErrStr(err))
			return
		}
		if (len(phy.Id) == 0) || (len(phy.Root) == 0) {
			continue
		}
		data.phyLs = append(data.phyLs, phy)
	}
	if len(data.phyLs) == 0 {
		return
	}
	m.SetProperty(sparta.Data, data)
	trViewInitTree(m, tv)
}
开发者ID:js-arias,项目名称:jdh,代码行数:27,代码来源:tr.view.go

示例2: txEdInitList

func txEdInitList(m, l sparta.Widget, data *txList, i int, syns bool) {
	if data == nil {
		data = newTxList(nil, localDB, syns)
	} else {
		d := newTxList(data.desc[i], data.db, syns)
		if len(d.desc) == 0 {
			if l.Property(sparta.Name).(string) == "validList" {
				data.sels = []int{i}
			} else {
				sel := false
				for _, s := range data.sels {
					if s == i {
						sel = true
						break
					}
				}
				if !sel {
					data.sels = append(data.sels, i)
				}
			}
		} else {
			data = d
		}
	}
	if l.Property(sparta.Name).(string) == "taxonList" {
		m.SetProperty(sparta.Data, data)
	}
	l.SetProperty(widget.ListList, data)
}
开发者ID:js-arias,项目名称:jdh,代码行数:29,代码来源:tx.ed.go

示例3: trViewMouse

func trViewMouse(tv sparta.Widget, e interface{}) bool {
	dt := tv.Property(sparta.Data)
	if dt == nil {
		return true
	}
	data := dt.(*trData)
	ev := e.(sparta.MouseEvent)
	switch ev.Button {
	case sparta.MouseRight:
		if !setFlag {
			return true
		}
		if data.sel == nil {
			return true
		}
		sel := trViewNearestNode(ev.Loc, data.node)
		if sel == nil {
			return true
		}
		x, y, pos := data.x, data.y, data.pos
		p := tv.Property(sparta.Parent).(sparta.Widget)
		d := p.Property(sparta.Data).(*trList)
		if sel == data.sel {
			vals := new(jdh.Values)
			vals.Add(jdh.NodCollapse, sel.id)
			localDB.Exec(jdh.Delete, jdh.Nodes, vals)
			localDB.Exec(jdh.Commit, "", nil)
		} else if !sel.isValidSis(data.sel) {
			return true
		} else {
			vals := new(jdh.Values)
			vals.Add(jdh.KeyId, data.sel.id)
			vals.Add(jdh.NodSister, sel.id)
			localDB.Exec(jdh.Set, jdh.Nodes, vals)
			localDB.Exec(jdh.Commit, "", nil)
		}
		rect := tv.Property(sparta.Geometry).(image.Rectangle)
		data = setTree(d.phyLs[d.pos], rect)
		data.x, data.y, data.pos = x, y, pos
		tv.SetProperty(sparta.Data, data)
		data.putOnScreen()
		tv.Update()
	case sparta.MouseLeft:
		data.sel = trViewNearestNode(ev.Loc, data.node)
		tv.Update()
	case -sparta.MouseWheel:
		data.pos.Y -= 5
		data.putOnScreen()
		tv.Update()
	case sparta.MouseWheel:
		data.pos.Y += 5
		data.putOnScreen()
		tv.Update()
	}
	return true
}
开发者ID:js-arias,项目名称:jdh,代码行数:56,代码来源:tr.view.go

示例4: txEdSetCaption

func txEdSetCaption(m sparta.Widget) {
	d := m.Property(sparta.Data)
	if d == nil {
		m.SetProperty(sparta.Caption, "no data")
		return
	}
	dt := d.(*txList)
	title := fmt.Sprintf("%s: %s [id: %s]", cmd.Name, dt.tax.Name, dt.tax.Id)
	m.SetProperty(sparta.Caption, title)
}
开发者ID:js-arias,项目名称:jdh,代码行数:10,代码来源:tx.ed.go

示例5: txNavComm

func txNavComm(m sparta.Widget, e interface{}) bool {
	d := m.Property(sparta.Data)
	if d == nil {
		return true
	}
	data := d.(*txList)
	ev := e.(sparta.CommandEvent)
	switch ev.Source.Property(sparta.Name).(string) {
	case "taxonList":
		if ev.Value < 0 {
			i := -ev.Value - 1
			if i >= len(data.desc) {
				break
			}
			title := fmt.Sprintf("%s: please wait", cmd.Name)
			m.SetProperty(sparta.Caption, title)
			ev.Source.SetProperty(widget.ListList, nil)
			tx := wnd["info"]
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			sparta.Block(nil)
			go txNavInitList(m, ev.Source, data.db, data, i)
			break
		}
		if data.IsSel(ev.Value) {
			data.sels = nil
		} else {
			data.sels = []int{ev.Value}
		}
		tx := wnd["info"]
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		ev.Source.Update()
		sparta.Block(nil)
		go func() {
			txNavInfo(tx, data)
			sparta.Unblock(nil)
		}()
	case "upTax":
		if data.tax.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		l := wnd["taxonList"]
		l.SetProperty(widget.ListList, nil)
		tx := wnd["info"]
		tx.SetProperty(sparta.Data, nil)
		sparta.Block(nil)
		go txNavAncList(m, l, data.db, data.tax)
	}
	return true
}
开发者ID:js-arias,项目名称:jdh,代码行数:53,代码来源:tx.nav.go

示例6: trViewInitTree

func trViewInitTree(m, tv sparta.Widget) {
	d := m.Property(sparta.Data).(*trList)
	if d.pos >= len(d.phyLs) {
		return
	}
	title := fmt.Sprintf("%s: %s [id: %s]", cmd.Name, d.phyLs[d.pos].Name, d.phyLs[d.pos].Id)
	m.SetProperty(sparta.Caption, title)
	rect := tv.Property(sparta.Geometry).(image.Rectangle)
	curTree := setTree(d.phyLs[d.pos], rect)
	curTree.putOnScreen()
	tv.SetProperty(sparta.Data, curTree)
	tv.Update()
}
开发者ID:js-arias,项目名称:jdh,代码行数:13,代码来源:tr.view.go

示例7: txNavInfo

func txNavInfo(tx sparta.Widget, data *txList) {
	if len(data.sels) == 0 {
		tx.SetProperty(sparta.Data, nil)
	} else {
		pair := &txTaxAnc{
			tax: data.desc[data.sels[0]],
			anc: data.tax,
		}
		if data.tax.Id == "0" {
			pair.anc = nil
		}
		tx.SetProperty(sparta.Data, pair)
	}
	tx.Update()
}
开发者ID:js-arias,项目名称:jdh,代码行数:15,代码来源:tx.nav.go

示例8: txEdUpdateList

func txEdUpdateList(m, l sparta.Widget, data *txList, syns bool) {
	if data == nil {
		data = newTxList(nil, localDB, syns)
	} else {
		d := newTxList(data.tax, data.db, syns)
		if len(d.desc) == 0 {
			txEdAncList(m, l, data.tax, syns)
			return
		}
		data = d
	}
	if l.Property(sparta.Name).(string) == "taxonList" {
		m.SetProperty(sparta.Data, data)
	}
	l.SetProperty(widget.ListList, data)
}
开发者ID:js-arias,项目名称:jdh,代码行数:16,代码来源:tx.ed.go

示例9: txEdAncList

func txEdAncList(m, l sparta.Widget, tax *jdh.Taxon, syns bool) {
	var p *jdh.Taxon
	if len(tax.Parent) > 0 {
		p = taxon(cmd, localDB, tax.Parent)
		if len(p.Id) == 0 {
			p = nil
		}
	}
	data := newTxList(p, localDB, syns)
	for i, d := range data.desc {
		if d.Id == tax.Id {
			data.sels = []int{i}
			break
		}
	}
	if l.Property(sparta.Name).(string) == "taxonList" {
		m.SetProperty(sparta.Data, data)
	}
	l.SetProperty(widget.ListList, data)
}
开发者ID:js-arias,项目名称:jdh,代码行数:20,代码来源:tx.ed.go

示例10: spNavInitTaxList

func spNavInitTaxList(m, l sparta.Widget, db jdh.DB, data *txList, i int) {
	if data == nil {
		data = newTxList(nil, db, true)
	} else {
		d := newTxList(data.desc[i], data.db, true)
		if len(d.desc) == 0 {
			data.sels = []int{i}
		} else {
			data = d
		}
	}
	title := fmt.Sprintf("%s: %s [id: %s]", cmd.Name, data.tax.Name, data.tax.Id)
	m.SetProperty(sparta.Caption, title)
	m.SetProperty(sparta.Data, data)
	l.SetProperty(widget.ListList, data)
}
开发者ID:js-arias,项目名称:jdh,代码行数:16,代码来源:sp.nav.go

示例11: spNavAncList

func spNavAncList(m, l sparta.Widget, db jdh.DB, tax *jdh.Taxon) {
	var p *jdh.Taxon
	if len(tax.Parent) > 0 {
		p = taxon(cmd, db, tax.Parent)
		if len(p.Id) == 0 {
			p = nil
		}
	}
	data := newTxList(p, db, true)
	title := fmt.Sprintf("%s: %s [id: %s]", cmd.Name, data.tax.Name, data.tax.Id)
	m.SetProperty(sparta.Caption, title)
	m.SetProperty(sparta.Data, data)
	for i, d := range data.desc {
		if d.Id == tax.Id {
			data.sels = []int{i}
			break
		}
	}
	l.SetProperty(widget.ListList, data)
}
开发者ID:js-arias,项目名称:jdh,代码行数:20,代码来源:sp.nav.go

示例12: spNavInfo

func spNavInfo(tx sparta.Widget, db jdh.DB, spe *jdh.Specimen, tax *jdh.Taxon) {
	if spe == nil {
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		return
	}
	if spe.Taxon != tax.Id {
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		return
	}
	info := &spInfo{
		tax: tax,
		spe: spe,
	}
	if len(spe.Dataset) > 0 {
		info.set = dataset(cmd, db, spe.Dataset)
	}
	tx.SetProperty(sparta.Data, info)
	tx.Update()
}
开发者ID:js-arias,项目名称:jdh,代码行数:21,代码来源:sp.nav.go

示例13: txEdComm

func txEdComm(m sparta.Widget, e interface{}) bool {
	ev := e.(sparta.CommandEvent)
	switch ev.Source.Property(sparta.Name).(string) {
	case "move":
		frWg := wnd["taxonList"]
		d := frWg.Property(widget.ListList)
		if d == nil {
			break
		}
		frLs := d.(*txList)
		if (len(frLs.sels) == 0) && (frLs.tax.Id == "0") {
			break
		}
		toWg := wnd["validList"]
		d = toWg.Property(widget.ListList)
		if d == nil {
			break
		}
		toLs := d.(*txList)
		var to *jdh.Taxon
		if len(toLs.sels) == 0 {
			to = toLs.tax
		} else {
			to = toLs.desc[toLs.sels[0]]
		}
		if (len(frLs.sels) == 0) && (frLs.tax.Id == to.Id) {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		frWg.SetProperty(widget.ListList, nil)
		toWg.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			if len(frLs.sels) == 0 {
				txEdMove(frLs.tax, to)
			} else {
				for _, s := range frLs.sels {
					from := frLs.desc[s]
					txEdMove(from, to)
				}
			}
			localDB.Exec(jdh.Commit, "", nil)
			txEdUpdateList(m, frWg, frLs, true)
			txEdUpdateList(m, toWg, toLs, false)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "syn":
		frWg := wnd["taxonList"]
		d := frWg.Property(widget.ListList)
		if d == nil {
			break
		}
		frLs := d.(*txList)
		if (len(frLs.sels) == 0) && (frLs.tax.Id == "0") {
			break
		}
		toWg := wnd["validList"]
		d = toWg.Property(widget.ListList)
		if d == nil {
			break
		}
		toLs := d.(*txList)
		var to *jdh.Taxon
		if len(toLs.sels) == 0 {
			to = toLs.tax
		} else {
			to = toLs.desc[toLs.sels[0]]
		}
		if to.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		frWg.SetProperty(widget.ListList, nil)
		toWg.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			if len(frLs.sels) == 0 {
				txEdSyn(frLs.tax, to)
			} else {
				for _, s := range frLs.sels {
					from := frLs.desc[s]
					txEdSyn(from, to)
				}
			}
			localDB.Exec(jdh.Commit, "", nil)
			txEdUpdateList(m, frWg, frLs, true)
			txEdUpdateList(m, toWg, toLs, false)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "taxonList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if ev.Value < 0 {
//.........这里部分代码省略.........
开发者ID:js-arias,项目名称:jdh,代码行数:101,代码来源:tx.ed.go

示例14: trViewKey

func trViewKey(tv sparta.Widget, e interface{}) bool {
	dt := tv.Property(sparta.Data)
	if dt == nil {
		return true
	}
	data := dt.(*trData)
	rect := tv.Property(sparta.Geometry).(image.Rectangle)
	ev := e.(sparta.KeyEvent)
	switch ev.Key {
	case sparta.KeyDown:
		data.pos.Y -= 5
	case sparta.KeyUp:
		data.pos.Y += 5
	case sparta.KeyLeft:
		data.pos.X -= 5
	case sparta.KeyRight:
		data.pos.X += 5
	case sparta.KeyHome:
		data.pos = image.Pt(0, 0)
	case sparta.KeyPageUp:
		data.pos.Y += rect.Dy() - sparta.HeightUnit
	case sparta.KeyPageDown:
		data.pos.Y -= rect.Dy() - sparta.HeightUnit
	case ' ', sparta.KeyReturn:
		p := tv.Property(sparta.Parent).(sparta.Widget)
		d := p.Property(sparta.Data).(*trList)
		if (d.pos + 1) >= len(d.phyLs) {
			return false
		}
		d.pos++
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		p.SetProperty(sparta.Caption, title)
		tv.SetProperty(sparta.Data, nil)
		go trViewInitTree(p, tv)
	case sparta.KeyBackSpace:
		p := tv.Property(sparta.Parent).(sparta.Widget)
		d := p.Property(sparta.Data).(*trList)
		if (d.pos - 1) < 0 {
			return false
		}
		d.pos--
		tv.SetProperty(sparta.Data, nil)
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		p.SetProperty(sparta.Caption, title)
		go trViewInitTree(p, tv)
	case '+':
		data.y = data.y * 5 / 4
	case '-':
		data.y = data.y * 4 / 5
	case '*':
		data.x = data.x * 5 / 4
	case '/':
		data.x = data.x * 4 / 5
	case '#':
		root := data.node[0]
		data.y = float32(rect.Dy()-10) / float32(root.terms+2)
		data.x = float32(rect.Dx()-10-(sparta.WidthUnit*32)) / float32(root.level)
	case '=':
		data.y = float32(sparta.HeightUnit)
		data.x = float32(sparta.WidthUnit * 2)
	case '>':
		if !data.aln {
			return false
		}
		data.aln = false
	case '<':
		if data.aln {
			return false
		}
		data.aln = true
	default:
		return true
	}
	data.putOnScreen()
	tv.Update()
	return false
}
开发者ID:js-arias,项目名称:jdh,代码行数:77,代码来源:tr.view.go

示例15: spNavComm

func spNavComm(m sparta.Widget, e interface{}) bool {
	ev := e.(sparta.CommandEvent)
	switch ev.Source.Property(sparta.Name).(string) {
	case "speList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*spList)
		i := ev.Value
		if ev.Value < 0 {
			i = -ev.Value - 1
		}
		tx := wnd["info"]
		if data.IsSel(i) {
			data.sel = -1
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			ev.Source.Update()
			break
		}
		data.sel = i
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		ev.Source.Update()
		sparta.Block(nil)
		go func() {
			spNavInfo(tx, data.db, data.spe[i], data.tax)
			sparta.Unblock(nil)
		}()
	case "taxonList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		s := wnd["speList"]
		tx := wnd["info"]
		if ev.Value < 0 {
			i := -ev.Value - 1
			if i >= len(data.desc) {
				break
			}
			title := fmt.Sprintf("%s: please wait", cmd.Name)
			m.SetProperty(sparta.Caption, title)
			ev.Source.SetProperty(widget.ListList, nil)
			s.SetProperty(widget.ListList, nil)
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			sparta.Block(nil)
			go func() {
				spNavInitTaxList(m, ev.Source, data.db, data, i)
				sparta.Unblock(nil)
			}()
			break
		}
		if data.IsSel(ev.Value) {
			data.sels = nil
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			s.SetProperty(widget.ListList, nil)
		} else {
			data.sels = []int{ev.Value}
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			sparta.Block(nil)
			go func() {
				spNavInitSpeList(m, s)
				sparta.Unblock(nil)
			}()
		}
		ev.Source.Update()
	case "upTax":
		l := wnd["taxonList"]
		s := wnd["speList"]
		tx := wnd["info"]
		d := l.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if data.tax.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		l.SetProperty(widget.ListList, nil)
		s.SetProperty(widget.ListList, nil)
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		sparta.Block(nil)
		go func() {
			spNavAncList(m, l, data.db, data.tax)
			spNavInitSpeList(m, s)
			sparta.Unblock(nil)
		}()
	}
	return true
}
开发者ID:js-arias,项目名称:jdh,代码行数:99,代码来源:sp.nav.go


注:本文中的github.com/js-arias/sparta.Widget.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。