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


Golang Widget.Property方法代码示例

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


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

示例1: trViewExpose

func trViewExpose(tv sparta.Widget, e interface{}) bool {
	dt := tv.Property(sparta.Data)
	if dt == nil {
		return false
	}
	data := dt.(*trData)
	draw := tv.(*widget.Canvas)
	for _, n := range data.node {
		draw.Draw(n.ancLine)
		if n.level > 0 {
			draw.Draw(n.descLine)
		} else if len(n.name.Text) > 0 {
			draw.Draw(n.name)
		}
	}
	if n := data.sel; n != nil {
		rect := widget.Rectangle{
			Rect: image.Rect(n.pos.X-3, n.pos.Y-3, n.pos.X+3, n.pos.Y+3),
		}
		draw.Draw(rect)
		rect.Rect = image.Rect(n.pos.X-2, n.pos.Y-2, n.pos.X+2, n.pos.Y+2)
		rect.Fill = true
		draw.SetColor(sparta.Foreground, color.RGBA{G: 255})
		draw.Draw(rect)
	}
	return false
}
开发者ID:js-arias,项目名称:jdh,代码行数:27,代码来源:tr.view.go

示例2: txKey

// TxKey gets keyboard events.
func txKey(tx sparta.Widget, e interface{}) bool {
	data := tx.Property(sparta.Data).(*pageData)
	ev := e.(sparta.KeyEvent)
	switch ev.Key {
	case sparta.KeyDown:
		if (data.pos + 1) < (len(poem) - data.page + 1) {
			data.pos++
		}
		tx.Update()
	case sparta.KeyUp:
		if (data.pos - 1) >= 0 {
			data.pos--
		}
		tx.Update()
	case sparta.KeyPageUp:
		if data.pos == 0 {
			break
		}
		data.pos -= data.page
		if data.pos < 0 {
			data.pos = 0
		}
		tx.Update()
	case sparta.KeyPageDown:
		if data.pos == (len(poem) - data.page) {
			break
		}
		data.pos += data.page
		if data.pos > (len(poem) - data.page + 1) {
			data.pos = len(poem) - data.page
		}
		tx.Update()
	}
	return true
}
开发者ID:js-arias,项目名称:sparta,代码行数:36,代码来源:03canvas.go

示例3: pgExpose

// pgExpose draws the polygons.
func pgExpose(pg sparta.Widget, e interface{}) bool {
	data := pg.Property(sparta.Data).([]widget.Polygon)
	c := pg.(*widget.Canvas)
	c.Draw(data[0])
	c.Draw(data[1])
	return false
}
开发者ID:js-arias,项目名称:sparta,代码行数:8,代码来源:03canvas.go

示例4: 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

示例5: txNavInfoExpose

func txNavInfoExpose(tx sparta.Widget, e interface{}) bool {
	d := tx.Property(sparta.Data)
	if d == nil {
		return false
	}
	data := d.(*txTaxAnc)
	c := tx.(*widget.Canvas)
	txt := widget.Text{}
	txt.Pos.X = 2
	txt.Pos.Y = 2
	txt.Text = "Id: " + data.tax.Id
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = data.tax.Name
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = data.tax.Authority
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	txt.Text = data.tax.Rank.String()
	c.Draw(txt)
	txt.Pos.Y += sparta.HeightUnit
	if data.tax.IsValid {
		txt.Text = "Valid"
		c.Draw(txt)
		if data.anc != nil {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "Parent: " + data.anc.Name
			c.Draw(txt)

		}
	} else {
		txt.Text = "Synonym of " + data.anc.Name
		c.Draw(txt)

	}
	if len(data.tax.Extern) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Extern ids:"
		c.Draw(txt)
		for _, e := range data.tax.Extern {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "    " + e
			c.Draw(txt)
		}
	}
	if len(data.tax.Comment) > 0 {
		txt.Pos.Y += sparta.HeightUnit
		txt.Text = "Comments:"
		c.Draw(txt)
		cmt := strings.Split(data.tax.Comment, "\n")
		for _, e := range cmt {
			txt.Pos.Y += sparta.HeightUnit
			txt.Text = "  " + e
			c.Draw(txt)
		}
	}
	return false
}
开发者ID:js-arias,项目名称:jdh,代码行数:59,代码来源:tx.nav.go

示例6: snConf

// SnConf sets the new values of the sine function points
func snConf(sn sparta.Widget, e interface{}) bool {
	ev := e.(sparta.ConfigureEvent)

	// Get data from the widget.
	data := sn.Property(sparta.Data).([]image.Point)
	sine(data, ev.Rect.Dx(), ev.Rect.Dy())
	return false
}
开发者ID:js-arias,项目名称:sparta,代码行数:9,代码来源:03canvas.go

示例7: 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

示例8: 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

示例9: 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

示例10: propagateWheel

