Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
cv.Initialize(Root)
Sleep(0)
drawGrid(20, 3)
Dim treeData As List = CreateList(Array( _
CreateMap("text": "Item 1", "row": 10, "col": 0, "children": CreateList(Array( _
CreateMap("text": "Item 1-1", "row": 8, "col": 1,"children": CreateList(Array( _
CreateMap("text": "Item 1-1-1", "row": 3, "col": 2), _
CreateMap("text": "Item 1-1-2", "row": 4, "col": 2)) _
)), _
CreateMap("text": "Item 1-2", "row": 9, "col": 1, "children": CreateList(Array( _
CreateMap("text": "Item 1-2-1", "row": 9, "col": 2), _
CreateMap("text": "Item 1-2-2", "row": 10, "col": 2)) _
)), _
CreateMap("text": "Item 1-3", "row": 10, "col": 1, "children": CreateList(Array( _
CreateMap("text": "Item 1-3-1", "row": 15, "col": 2)) _
))) _
)) _
))
drawTree(treeData, "")
End Sub
Private Sub drawTree(tree As List, tabs As String)
tabs = tabs & TAB
Dim connectCount As Int
For Each item As Map In tree
Dim text As String = item.Get("text")
Dim row As Int = item.Get("row")
Dim col As Int = item.Get("col")
drawText(text, row, col, tabs)
If item.ContainsKey("children") Then
Dim children As List = item.Get("children")
connectCount = connectCount + 1
connect(connectCount, row, col, children.Get(0), True)
connect(connectCount, row, col, children.Get(children.Size -1), False)
drawTree(children, tabs)
End If
Next
End Sub