mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-30 12:09:45 +02:00
TAChart: Add TChartLegend.BackgroundBrush property
git-svn-id: trunk@21891 -
This commit is contained in:
parent
83a241e7ea
commit
49a19e71af
@ -55,11 +55,17 @@ type
|
||||
|
||||
TChartLegendItems = TObjectList;
|
||||
|
||||
TChartLegendBrush = class(TBrush)
|
||||
published
|
||||
property Color default clWhite;
|
||||
end;
|
||||
|
||||
{ TChartLegend }
|
||||
|
||||
TChartLegend = class(TChartElement)
|
||||
private
|
||||
FAlignment: TLegendAlignment;
|
||||
FBackgroundBrush: TChartLegendBrush;
|
||||
FFont: TFont;
|
||||
FFrame: TChartPen;
|
||||
FMargin: TChartDistance;
|
||||
@ -67,6 +73,7 @@ type
|
||||
FSymbolWidth: TChartDistance;
|
||||
|
||||
procedure SetAlignment(AValue: TLegendAlignment);
|
||||
procedure SetBackgroundBrush(AValue: TChartLegendBrush);
|
||||
procedure SetFont(AValue: TFont);
|
||||
procedure SetFrame(AValue: TChartPen);
|
||||
procedure SetMargin(AValue: TChartDistance);
|
||||
@ -83,6 +90,8 @@ type
|
||||
published
|
||||
property Alignment: TLegendAlignment
|
||||
read FAlignment write SetAlignment default laRight;
|
||||
property BackgroundBrush: TChartLegendBrush
|
||||
read FBackgroundBrush write SetBackgroundBrush;
|
||||
property Font: TFont read FFont write SetFont;
|
||||
property Frame: TChartPen read FFrame write SetFrame;
|
||||
property Margin: TChartDistance
|
||||
@ -183,6 +192,7 @@ begin
|
||||
FSymbolWidth := DEF_LEGEND_SYMBOL_WIDTH;
|
||||
Visible := false;
|
||||
|
||||
InitHelper(TFPCanvasHelper(FBackgroundBrush), TChartLegendBrush);
|
||||
InitHelper(TFPCanvasHelper(FFont), TFont);
|
||||
InitHelper(TFPCanvasHelper(FFrame), TChartPen);
|
||||
end;
|
||||
@ -221,14 +231,14 @@ begin
|
||||
y1 := AClipRect.Top;
|
||||
|
||||
// Border
|
||||
ACanvas.Brush.Color := clWhite;
|
||||
ACanvas.Brush.Assign(BackgroundBrush);
|
||||
ACanvas.Pen.Assign(Frame);
|
||||
ACanvas.Rectangle(Bounds(
|
||||
x1, y1, w, Spacing + AItems.Count * (th + Spacing)));
|
||||
|
||||
r := Bounds(x1 + Spacing, y1 + Spacing, SymbolWidth, th);
|
||||
for i := 0 to AItems.Count - 1 do begin
|
||||
ACanvas.Brush.Color := clWhite;
|
||||
ACanvas.Brush.Assign(BackgroundBrush);
|
||||
ACanvas.Pen.Assign(Frame);
|
||||
(AItems[i] as TLegendItem).Draw(ACanvas, r);
|
||||
OffsetRect(r, 0, th + Spacing);
|
||||
@ -245,6 +255,12 @@ begin
|
||||
StyleChanged(Self);
|
||||
end;
|
||||
|
||||
procedure TChartLegend.SetBackgroundBrush(AValue: TChartLegendBrush);
|
||||
begin
|
||||
FBackgroundBrush.Assign(AValue);
|
||||
StyleChanged(Self);
|
||||
end;
|
||||
|
||||
procedure TChartLegend.SetFont(AValue: TFont);
|
||||
begin
|
||||
FFont.Assign(AValue);
|
||||
|
Loading…
Reference in New Issue
Block a user