From 2d7dd017e50e3d30f5a796a62bdc97e4cc938161 Mon Sep 17 00:00:00 2001 From: ask Date: Mon, 21 Feb 2011 09:42:59 +0000 Subject: [PATCH] TAChart: Add GetBrushColor, SetBrushColor and DrawLineDepth methods to the IChartDrawer interface git-svn-id: trunk@29629 - --- components/tachart/tadraweraggpas.pas | 14 +++++++++- components/tachart/tadrawutils.pas | 37 +++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/components/tachart/tadraweraggpas.pas b/components/tachart/tadraweraggpas.pas index 0d93d3c6ec..ae124dc894 100644 --- a/components/tachart/tadraweraggpas.pas +++ b/components/tachart/tadraweraggpas.pas @@ -29,17 +29,19 @@ type procedure ClippingStart(const AClipRect: TRect); procedure ClippingStop; procedure FillRect(AX1, AY1, AX2, AY2: Integer); + function GetBrushColor: TChartColor; function GetCanvas: TCanvas; function HasCanvas: Boolean; procedure Line(AX1, AY1, AX2, AY2: Integer); procedure Line(const AP1, AP2: TPoint); - procedure Polygon(const APoints: array of TPoint); + procedure Polygon(const APoints: array of TPoint); override; procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); end; @@ -83,6 +85,11 @@ begin FCanvas.FillRect(AX1, AY1, AX2, AY2); end; +function TAggPasDrawer.GetBrushColor: TChartColor; +begin + Result := FCanvas.Brush.Color; +end; + function TAggPasDrawer.GetCanvas: TCanvas; begin raise Exception.Create('TAggPasDrawer.GetCanvas'); @@ -153,6 +160,11 @@ begin end; end; +procedure TAggPasDrawer.SetBrushColor(AColor: TChartColor); +begin + FCanvas.Brush.Color := AColor; +end; + procedure TAggPasDrawer.SetBrushParams( AStyle: TFPBrushStyle; AColor: TChartColor); begin diff --git a/components/tachart/tadrawutils.pas b/components/tachart/tadrawutils.pas index d911ebda7f..8d1d7a9d8a 100644 --- a/components/tachart/tadrawutils.pas +++ b/components/tachart/tadrawutils.pas @@ -88,7 +88,10 @@ type procedure ClippingStart(const AClipRect: TRect); procedure ClippingStart; procedure ClippingStop; + procedure DrawLineDepth(AX1, AY1, AX2, AY2, ADepth: Integer); + procedure DrawLineDepth(const AP1, AP2: TPoint; ADepth: Integer); procedure FillRect(AX1, AY1, AX2, AY2: Integer); + function GetBrushColor: TChartColor; function GetCanvas: TCanvas; function HasCanvas: Boolean; procedure Line(AX1, AY1, AX2, AY2: Integer); @@ -100,7 +103,8 @@ type AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); - procedure SetBrush(APen: TFPCustomBrush); + procedure SetBrushColor(AColor: TChartColor); + procedure SetBrush(ABrush: TFPCustomBrush); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); procedure SetFont(AValue: TFPCustomFont); procedure SetPen(APen: TFPCustomPen); @@ -110,6 +114,7 @@ type function TextOut: TChartTextOut; property Brush: TFPCustomBrush write SetBrush; + property BrushColor: TChartColor read GetBrushColor write SetBrushColor; property Canvas: TCanvas read GetCanvas; property Font: TFPCustomFont write SetFont; property Pen: TFPCustomPen write SetPen; @@ -123,6 +128,9 @@ type procedure SimpleTextOut(AX, AY: Integer; const AText: String); virtual; abstract; function SimpleTextExtent(const AText: String): TPoint; virtual; abstract; public + procedure DrawLineDepth(AX1, AY1, AX2, AY2, ADepth: Integer); + procedure DrawLineDepth(const AP1, AP2: TPoint; ADepth: Integer); + procedure Polygon(const APoints: array of TPoint); virtual; abstract; function TextExtent(const AText: String): TPoint; function TextExtent(AText: TStrings): TPoint; function TextOut: TChartTextOut; @@ -147,17 +155,19 @@ type procedure ClippingStop; constructor Create(ACanvas: TCanvas); procedure FillRect(AX1, AY1, AX2, AY2: Integer); + function GetBrushColor: TChartColor; function GetCanvas: TCanvas; function HasCanvas: Boolean; procedure Line(AX1, AY1, AX2, AY2: Integer); procedure Line(const AP1, AP2: TPoint); - procedure Polygon(const APoints: array of TPoint); + procedure Polygon(const APoints: array of TPoint); override; procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; AStartAngle16Deg, AAngleLength16Deg: Integer); procedure Rectangle(const ARect: TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer); + procedure SetBrushColor(AColor: TChartColor); procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor); procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); end; @@ -289,6 +299,19 @@ end; { TFPCanvasDrawer } +procedure TFPCanvasDrawer.DrawLineDepth(AX1, AY1, AX2, AY2, ADepth: Integer); +begin + DrawLineDepth(Point(AX1, AY1), Point(AX2, AY2), ADepth); +end; + +procedure TFPCanvasDrawer.DrawLineDepth(const AP1, AP2: TPoint; ADepth: Integer); +var + d: TPoint; +begin + d := Point(ADepth, -ADepth); + Polygon([AP1, AP1 + d, AP2 + d, AP2]); +end; + function TFPCanvasDrawer.TextExtent(const AText: String): TPoint; var sl: TStrings; @@ -355,6 +378,11 @@ begin FCanvas.FillRect(AX1, AY1, AX2, AY2); end; +function TCanvasDrawer.GetBrushColor: TChartColor; +begin + Result := FCanvas.Brush.Color; +end; + function TCanvasDrawer.GetCanvas: TCanvas; begin Result := FCanvas; @@ -418,6 +446,11 @@ begin FCanvas.Brush.Assign(ABrush); end; +procedure TCanvasDrawer.SetBrushColor(AColor: TChartColor); +begin + FCanvas.Brush.Color := AColor; +end; + procedure TCanvasDrawer.SetBrushParams( AStyle: TFPBrushStyle; AColor: TChartColor); begin