mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 15:12:39 +02:00
TAChart: Add OnBeforeDrawBackWall, OnAfterDrawBackWall events to TChart component.
This partially implements issue #18403 git-svn-id: trunk@28887 -
This commit is contained in:
parent
f56cf898d9
commit
d62a631917
@ -131,6 +131,12 @@ type
|
|||||||
property List: TFPList read FList;
|
property List: TFPList read FList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TChartAfterDrawEvent = procedure (
|
||||||
|
ASender: TChart; ACanvas: TCanvas; const ARect: TRect) of object;
|
||||||
|
TChartBeforeDrawEvent = procedure (
|
||||||
|
ASender: TChart; ACanvas: TCanvas; const ARect: TRect;
|
||||||
|
var ADoDefaultDrawing: Boolean) of object;
|
||||||
|
|
||||||
{ TChart }
|
{ TChart }
|
||||||
|
|
||||||
TChart = class(TCustomChart, ICoordTransformer)
|
TChart = class(TCustomChart, ICoordTransformer)
|
||||||
@ -148,6 +154,8 @@ type
|
|||||||
FLegend: TChartLegend;
|
FLegend: TChartLegend;
|
||||||
FLogicalExtent: TDoubleRect;
|
FLogicalExtent: TDoubleRect;
|
||||||
FMargins: TChartMargins;
|
FMargins: TChartMargins;
|
||||||
|
FOnAfterDrawBackWall: TChartAfterDrawEvent;
|
||||||
|
FOnBeforeDrawBackWall: TChartBeforeDrawEvent;
|
||||||
FOnDrawReticule: TDrawReticuleEvent;
|
FOnDrawReticule: TDrawReticuleEvent;
|
||||||
FSeries: TChartSeriesList;
|
FSeries: TChartSeriesList;
|
||||||
FTitle: TChartTitle;
|
FTitle: TChartTitle;
|
||||||
@ -168,7 +176,7 @@ type
|
|||||||
|
|
||||||
procedure CalculateTransformationCoeffs(const AMargin: TRect);
|
procedure CalculateTransformationCoeffs(const AMargin: TRect);
|
||||||
procedure DrawReticule(ACanvas: TCanvas);
|
procedure DrawReticule(ACanvas: TCanvas);
|
||||||
function GetAxis(AIndex: integer): TChartAxis; inline;
|
function GetAxis(AIndex: Integer): TChartAxis;
|
||||||
function GetChartHeight: Integer;
|
function GetChartHeight: Integer;
|
||||||
function GetChartWidth: Integer;
|
function GetChartWidth: Integer;
|
||||||
function GetMargins(ACanvas: TCanvas): TRect;
|
function GetMargins(ACanvas: TCanvas): TRect;
|
||||||
@ -189,6 +197,9 @@ type
|
|||||||
procedure SetLegend(Value: TChartLegend);
|
procedure SetLegend(Value: TChartLegend);
|
||||||
procedure SetLogicalExtent(const AValue: TDoubleRect);
|
procedure SetLogicalExtent(const AValue: TDoubleRect);
|
||||||
procedure SetMargins(AValue: TChartMargins);
|
procedure SetMargins(AValue: TChartMargins);
|
||||||
|
procedure SetOnAfterDrawBackWall(AValue: TChartAfterDrawEvent);
|
||||||
|
procedure SetOnBeforeDrawBackWall(AValue: TChartBeforeDrawEvent);
|
||||||
|
procedure SetOnDrawReticule(AValue: TDrawReticuleEvent);
|
||||||
procedure SetProportional(AValue: Boolean);
|
procedure SetProportional(AValue: Boolean);
|
||||||
procedure SetReticuleMode(const AValue: TReticuleMode);
|
procedure SetReticuleMode(const AValue: TReticuleMode);
|
||||||
procedure SetReticulePos(const AValue: TPoint);
|
procedure SetReticulePos(const AValue: TPoint);
|
||||||
@ -199,7 +210,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure Clean(ACanvas: TCanvas; ARect: TRect);
|
procedure Clean(ACanvas: TCanvas; ARect: TRect);
|
||||||
procedure DisplaySeries(ACanvas: TCanvas);
|
procedure DisplaySeries(ACanvas: TCanvas);
|
||||||
procedure DrawBackground(const ACanvas: TCanvas);
|
procedure DrawBackWall(ACanvas: TCanvas);
|
||||||
procedure DrawTitleFoot(ACanvas: TCanvas);
|
procedure DrawTitleFoot(ACanvas: TCanvas);
|
||||||
procedure MouseDown(
|
procedure MouseDown(
|
||||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
@ -288,8 +299,12 @@ type
|
|||||||
property Toolset: TBasicChartToolset read FToolset write SetToolset;
|
property Toolset: TBasicChartToolset read FToolset write SetToolset;
|
||||||
|
|
||||||
published
|
published
|
||||||
|
property OnAfterDrawBackWall: TChartAfterDrawEvent
|
||||||
|
read FOnAfterDrawBackWall write SetOnAfterDrawBackWall;
|
||||||
|
property OnBeforeDrawBackWall: TChartBeforeDrawEvent
|
||||||
|
read FOnBeforeDrawBackWall write SetOnBeforeDrawBackWall;
|
||||||
property OnDrawReticule: TDrawReticuleEvent
|
property OnDrawReticule: TDrawReticuleEvent
|
||||||
read FOnDrawReticule write FOnDrawReticule;
|
read FOnDrawReticule write SetOnDrawReticule;
|
||||||
|
|
||||||
published
|
published
|
||||||
property Align;
|
property Align;
|
||||||
@ -445,7 +460,7 @@ begin
|
|||||||
Unused(DC);
|
Unused(DC);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChart.GetAxis(AIndex: integer): TChartAxis;
|
function TChart.GetAxis(AIndex: Integer): TChartAxis;
|
||||||
begin
|
begin
|
||||||
Result := FAxisList.GetAxis(AIndex);
|
Result := FAxisList.GetAxis(AIndex);
|
||||||
end;
|
end;
|
||||||
@ -487,7 +502,7 @@ begin
|
|||||||
PrepareLegend(ACanvas, legendItems, FClipRect, legendRect);
|
PrepareLegend(ACanvas, legendItems, FClipRect, legendRect);
|
||||||
try
|
try
|
||||||
PrepareAxis(ACanvas);
|
PrepareAxis(ACanvas);
|
||||||
DrawBackground(ACanvas);
|
DrawBackWall(ACanvas);
|
||||||
DisplaySeries(ACanvas);
|
DisplaySeries(ACanvas);
|
||||||
if Legend.Visible then
|
if Legend.Visible then
|
||||||
Legend.Draw(ACanvas, legendItems, legendRect);
|
Legend.Draw(ACanvas, legendItems, legendRect);
|
||||||
@ -519,17 +534,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChart.DrawBackground(const ACanvas: TCanvas);
|
procedure TChart.DrawBackWall(ACanvas: TCanvas);
|
||||||
|
var
|
||||||
|
defaultDrawing: Boolean = true;
|
||||||
begin
|
begin
|
||||||
with ACanvas do begin
|
if Assigned(OnBeforeDrawBackWall) then
|
||||||
if FFrame.Visible then
|
OnBeforeDrawBackWall(Self, ACanvas, FClipRect, defaultDrawing);
|
||||||
Pen.Assign(FFrame)
|
if defaultDrawing then
|
||||||
else
|
with ACanvas do begin
|
||||||
Pen.Style := psClear;
|
if FFrame.Visible then
|
||||||
Brush.Color := BackColor;
|
Pen.Assign(FFrame)
|
||||||
with FClipRect do
|
else
|
||||||
Rectangle(Left, Top, Right + 1, Bottom + 1);
|
Pen.Style := psClear;
|
||||||
end;
|
Brush.Color := BackColor;
|
||||||
|
with FClipRect do
|
||||||
|
Rectangle(Left, Top, Right + 1, Bottom + 1);
|
||||||
|
end;
|
||||||
|
if Assigned(OnAfterDrawBackWall) then
|
||||||
|
OnAfterDrawBackWall(Self, ACanvas, FClipRect);
|
||||||
|
|
||||||
// Z axis
|
// Z axis
|
||||||
if Depth > 0 then
|
if Depth > 0 then
|
||||||
@ -944,6 +966,27 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChart.SetOnAfterDrawBackWall(AValue: TChartAfterDrawEvent);
|
||||||
|
begin
|
||||||
|
if FOnAfterDrawBackWall = AValue then exit;
|
||||||
|
FOnAfterDrawBackWall := AValue;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChart.SetOnBeforeDrawBackWall(AValue: TChartBeforeDrawEvent);
|
||||||
|
begin
|
||||||
|
if FOnBeforeDrawBackWall = AValue then exit;
|
||||||
|
FOnBeforeDrawBackWall := AValue;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChart.SetOnDrawReticule(AValue: TDrawReticuleEvent);
|
||||||
|
begin
|
||||||
|
if FOnDrawReticule = AValue then exit;
|
||||||
|
FOnDrawReticule := AValue;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChart.SetProportional(AValue: Boolean);
|
procedure TChart.SetProportional(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FProportional = AValue then exit;
|
if FProportional = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user