Lightweight bottom-up tree with variable size nodes
Posted on 2006-04-02
I'd like to build a tree display that is a bit unusual.
a) firstly the nodes are of different sizes .. that is, they have different amounts of text in them, multiple lines etc
b) I want the first level nodes to appear alternately left and right of the "main trunk", and left side nodes always expand out to the left, right side nodes to the right
c) conceptually at least, this is built from the bottom up. I am not sure that this makes any difference in practice, but that is my idea.
d) the tree is of unknown size, in general. Scrolling will be required.
I need some help getting started.
q1. What sort of container should I use for the tree? a Tscrollbox?
q2. For the nodes, should I use panels?
q3. I need some clues as to how to do the painting. When the user scrolls, how do I determine what needs to be painted . What messages do I need to handle?
q4. The coordinate system will need to be "virtual" - in the sense that I cannot know in advance, until I start drawing, what the coordinates of any node should be. This will thus involve some negative coordinates .. do I need to map these back to a positive coordinate space?
I know there are good tree packages out there (like TeeTree and VirtualTreeView), but I want to try this for myself. It does not need to do much except draw itself and respond to expand/collapse clicks.