TreeNode methods newTreeNode creates and returns a pointer to a new TreeNode with the specified text, tree and parent node
(text string, tree *Tree, parNode *TreeNode)
| 194 | // newTreeNode creates and returns a pointer to a new TreeNode with |
| 195 | // the specified text, tree and parent node |
| 196 | func newTreeNode(text string, tree *Tree, parNode *TreeNode) *TreeNode { |
| 197 | |
| 198 | n := new(TreeNode) |
| 199 | n.Panel.Initialize(n, 0, 0) |
| 200 | |
| 201 | // Initialize node label |
| 202 | n.label.initialize(text, StyleDefault().Font) |
| 203 | n.Panel.Add(&n.label) |
| 204 | |
| 205 | // Create node icon |
| 206 | n.icon.initialize("", StyleDefault().FontIcon) |
| 207 | n.icon.SetFontSize(StyleDefault().Label.PointSize * 1.3) |
| 208 | n.Panel.Add(&n.icon) |
| 209 | |
| 210 | // Subscribe to events |
| 211 | n.Panel.Subscribe(OnMouseDown, n.onMouse) |
| 212 | n.Panel.Subscribe(OnListItemResize, func(evname string, ev interface{}) { |
| 213 | n.recalc() |
| 214 | }) |
| 215 | n.tree = tree |
| 216 | n.parNode = parNode |
| 217 | |
| 218 | n.update() |
| 219 | n.recalc() |
| 220 | return n |
| 221 | } |
| 222 | |
| 223 | // Len returns the number of immediate children of this node |
| 224 | func (n *TreeNode) Len() int { |
no test coverage detected