本文整理汇总了Golang中github.com/ArchRobison/Gophetica/nimble.PixMap.DrawText方法的典型用法代码示例。如果您正苦于以下问题:Golang PixMap.DrawText方法的具体用法?Golang PixMap.DrawText怎么用?Golang PixMap.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ArchRobison/Gophetica/nimble.PixMap
的用法示例。
在下文中一共展示了PixMap.DrawText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Draw
// Draw draws the menu with its upper left corner at (x,y)
func (m *Menu) Draw(pm nimble.PixMap, x, y int32) {
// Draw the tab
if m.tabWidth == 0 {
// Lazily compute tabWidth and itemHeight
m.computeTabSize()
}
var back, fore nimble.Pixel
if m.hilightRow != showNone {
back = tabHilightColor
fore = backgroundColor
} else {
back = backgroundColor
fore = foregroundColor
}
m.tabRect = nimble.MakeRect(x, y, 2*marginWidth+int32(m.tabWidth), int32(m.itemHeight))
pm.DrawRect(m.tabRect, back)
pm.DrawText(x+marginWidth, y, m.Label, fore, menuFont)
pm.DrawRect(nimble.Rect{Left: m.tabRect.Left, Top: m.tabRect.Bottom, Right: m.tabRect.Right, Bottom: m.tabRect.Bottom + 1}, separatorColor)
if m.hilightRow != showNone {
if m.itemWidth == 0 {
// Lazily compute itemsWidth
w := int32(m.tabWidth)
for i := range m.Items {
p := m.Items[i].GetItem()
w0, _ := menuFont.Size(p.Label)
if w0 > w {
w = w0
}
}
m.itemWidth = uint16(checkWidth + w + 3 + 4*marginWidth)
}
w := int32(m.itemWidth)
h := int32(m.itemHeight)
m.itemsRect = nimble.MakeRect(x, m.tabRect.Bottom, w, h*int32(len(m.Items)))
r := m.itemsRect
r.Left += 1
r.Right -= 1
pm.DrawRect(r, backgroundColor)
// Draw left border
r.Left -= 1
r.Right = r.Left + 1
pm.DrawRect(r, separatorColor)
// Draw middle border
r.Left += 1 + checkWidth + 2*marginWidth
r.Right = r.Left + 1
pm.DrawRect(r, separatorColor)
// Draw right border
r.Left = m.itemsRect.Right - 1
r.Right = r.Left + 1
pm.DrawRect(r, separatorColor)
// Draw the items
checkX := x + 1 + marginWidth
labelX := x + 2 + 3*marginWidth + checkWidth
for i := range m.Items {
mi := m.Items[i].GetItem()
yi := m.itemsRect.Top + h*int32(i)
if i == int(m.hilightRow-hilightBase) {
pm.DrawRect(nimble.MakeRect(x, yi, int32(m.itemWidth), h), itemHilightColor)
}
if i == 0 {
pm.DrawRect(nimble.Rect{x, yi, m.itemsRect.Right - 1, yi + 1}, separatorColor)
} else if mi.Flags&Separator != 0 || i == 0 {
pm.DrawRect(nimble.Rect{labelX - marginWidth, yi, m.itemsRect.Right - 1, yi + 1}, separatorColor)
}
fore := choose(mi.Flags&Disabled != 0, disabledForegroundColor, foregroundColor)
if mi.Check != 0 {
pm.DrawText(checkX, yi, string(mi.Check), fore, checkFont)
}
pm.DrawText(labelX, yi, mi.Label, fore, menuFont)
}
}
}