procedure TChartListbox.DrawItem(
AIndex: Integer; ARect: TRect; AState: TOwnerDrawState);
{ draws the listbox item }
const
THEMED_FLAGS: array [TCheckboxesStyle, Boolean] of TThemedButton = (
(tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal),
(tbRadioButtonUnCheckedNormal, tbRadioButtonCheckedNormal)
);
var
id: IChartDrawer;
rcb, ricon: TRect;
te: TThemedElementDetails;
x: Integer;
ch: Boolean;
begin
if Assigned(OnDrawItem) then begin
OnDrawItem(Self, AIndex, ARect, AState);
exit;
end;
if (FChart = nil) or not InRange(AIndex, 0, Count - 1) then
exit;
Canvas.FillRect(ARect);
CalcRects(ARect, rcb, ricon);
if cloShowCheckboxes in Options then begin
ch := Checked[AIndex];
te := ThemeServices.GetElementDetails(THEMED_FLAGS[FCheckStyle, ch]);
ThemeServices.DrawElement(Canvas.Handle, te, rcb);
x := rcb.Right;
end
else
x := ARect.Left;
Canvas.Brush.Style := bsClear;
if cloShowIcons in Options then begin
id := TCanvasDrawer.Create(Canvas);
id.Pen := Chart.Legend.SymbolFrame;
FLegendItems[AIndex].Draw(id, ricon);
end
else
Canvas.TextOut(x + 2, ARect.Top, FLegendItems.Items[AIndex].Text);
end;