TCustomTreeView.DoPaintNode procedure
Renders the specified tree node to the canvas for the control.
Declaration
procedure DoPaintNode(Node: TTreeNode); virtualArguments
Node | Tree node examined and rendered in the method. |
Description
DoPaintNode is a method used to render the tree node specified in
Node to the
Canvas for the control. DoPaintNode is
called from the DoPaint method, and occurs for visible nodes processed in the
method. The display rectangle needed for the tree node is calculated in the
method. No actions are performed if the Node is not in the visible client area
for the control.
By default, text drawn for a node uses the Font assigned to the control with
its Color used for the background on the rendered tree node. The font, color,
and background are overridden as needed to reflect the enabled, selected, or
hot-tracked state for the tree node. These may also be changed when theme
drawing is enabled in Options (using tvoThemedDraw).
SelectedColor and SelectedFontColor are used when the tree node is selected (or multi-selected), selection highlighting is not hidden, and theme drawing has not been enabled.
DisabledFontColor is used when the tree node is not enabled and the property contains a value other than clNone.
DoPaintNode retrieves scaled image resolutions needed for the Images and StateImages in the control. The images sizes are determined by applying the scaling factor in Canvas to the current PixelsPerInch setting in Font.
Use of multi-stage custom drawing is supported. If event handlers are provided which support the stages, the draw state flags needed for a focused / selected / multi-selected / hot-tracked / disabled tree node are calculated.
CustomDrawItem is called to draw the node using the draw state flags and image settings for the node. No additional actions are performed in the method if event handlers have not been assigned which support custom drawing the item for the cdPrePaint state.
See IsCustomDrawn for information about the custom draw event
handlers and their use for specific drawing stages.
ShowButtons controls whether an Expand / Collapse indicator is drawn for a tree node which has child nodes, or is the root node for the tree view control.
DoPaintNode performs default drawing for the elements which represent a given tree node using its Canvas. These actions are performed when custom draw event handlers have not been assigned or enabled in Options, including:
- Drawing the normal, unselected, non-tracked background for the node.
- Drawing the background for a selected or hot-tracked node.
- Drawing the full-width background for a selected or hot-tracked node when RowSelect is enabled.
- Drawing horizontal and vertical lines which connect tree nodes using the TreeLineColor and TreeLinePenStyle for the control.
- Drawing the expand or collapse indicator using the expanded state for a node with child nodes. Use ExpandSignType and ExpandSignColor for the pre-defined indicators used on the control. Use OnCustomDrawArrow to draw a custom expand / collapse indicator.
- Drawing the StateImage, Image (including the built-in ones), and an overlay image using the ImageIndex, SelectedIndex, and OverlayIndex for the tree node.
- Drawing the text for the node when assigned and the node is not being edited. The text is drawn using the selected and hot-tracked state for the node. The underline style is added to the font when a node is hot-tracked and themed drawing has not been enabled in Options.
- Drawing the separator line after a tree node when tvoShowSeparators has been included in Options.
- Drawing the insert mark for a tree node inserted in to the tree view control. Use InsertMarkType to specify the position for the mark relative to the InsertMarkNode.
If custom draw event handlers for the cdPostPaint drawing stage have been assigned, draw state flags are calculated for Selected, MultiSelected, Focused, and hot-tracking state for the node. The CustomDrawItem method is called to draw the node using the event handlers for the drawing stage.
Modified in LCL version 5.0 to provide better support for background drawing, and selected or hot-tracked drawing states in multi-stage drawing.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
