TAChart: Use IChartDrawer to draw chart back wall

git-svn-id: trunk@29529 -
This commit is contained in:
ask 2011-02-13 15:57:46 +00:00
parent a4fb8cc245
commit 6edfc21f02
2 changed files with 31 additions and 16 deletions

View File

@ -63,10 +63,12 @@ type
AX1, AY1, AX2, AY2: Integer;
AStartAngle16Deg, AAngleLength16Deg: Integer);
procedure Rectangle(const ARect: TRect);
procedure Rectangle(AX1, AY1, AX2, AY2: Integer);
procedure SetBrush(APen: TFPCustomBrush);
procedure SetBrushParams(AStyle: TBrushStyle; AColor: TChartColor);
procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor);
procedure SetFont(AValue: TFPCustomFont);
procedure SetPen(APen: TFPCustomPen);
procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
function TextExtent(const AText: String): TPoint;
function TextExtent(AText: TStrings): TPoint;
function TextOut: TChartTextOut;
@ -117,7 +119,9 @@ type
AX1, AY1, AX2, AY2: Integer;
AStartAngle16Deg, AAngleLength16Deg: Integer);
procedure Rectangle(const ARect: TRect);
procedure SetBrushParams(AStyle: TBrushStyle; AColor: TChartColor);
procedure Rectangle(AX1, AY1, AX2, AY2: Integer);
procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor);
function TextExtent(const AText: String): TPoint;
function TextExtent(AText: TStrings): TPoint;
function TextOut: TChartTextOut;
@ -345,6 +349,11 @@ begin
AX1, AY1, AX2, AY2, AStartAngle16Deg, AAngleLength16Deg);
end;
procedure TCanvasDrawer.Rectangle(AX1, AY1, AX2, AY2: Integer);
begin
FCanvas.Rectangle(AX1, AY1, AX2, AY2);
end;
procedure TCanvasDrawer.Rectangle(const ARect: TRect);
begin
FCanvas.Rectangle(ARect);
@ -356,7 +365,7 @@ begin
end;
procedure TCanvasDrawer.SetBrushParams(
AStyle: TBrushStyle; AColor: TChartColor);
AStyle: TFPBrushStyle; AColor: TChartColor);
begin
FCanvas.Brush.Style := AStyle;
FCanvas.Brush.Color := AColor;
@ -372,6 +381,12 @@ begin
FCanvas.Pen.Assign(APen);
end;
procedure TCanvasDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
begin
FCanvas.Pen.Style := AStyle;
FCanvas.Pen.Color := AColor;
end;
function TCanvasDrawer.TextExtent(const AText: String): TPoint;
begin
Result := MultiLineTextExtent(FCanvas, AText);

View File

@ -217,7 +217,7 @@ type
protected
procedure Clear(ADrawer: IChartDrawer; const ARect: TRect);
procedure DisplaySeries(ADrawer: IChartDrawer);
procedure DrawBackWall(ACanvas: TCanvas);
procedure DrawBackWall(ADrawer: IChartDrawer);
procedure MouseDown(
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
@ -656,7 +656,7 @@ begin
PrepareLegend(ADrawer, legendItems, FClipRect, legendRect);
try
PrepareAxis(ADrawer.Canvas);
DrawBackWall(ADrawer.Canvas);
DrawBackWall(ADrawer);
DisplaySeries(ADrawer);
if Legend.Visible then
Legend.Draw(ADrawer, legendItems, legendRect);
@ -669,30 +669,30 @@ begin
Series[i].AfterDraw;
end;
procedure TChart.DrawBackWall(ACanvas: TCanvas);
procedure TChart.DrawBackWall(ADrawer: IChartDrawer);
var
defaultDrawing: Boolean = true;
begin
if Assigned(OnBeforeDrawBackWall) then
OnBeforeDrawBackWall(Self, ACanvas, FClipRect, defaultDrawing);
if ADrawer.HasCanvas and Assigned(OnBeforeDrawBackWall) then
OnBeforeDrawBackWall(Self, ADrawer.Canvas, FClipRect, defaultDrawing);
if defaultDrawing then
with ACanvas do begin
with ADrawer do begin
if FFrame.Visible then
Pen.Assign(FFrame)
Pen := FFrame
else
Pen.Style := psClear;
Brush.Color := BackColor;
SetPenParams(psClear, clTAColor);
SetBrushParams(bsSolid, BackColor);
with FClipRect do
Rectangle(Left, Top, Right + 1, Bottom + 1);
end;
if Assigned(OnAfterDrawBackWall) then
OnAfterDrawBackWall(Self, ACanvas, FClipRect);
if ADrawer.HasCanvas and Assigned(OnAfterDrawBackWall) then
OnAfterDrawBackWall(Self, ADrawer.Canvas, FClipRect);
// Z axis
if (Depth > 0) and FFrame.Visible then begin
ACanvas.Pen.Assign(FFrame);
ADrawer.Pen := FFrame;
with FClipRect do
ACanvas.Line(Left, Bottom, Left - Depth, Bottom + Depth);
ADrawer.Line(Left, Bottom, Left - Depth, Bottom + Depth);
end;
end;