Beispiel #1
0
func CreateTreeToListAdapter(adapter gxui.TreeAdapter, ceb CreateExpandButton) *TreeToListAdapter {
	outer := &TreeToListAdapter{
		createExpandButton: ceb,
		adapter:            adapter,
		root:               CreateTreeInternalRoot(adapter),
	}
	adapter.OnDataReplaced(func() {
		outer.root = CreateTreeInternalRoot(adapter)
		outer.DataReplaced()
	})
	adapter.OnDataChanged(outer.DataChanged)

	return outer
}
Beispiel #2
0
// CreateTreeToListAdapter wraps the provided TreeAdapter with an adapter
// conforming to the ListAdapter interface.
func CreateTreeToListAdapter(treeAdapter gxui.TreeAdapter, creator TreeControlCreator) *TreeToListAdapter {
	listAdapter := &TreeToListAdapter{}
	listAdapter.node.depth = -1 // The node is just a container.
	listAdapter.node.container = treeAdapter
	listAdapter.adapter = treeAdapter
	listAdapter.creator = creator
	treeAdapter.OnDataReplaced(func() {
		listAdapter.reset()
		listAdapter.DataReplaced()
	})
	treeAdapter.OnDataChanged(func(recreateControls bool) {
		listAdapter.node.update(listAdapter)
		listAdapter.DataChanged(recreateControls)
	})
	listAdapter.reset()
	return listAdapter
}
// CreateTreeToListAdapter wraps the provided TreeAdapter with an adapter
// conforming to the ListAdapter interface.
func CreateTreeToListAdapter(treeAdapter gxui.TreeAdapter, creator TreeControlCreator) *TreeToListAdapter {
	listAdapter := &TreeToListAdapter{}
	listAdapter.depth = -1 // The adapter is not a node, just a container.
	listAdapter.adapter = treeAdapter
	listAdapter.container = treeAdapter
	listAdapter.creator = creator
	treeAdapter.OnDataReplaced(func() {
		listAdapter.reset()
		listAdapter.DataReplaced()
	})
	treeAdapter.OnDataChanged(func() {
		listAdapter.update()
		listAdapter.DataChanged()
	})
	listAdapter.reset()
	return listAdapter
}