func propagateWheel(w sparta.Widget, pt image.Point) sparta.Widget {
	rect := w.Property(sparta.Geometry).(image.Rectangle)
	childs := w.Property(sparta.Childs)
	if childs == nil {
		return w
	}
	for _, ch := range childs.([]sparta.Widget) {
		rect = ch.Property(sparta.Geometry).(image.Rectangle)
		if pt.In(rect) {
			return propagateWheel(ch, pt.Add(rect.Min))
		}
	}
	return w
}
开发者ID:js-arias,项目名称:sparta,代码行数:14,代码来源:run.go

示例11: obExpose

// ObExpose draws the objects.
func obExpose(ob sparta.Widget, e interface{}) bool {
	data := ob.Property(sparta.Data).(*objData)
	c := ob.(*widget.Canvas)
	// Set color sets a color temporalely for the following dawing
	// operations. Contrast this with the property sparta.Background
	// and sparta.Foreground.
	c.SetColor(sparta.Foreground, color.RGBA{255, 0, 0, 0})
	c.Draw(widget.Rectangle{Rect: data.arc.Rect})
	c.SetColor(sparta.Foreground, color.RGBA{0, 255, 0, 0})
	c.Draw(data.l1)
	c.Draw(data.l2)
	c.SetColor(sparta.Foreground, color.RGBA{0, 0, 255, 0})
	c.Draw(data.arc)
	return false
}
开发者ID:js-arias,项目名称:sparta,代码行数:16,代码来源:03canvas.go

示例12: newWindow

// NewWindow creates a new window and assigns it to a widget.
func newWindow(w sparta.Widget) {
	var win *window
	rect := w.Property(sparta.Geometry).(image.Rectangle)
	if p := w.Property(sparta.Parent); p != nil {
		pW := p.(sparta.Widget)
		pWin := pW.Window().(*window)
		win = &window{
			w:    w,
			back: pWin.back,
			fore: pWin.fore,
			pos:  rect.Min,
		}
		count := len(pW.Property(sparta.Childs).([]sparta.Widget))
		pW.SetProperty(sparta.Childs, w)
		win.id = w32.CreateWindowEx(0, stringToUTF16(childClass), nil,
			uint(w32.WS_CHILDWINDOW|w32.WS_VISIBLE),
			rect.Min.X, rect.Min.Y, rect.Dx(), rect.Dy(),
			pWin.id, w32.HMENU(count),
			w32.HINSTANCE(w32.GetWindowLong(pWin.id, w32.GWL_HINSTANCE)), nil)
		if win.id == 0 {
			log.Printf("w32: error: %v\n", getLastError())
			os.Exit(1)
		}
	} else {
		win = &window{
			w:    w,
			back: bkGround,
			fore: frGround,
		}
		win.id = w32.CreateWindowEx(uint(w32.WS_EX_CLIENTEDGE),
			stringToUTF16(baseClass), stringToUTF16(""),
			uint(w32.WS_OVERLAPPEDWINDOW),
			150, 150, rect.Dx()+extraX, rect.Dy()+extraY,
			0, 0, instance, nil)
		if win.id == 0 {
			log.Printf("w32: error: %v\n", getLastError())
			os.Exit(1)
		}
	}
	widgetTable[win.id] = w
	w.SetWindow(win)

	w32.ShowWindow(win.id, w32.SW_SHOWDEFAULT)
	if !w32.UpdateWindow(win.id) {
		log.Printf("w32: error: %v\n", getLastError())
		os.Exit(1)
	}
}
开发者ID:js-arias,项目名称:sparta,代码行数:49,代码来源:window.go

示例13: 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

示例14: snExpose

// SnExpose draw the sine function.
func snExpose(sn sparta.Widget, e interface{}) bool {
	// get point data.
	data := sn.Property(sparta.Data).([]image.Point)
	// get widget geometry
	geo := sn.Property(sparta.Geometry).(image.Rectangle)

	c := sn.(*widget.Canvas)
	// The widget canvas ruses the function Draw to draw particular
	// objects, it depends on the data type to decide what to draw.
	// Here a line (the "x" axis), is draw.
	c.Draw([]image.Point{image.Pt(0, geo.Dy()/2), image.Pt(geo.Dx(), geo.Dy()/2)})
	// Then the sine function is draw.
	c.Draw(data)

	return false
}
开发者ID:js-arias,项目名称:sparta,代码行数:17,代码来源:03canvas.go

示例15: spNavInitSpeList

func spNavInitSpeList(m, s sparta.Widget) {
	d := m.Property(sparta.Data)
	l := wnd["speList"]
	if d == nil {
		l.SetProperty(widget.ListList, nil)
		return
	}
	data := d.(*txList)
	if len(data.sels) == 0 {
		l.SetProperty(widget.ListList, nil)
		return
	}
	tax := data.desc[data.sels[0]]
	ls := newSpList(tax, data.db)
	l.SetProperty(widget.ListList, ls)
}
开发者ID:js-arias,项目名称:jdh,代码行数:16,代码来源:sp.nav.go


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