Overview
You can create completely custom layout algorithms for TeeTree by implementing theTChildManager abstract base class. This allows you to define exactly how child nodes are positioned relative to their parents.
Base Class: TChildManager
All child managers inherit from the abstractTChildManager class, which defines the interface for layout algorithms.
Abstract Methods
You must implement these four abstract methods:Function
Signature:
Function CalcXYCross(const ANode, AParent: TTreeNodeShape): TPointCalculates the position of the cross-box (expand/collapse control) for the given node.Parameters:ANode- The node for which to calculate cross-box positionAParent- The parent node (may be nil for root nodes)
Function
Signature:
Function DrawConnection(const AConnection: TTreeConnection): BooleanDraws the connection line between parent and child nodes.Parameters:AConnection- The connection object to draw
Function
Signature:
Function XPosition(const ANode: TTreeNodeShape; ABrotherIndex: Integer): IntegerCalculates the horizontal (X) position for a child node.Parameters:ANode- The node to positionABrotherIndex- Zero-based index among siblings
Function
Signature:
Function YPosition(const ANode: TTreeNodeShape; ABrotherIndex: Integer): IntegerCalculates the vertical (Y) position for a child node.Parameters:ANode- The node to positionABrotherIndex- Zero-based index among siblings
Creating a Custom Child Manager
Basic Template
Using Your Custom Manager
Example: Diagonal Layout
Here’s a complete example of a diagonal child manager:Visual Result
Example: Grid Layout
A child manager that arranges nodes in a grid:Visual Result
Built-in Helper Classes
Several built-in classes provide useful foundations:TTreeSideAlignChild
Base class with common properties for side-based layouts:TTreeTopBottomAlignChild and TTreeLeftRightAlignChild.
Tips for Custom Layouts
Connection Drawing Techniques
Simple Line Connection
Custom Connection Points
Testing Your Custom Manager
Related Classes
- Explorer Layout - Reference implementation
- Horizontal Layout - Left-to-right example
- Vertical Layout - Top-to-bottom example
- Circular Layout - Radial example
