{ Draws the default normal node background }
procedure DrawNormalBackground(ARect: TRect);
begin
if Canvas.Brush.Color <> clNone then
Canvas.FillRect(ARect);
end;
{ Default-draws the background of selected and hot-tracked nodes over the full
client width. This does not occur when the tree is not in RowSelect mode,
or when the preceding OnAdvancedCustomDrawItem event handler has been
exited with DefaultDraw = fals. }
procedure DrawSpecialBackground(IsSelected, IsHot: Boolean; ARect: TRect);
var
Details: TThemedElementDetails;
DrawNormal: Boolean;
begin
if not RowSelect then
exit;
if not (IsSelected or IsHot) then
exit;
DrawNormal := IsSelected and not (Focused or IsHot) and HideSelection;
if (tvoThemedDraw in Options) and (not DrawNormal) then
begin
if (tvoFocusedPainting in FStates) then
begin
if (IsSelected and (not Focused) and not HideSelection) then
Details := ThemeServices.GetElementDetails(ttItemSelectedNotFocus)
else
if IsHot then
Details := ThemeServices.GetElementDetails(ttItemHot)
else
if IsSelected then
Details := ThemeServices.GetElementDetails(ttItemSelected);
ThemeServices.DrawElement(Canvas.Handle, Details, ARect, nil);
end;
end else
if (IsSelected or IsHot) and (Canvas.Brush.Color <> clNone) then
Canvas.FillRect(ARect);
end;
{ Draws first the node text background unless deactivated by user selection
in the custom-draw events. Then the node text is drawn. }
procedure DrawNodeText(IsSelected, IsHot: Boolean; NdRect: TRect; AText: String);
var
Details: TThemedElementDetails;
DrawNormal: Boolean;
begin
if tvoThemedDraw in Options then
begin
// Themed drawing here
DrawNormal := not (RowSelect or Focused or IsHot) and IsSelected and HideSelection;
if (IsSelected or IsHot) and not DrawNormal then
begin
if (not Focused) and (not HideSelection) and (not IsHot) then
Details := ThemeServices.GetElementDetails(ttItemSelectedNotFocus)
else
if IsHot then
Details := ThemeServices.GetElementDetails(ttItemHot)
else
if IsSelected then
Details := ThemeServices.GetElementDetails(ttItemSelected);
if not RowSelect then
ThemeServices.DrawElement(Canvas.Handle, Details, NdRect, nil);
end else
Details := ThemeServices.GetElementDetails(ttItemNormal);
end else
// Non-themed drawing of text background here
if not RowSelect and (Canvas.Brush.Color <> clNone) then
Canvas.FillRect(NdRect);
// Draw the node text
NdRect.Offset(ScaleX(2, 96), 0);
if (tvoThemedDraw in Options) then
begin
if not (Enabled and Node.Enabled) then
Details.State := 4; // TmSchema.TREIS_DISABLED = 4
ThemeServices.DrawText(Canvas, Details, AText, NdRect, DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX, 0);
end
else
begin
SetBkMode(Canvas.Handle, TRANSPARENT);
DrawText(Canvas.Handle, PChar(AText), -1, NdRect, DT_LEFT or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX);
end;
end;