TAChart: Use IChartDrawer to draw TConstantLine series

git-svn-id: trunk@29624 -
This commit is contained in:
ask 2011-02-20 23:02:21 +00:00
parent bec3b9be2a
commit afb0fca7f1
2 changed files with 15 additions and 15 deletions

View File

@ -241,8 +241,8 @@ type
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
public // Helpers for series drawing
procedure DrawLineHoriz(ACanvas: TCanvas; AY: Integer);
procedure DrawLineVert(ACanvas: TCanvas; AX: Integer);
procedure DrawLineHoriz(ADrawer: IChartDrawer; AY: Integer);
procedure DrawLineVert(ADrawer: IChartDrawer; AX: Integer);
procedure DrawOnCanvas(Rect: TRect; ACanvas: TCanvas); deprecated;
function IsPointInViewPort(const AP: TDoublePoint): Boolean;
@ -712,16 +712,16 @@ begin
end;
end;
procedure TChart.DrawLineHoriz(ACanvas: TCanvas; AY: Integer);
procedure TChart.DrawLineHoriz(ADrawer: IChartDrawer; AY: Integer);
begin
if (FClipRect.Top < AY) and (AY < FClipRect.Bottom) then
ACanvas.Line(FClipRect.Left, AY, FClipRect.Right, AY);
ADrawer.Line(FClipRect.Left, AY, FClipRect.Right, AY);
end;
procedure TChart.DrawLineVert(ACanvas: TCanvas; AX: Integer);
procedure TChart.DrawLineVert(ADrawer: IChartDrawer; AX: Integer);
begin
if (FClipRect.Left < AX) and (AX < FClipRect.Right) then
ACanvas.Line(AX, FClipRect.Top, AX, FClipRect.Bottom);
ADrawer.Line(AX, FClipRect.Top, AX, FClipRect.Bottom);
end;
procedure TChart.DrawOnCanvas(Rect: TRect; ACanvas: TCanvas);
@ -734,9 +734,9 @@ begin
if not ADrawer.HasCanvas then exit;
PrepareXorPen(ADrawer.Canvas);
if ReticuleMode in [rmVertical, rmCross] then
DrawLineVert(ADrawer.Canvas, FReticulePos.X);
DrawLineVert(ADrawer, FReticulePos.X);
if ReticuleMode in [rmHorizontal, rmCross] then
DrawLineHoriz(ADrawer.Canvas, FReticulePos.Y);
DrawLineHoriz(ADrawer, FReticulePos.Y);
end;
procedure TChart.EraseBackground(DC: HDC);

View File

@ -256,7 +256,7 @@ type
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Draw(ACanvas: TCanvas); override;
procedure Draw(ADrawer: IChartDrawer); override;
function GetNearestPoint(
ADistFunc: TPointDistFunc;
const APoint: TPoint; out AIndex: Integer; out AImg: TPoint;
@ -270,7 +270,7 @@ type
property Pen: TPen read FPen write SetPen;
property Position: Double read FPosition write SetPosition;
property SeriesColor: TColor
read GetSeriesColor write SetSeriesColor stored false default clTAColor;
read GetSeriesColor write SetSeriesColor stored false default clBlack;
property ShowInLegend;
property Title;
property UseBounds: Boolean read FUseBounds write SetUseBounds default true;
@ -596,17 +596,17 @@ begin
inherited;
end;
procedure TConstantLine.Draw(ACanvas: TCanvas);
procedure TConstantLine.Draw(ADrawer: IChartDrawer);
begin
ACanvas.Brush.Style := bsClear;
ACanvas.Pen.Assign(FPen);
ADrawer.SetBrushParams(bsClear, clTAColor);
ADrawer.Pen := FPen;
with ParentChart do
case LineStyle of
lsHorizontal:
DrawLineHoriz(ACanvas, YGraphToImage(FPosition));
DrawLineHoriz(ADrawer, YGraphToImage(FPosition));
lsVertical:
DrawLineVert(ACanvas, XGraphToImage(FPosition));
DrawLineVert(ADrawer, XGraphToImage(FPosition));
end;
end;