|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
--[[ The tree node--]] node.m_OwningTree = myTree node.m_Control = controlData node.m_Expanded = true node.m_Showing = true node.m_Child = nil node.m_Sibling = nil node.m_Parent = myParent node.m_ChildIndent = childIndent return nodeendend if(node) then local parentShowing = true local parentExpanded = true if(node.m_Parent) then end node.m_Showing = parentShowing and parentExpanded if(node.m_Child) then end if(node.m_Sibling) then end endend if(expanded == nil) then end end if(expanded) then --climb the tree opening un-expanded parents while(curParent ~= nil) do if(not curParent.m_Expanded) then curParent.m_Expanded = true end lastChangedParent = curParent end curParent = curParent.m_Parent end --update visibility from the highest changed node else end -- Update the whole tree.endendendend local nestingLevel = 0 do nestingLevel = nestingLevel + 1 ancestor = ancestor.m_Parent end return nestingLevelendendendendendendend--[[ The tree control--]]local DEFAULT_INDENT_OFFSET = 10local DEFAULT_LINE_SPACING = 5 tree.m_OffsetX = indentXOffset or DEFAULT_INDENT_OFFSET tree.m_OffsetY = verticalSpacing or DEFAULT_LINE_SPACING tree.m_InitialAnchor = initialAnchor return treeend if(atNode == nil) then return nil end -- If root is the insertion point, and there is no child add the new node as Root's first child then return newNode end -- Find the last sibling of atNode's first child and insert after that. if(atNode.m_Child == nil) then atNode.m_Child = newNode return newNode endendlocal ADD_HERE = 1local ADD_ON_END = 2 then return nil end if(where == ADD_ON_END) then while(atNode.m_Sibling) do atNode = atNode.m_Sibling end atNode.m_Sibling = newNode else newNode.m_Sibling = atNode.m_Sibling atNode.m_Sibling = newNode end return newNodeendendend-- NOTE: This removes entire subtrees, but does not inform the controls in those subtrees that they have been-- removed. That needs to be handled by whatever is calling RemoveNode. then return end if(node.m_Parent) then if(node.m_Parent.m_Child == node) then node.m_Parent.m_Child = node.m_Sibling return end local previousSibling = nil local currentSibling = node.m_Parent.m_Child if(currentSibling == nil) then return end while((currentSibling ~= node) and (currentSibling ~= nil)) do previousSibling = currentSibling currentSibling = currentSibling.m_Sibling end if(currentSibling == node) then previousSibling.m_Sibling = node.m_Sibling end endendend indent = indent or 0 if(firstControl == nil) then firstControl = true end if(node) then if(node.m_Control) then if(not hidden) then if(firstControl) then firstControl = false else end end end local backOffIndent = false if(node.m_Child) then then indent = 0 else end end if(backOffIndent) then else indent = 0 end node = node.m_Sibling if(node) then end end return anchor, indentendendend |