本文整理匯總了Golang中github.com/nelsam/gxui.Theme.CreateList方法的典型用法代碼示例。如果您正苦於以下問題:Golang Theme.CreateList方法的具體用法?Golang Theme.CreateList怎麽用?Golang Theme.CreateList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui.Theme
的用法示例。
在下文中一共展示了Theme.CreateList方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func (l *DropDownList) Init(outer DropDownListOuter, theme gxui.Theme) {
l.outer = outer
l.Container.Init(outer, theme)
l.BackgroundBorderPainter.Init(outer)
l.Focusable.Init(outer)
l.theme = theme
l.list = theme.CreateList()
l.list.OnSelectionChanged(func(item gxui.AdapterItem) {
l.outer.RemoveAll()
adapter := l.list.Adapter()
if item != nil && adapter != nil {
l.selected = l.AddChild(adapter.Create(l.theme, adapter.ItemIndex(item)))
} else {
l.selected = nil
}
l.Relayout()
})
l.list.OnItemClicked(func(gxui.MouseEvent, gxui.AdapterItem) {
l.HideList()
})
l.list.OnKeyPress(func(ev gxui.KeyboardEvent) {
switch ev.Key {
case gxui.KeyEnter, gxui.KeyEscape:
l.HideList()
}
})
l.list.OnLostFocus(l.HideList)
l.OnDetach(l.HideList)
l.SetMouseEventTarget(true)
// Interface compliance test
_ = gxui.DropDownList(l)
}
示例2: colorPicker
// 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
}
示例3: NewProjectsPane
func NewProjectsPane(driver gxui.Driver, theme gxui.Theme, projFrame gxui.Control) *Projects {
pane := &Projects{
theme: theme,
projectFrame: projFrame,
button: createIconButton(driver, theme, "projects.png"),
projects: theme.CreateList(),
projectsAdapter: gxui.CreateDefaultAdapter(),
}
pane.projectsAdapter.SetItems(settings.Projects())
pane.projects.SetAdapter(pane.projectsAdapter)
return pane
}
示例4: numberPicker
// 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
}