TAChart: Add TLine.UseBounds property. Minor refactoring.

git-svn-id: trunk@20090 -
This commit is contained in:
ask 2009-05-21 07:48:50 +00:00
parent f0b1c740fd
commit ff15f8408c

View File

@ -278,11 +278,13 @@ type
private private
FPen: TPen; FPen: TPen;
FPosGraph: Double; // Graph coordinates of line FPosGraph: Double; // Graph coordinates of line
FStyle: TLineStyle; FLineStyle: TLineStyle;
FUseBounds: Boolean;
procedure SetLineStyle(AValue: TLineStyle);
procedure SetPen(AValue: TPen); procedure SetPen(AValue: TPen);
procedure SetPos(AValue: Double); procedure SetPos(AValue: Double);
procedure SetStyle(AValue: TLineStyle); procedure SetUseBounds(AValue: Boolean);
protected protected
function GetSeriesColor: TColor; override; function GetSeriesColor: TColor; override;
procedure SetSeriesColor(const AValue: TColor); override; procedure SetSeriesColor(const AValue: TColor); override;
@ -294,10 +296,12 @@ type
procedure Draw(ACanvas: TCanvas); override; procedure Draw(ACanvas: TCanvas); override;
published published
property LineStyle: TLineStyle read FStyle write SetStyle default lsHorizontal; property LineStyle: TLineStyle
read FLineStyle write SetLineStyle default lsHorizontal;
property Pen: TPen read FPen write SetPen; property Pen: TPen read FPen write SetPen;
property Position: Double read FPosGraph write SetPos; property Position: Double read FPosGraph write SetPos;
property SeriesColor; property SeriesColor;
property UseBounds: Boolean read FUseBounds write SetUseBounds default true;
end; end;
TFuncCalculateEvent = procedure (const AX: Double; out AY: Double) of object; TFuncCalculateEvent = procedure (const AX: Double; out AY: Double) of object;
@ -934,9 +938,10 @@ constructor TLine.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FLineStyle := lsHorizontal;
FPen := TPen.Create; FPen := TPen.Create;
FPen.OnChange := @StyleChanged; FPen.OnChange := @StyleChanged;
LineStyle := lsHorizontal; FUseBounds := true;
end; end;
destructor TLine.Destroy; destructor TLine.Destroy;
@ -945,20 +950,28 @@ begin
FPen.Free; FPen.Free;
end; end;
procedure TLine.SetLineStyle(AValue: TLineStyle);
begin
if FLineStyle = AValue then exit;
FLineStyle := AValue;
UpdateParentChart;
end;
procedure TLine.SetPen(AValue: TPen); procedure TLine.SetPen(AValue: TPen);
begin begin
FPen.Assign(AValue); FPen.Assign(AValue);
end; end;
procedure TLine.SetStyle(AValue: TLineStyle); procedure TLine.SetUseBounds(AValue: Boolean);
begin begin
if FStyle = AValue then exit; if FUseBounds = AValue then exit;
FStyle := AValue; FUseBounds := AValue;
UpdateParentChart; UpdateParentChart;
end; end;
procedure TLine.UpdateBounds(var ABounds: TDoubleRect); procedure TLine.UpdateBounds(var ABounds: TDoubleRect);
begin begin
if not UseBounds then exit;
case LineStyle of case LineStyle of
lsHorizontal: UpdateMinMax(FPosGraph, ABounds.a.Y, ABounds.b.Y); lsHorizontal: UpdateMinMax(FPosGraph, ABounds.a.Y, ABounds.b.Y);
lsVertical: UpdateMinMax(FPosGraph, ABounds.a.X, ABounds.b.X); lsVertical: UpdateMinMax(FPosGraph, ABounds.a.X, ABounds.b.X);