Overview
TTreeConnection is a component that draws single or multi-line segments between nodes in a tree. Each connection is a full component with properties, methods, and events for customizing the appearance and behavior of lines connecting nodes.
Class Hierarchy
Key Features
- Multiple connection styles (auto, line, sides, curve)
- Customizable arrows at start and end points
- Multi-point connections
- Text labels on connections
- Border styling and colors
- Interactive selection and editing
- Automatic and manual positioning
Properties
Connected Nodes
The source node of the connection.
The destination node of the connection.
Connection Style
Defines how the connection is drawn:
csAuto- Automatic style determined by ChildManagercsLine- Direct straight linecsSides- Line with right angles (sides)csCurve- Bezier curvecsInvertedSides- Inverted sides style
Visual Appearance
Pen used to draw the connection line. Default is gray with small dots.TTreeConnectionPen defaults:
- Color:
clGray - SmallDots:
True - Style:
psDot
Additional formatting options for the connection background.
Arrows
Arrow displayed at the start (From) point of the connection.Properties:
Style- Arrow style (default:casNone)Size- Arrow size in pixelsBorder- Arrow border penBrush- Arrow fill brushBackColor- Arrow background color
casNone- No arrowcasSolid- Filled solid arrowcasLines- Line arrowcasSquare- Square arrowcasCircle- Circle arrowcasDiamond- Diamond arrow
Arrow displayed at the end (To) point of the connection. Default style is
casSolid.Connection Points
Collection of connection points that define the path of the connection.Point Styles:
cpsAutoFrom- Automatic position on From nodecpsAutoTo- Automatic position on To nodecpsFromPercent- Percentage offset from From nodecpsToPercent- Percentage offset from To nodecpsFromRel- Relative pixels from From nodecpsToRel- Relative pixels from To nodecpsPrevious- Relative to previous pointcpsNext- Relative to next pointcpsFixed- Fixed XY position
Text
Text to display along the connection line.
Font for connection text.
Other
Mouse cursor when hovering over the connection.
Reference to the parent Tree component.
Methods
Drawing
Draws the connection.Returns: True if connection was drawn
Draws edit handles when connection is selected.
Draws text on the connection.
Hit Testing
Tests if coordinates are on the connection line.Parameters:
x,y- Coordinates to test
Returns which line segment was clicked.Returns: Index of clicked segment, or -1 if none
Geometry
Returns the bounding rectangle of the connection.
Returns True if connection is visible.
Other
Copies properties from another connection.
Connection Points API
ThePoints property provides methods to manipulate connection points:
Adding Points
Adds a new point to the connection.
Adds a point relative to the previous point.
Modifying Points
Moves a point by offset.
Inserts a point at specific index.
Removes a point.
Removes all points.
Point Information
Returns the number of points.
Finds which point was clicked.Returns: Index of clicked point, or -1
Changes the X coordinate style of a point.
Changes the Y coordinate style of a point.
Usage Examples
Creating a Simple Connection
Customizing Connection Appearance
Adding Text to Connection
Creating Multi-Point Connection
Curved Connection
Connection with Sides Style
Handling Connection Click
Programmatic Point Manipulation
Conditional Arrow Display
Dynamic Connection Styling
See Also
- TTree - Main tree component
- TTreeNodeShape - Tree nodes
- TDBTree - Database-aware tree
