mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 10:29:29 +02:00
TAChart: Separate measure and draw phases for TChartTitle
git-svn-id: trunk@38890 -
This commit is contained in:
parent
4443b9ae3f
commit
e75056a790
@ -746,10 +746,6 @@ var
|
|||||||
begin
|
begin
|
||||||
Prepare;
|
Prepare;
|
||||||
|
|
||||||
ADrawer.DrawingBegin(ARect);
|
|
||||||
ADrawer.SetAntialiasingMode(AntialiasingMode);
|
|
||||||
Clear(ADrawer, ARect);
|
|
||||||
|
|
||||||
FClipRect := ARect;
|
FClipRect := ARect;
|
||||||
with MarginsExternal do begin
|
with MarginsExternal do begin
|
||||||
FClipRect.Left += Left;
|
FClipRect.Left += Left;
|
||||||
@ -759,8 +755,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
with ClipRect do begin;
|
with ClipRect do begin;
|
||||||
FTitle.Draw(ADrawer, 1, Left, Right, Top);
|
FTitle.Measure(ADrawer, 1, Left, Right, Top);
|
||||||
FFoot.Draw(ADrawer, -1, Left, Right, Bottom);
|
FFoot.Measure(ADrawer, -1, Left, Right, Bottom);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ldd.FItems := nil;
|
ldd.FItems := nil;
|
||||||
@ -768,6 +764,12 @@ begin
|
|||||||
ldd := PrepareLegend(ADrawer, FClipRect);
|
ldd := PrepareLegend(ADrawer, FClipRect);
|
||||||
try
|
try
|
||||||
PrepareAxis(ADrawer);
|
PrepareAxis(ADrawer);
|
||||||
|
|
||||||
|
ADrawer.DrawingBegin(ARect);
|
||||||
|
ADrawer.SetAntialiasingMode(AntialiasingMode);
|
||||||
|
Clear(ADrawer, ARect);
|
||||||
|
FTitle.Draw(ADrawer);
|
||||||
|
FFoot.Draw(ADrawer);
|
||||||
DrawBackWall(ADrawer);
|
DrawBackWall(ADrawer);
|
||||||
DisplaySeries(ADrawer);
|
DisplaySeries(ADrawer);
|
||||||
if Legend.Visible then
|
if Legend.Visible then
|
||||||
|
@ -119,6 +119,7 @@ type
|
|||||||
TChartTitle = class(TChartTextElement)
|
TChartTitle = class(TChartTextElement)
|
||||||
strict private
|
strict private
|
||||||
FBrush: TBrush;
|
FBrush: TBrush;
|
||||||
|
FCenter: TPoint;
|
||||||
FFont: TFont;
|
FFont: TFont;
|
||||||
FFrame: TChartTitleFramePen;
|
FFrame: TChartTitleFramePen;
|
||||||
FMargin: TChartDistance;
|
FMargin: TChartDistance;
|
||||||
@ -138,7 +139,8 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
public
|
public
|
||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
procedure Draw(
|
procedure Draw(ADrawer: IChartDrawer);
|
||||||
|
procedure Measure(
|
||||||
ADrawer: IChartDrawer; ADir, ALeft, ARight: Integer; var AY: Integer);
|
ADrawer: IChartDrawer; ADir, ALeft, ARight: Integer; var AY: Integer);
|
||||||
published
|
published
|
||||||
property Alignment default taCenter;
|
property Alignment default taCenter;
|
||||||
@ -510,22 +512,12 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartTitle.Draw(
|
procedure TChartTitle.Draw(ADrawer: IChartDrawer);
|
||||||
ADrawer: IChartDrawer; ADir, ALeft, ARight: Integer; var AY: Integer);
|
|
||||||
var
|
var
|
||||||
p, ptSize: TPoint;
|
|
||||||
dummy: TPointArray = nil;
|
dummy: TPointArray = nil;
|
||||||
begin
|
begin
|
||||||
if not Visible or (Text.Count = 0) then exit;
|
if not Visible or (Text.Count = 0) then exit;
|
||||||
ptSize := MeasureLabel(ADrawer, Text.Text);
|
DrawLabel(ADrawer, FCenter, FCenter, Text.Text, dummy);
|
||||||
case Alignment of
|
|
||||||
taLeftJustify: p.X := ALeft + ptSize.X div 2;
|
|
||||||
taRightJustify: p.X := ARight - ptSize.X div 2;
|
|
||||||
taCenter: p.X := (ALeft + ARight) div 2;
|
|
||||||
end;
|
|
||||||
p.Y := AY + ADir * ptSize.Y div 2;
|
|
||||||
DrawLabel(ADrawer, p, p, Text.Text, dummy);
|
|
||||||
AY += ADir * (ptSize.Y + Margin);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChartTitle.GetFrame: TChartPen;
|
function TChartTitle.GetFrame: TChartPen;
|
||||||
@ -543,6 +535,22 @@ begin
|
|||||||
Result := Font;
|
Result := Font;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartTitle.Measure(ADrawer: IChartDrawer;
|
||||||
|
ADir, ALeft, ARight: Integer; var AY: Integer);
|
||||||
|
var
|
||||||
|
ptSize: TPoint;
|
||||||
|
begin
|
||||||
|
if not Visible or (Text.Count = 0) then exit;
|
||||||
|
ptSize := MeasureLabel(ADrawer, Text.Text);
|
||||||
|
case Alignment of
|
||||||
|
taLeftJustify: FCenter.X := ALeft + ptSize.X div 2;
|
||||||
|
taRightJustify: FCenter.X := ARight - ptSize.X div 2;
|
||||||
|
taCenter: FCenter.X := (ALeft + ARight) div 2;
|
||||||
|
end;
|
||||||
|
FCenter.Y := AY + ADir * ptSize.Y div 2;
|
||||||
|
AY += ADir * (ptSize.Y + Margin);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartTitle.SetBrush(AValue: TBrush);
|
procedure TChartTitle.SetBrush(AValue: TBrush);
|
||||||
begin
|
begin
|
||||||
FBrush.Assign(AValue);
|
FBrush.Assign(AValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user