Overview
TPainter is an abstract base class that provides platform-agnostic methods for drawing shapes, text, and graphics in TeeGrid. Framework-specific implementations (VCL and FireMonkey) inherit from this class to provide actual rendering functionality.
Unit: Tee.Painter.pas
Architecture
TPainter provides an abstraction layer that allows TeeGrid to work identically across different frameworks:
- VCL:
VCLTee.Painterunit implementsTPainterusing GDI/GDI+ - FireMonkey:
FMXTee.Painterunit implementsTPainterusing FMX canvas - Lazarus/LCL: Compatible with VCL painter implementation
Type Definitions
THorizontalAlign
TVerticalAlign
TTrimmingMode
None: No trimmingCharacter: Trim at character boundaryWord: Trim at word boundary
TPointsF
Drawing Methods
Draw (Rectangle)
R: Rectangle bounds
Draw (Polyline)
P: Array of points
Draw (Picture)
APicture: Picture to drawX,Y: Top-left coordinatesR: Rectangle to draw within (stretches if picture has Stretch = True)
DrawEllipse
R: Bounding rectangle
Filling Methods
Fill (Rectangle)
R: Rectangle boundsAColor: Fill color (optional)
Fill (Polygon)
P: Array of points (automatically closed)
FillEllipse
R: Bounding rectangle
Line Drawing Methods
Line
HorizontalLine
Y: Vertical positionX0: Start X coordinateX1: End X coordinate
VerticalLine
X: Horizontal positionY0: Start Y coordinateY1: End Y coordinate
Lines
P: Array of points
Text Methods
TextOut
ARect: Rectangle boundsAText: Text to draw
TextWidth
AText: Text to measure
TextHeight
AText: Text to measureAFont: Font to use for measurement
CalcTextLines
AText: Text with potential line breaks
Style Setting Methods
SetBrush
HideBrush
SetStroke
SetFont
SetFontColor
SetHorizontalAlign
Left, Center, Right
SetVerticalAlign
Top, Center, Bottom
SetTextTrimming
ATrimming: Trimming mode (None, Character, Word)Ellipsi: Show ”…” when trimmed
Format Painting Methods
Paint (Format + Rectangle)
Paint (Format + Polygon)
Clipping Methods
Clip
R: Clipping rectangle
UnClip
TryClip
AText: Text to checkARect: Bounding rectangleAMinX: Minimum X coordinate
True if clipping was applied
Usage Example: Complete Rendering
Platform-Specific Notes
VCL Implementation
- Uses GDI+ for smooth rendering
- Supports all standard Windows fonts
- Hardware-accelerated on modern systems
FireMonkey Implementation
- Uses native FMX canvas
- Cross-platform compatible (Windows, macOS, iOS, Android, Linux)
- Supports GPU acceleration on mobile
Performance Tips
- Minimize state changes: Group operations that use the same brush/stroke/font
- Reuse objects: Don’t create new TFormat/TFont objects for every cell
- Use clipping: Prevent overdraw by clipping to visible region
- Batch similar operations: Draw all horizontal lines together, then all vertical lines
See Also
- TRender - Base class for custom renderers
- TFormat - Formatting classes used with painter
- Custom Renderers Guide - Creating custom visual elements
