Skip to main content

Overview

You can create completely custom layout algorithms for TeeTree by implementing the TChildManager 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 abstract TChildManager 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 position
  • AParent - The parent node (may be nil for root nodes)
Returns: TPoint with X and Y coordinates for the cross-box
Function
Signature: Function DrawConnection(const AConnection: TTreeConnection): BooleanDraws the connection line between parent and child nodes.Parameters:
  • AConnection - The connection object to draw
Returns: True to continue drawing nodes, False to skip
Function
Signature: Function XPosition(const ANode: TTreeNodeShape; ABrotherIndex: Integer): IntegerCalculates the horizontal (X) position for a child node.Parameters:
  • ANode - The node to position
  • ABrotherIndex - Zero-based index among siblings
Returns: X coordinate in pixels
Function
Signature: Function YPosition(const ANode: TTreeNodeShape; ABrotherIndex: Integer): IntegerCalculates the vertical (Y) position for a child node.Parameters:
  • ANode - The node to position
  • ABrotherIndex - Zero-based index among siblings
Returns: Y coordinate in pixels

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:
Used by TTreeTopBottomAlignChild and TTreeLeftRightAlignChild.

Tips for Custom Layouts

Access node properties like ANode.Parent, ANode.Count, ANode.Children[i] to make layout decisions based on tree structure.
Use ANode.Tree.ChartBounds to access the tree’s drawing area boundaries.
For complex connection drawing, use AConnection.Points.Add() to create multi-segment paths.
Always check if ANode.Parent is assigned before accessing parent properties, as root nodes have no parent.

Connection Drawing Techniques

Simple Line Connection

Custom Connection Points

Testing Your Custom Manager