mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 03:01:42 +02:00
TAChart: Use listener to update chart after mark source changes
git-svn-id: trunk@24472 -
This commit is contained in:
parent
5b2e752e04
commit
10de772730
@ -84,11 +84,13 @@ type
|
|||||||
TChartAxisMarks = class(
|
TChartAxisMarks = class(
|
||||||
specialize TGenericChartMarks<TChartAxisBrush, TChartPen, TChartAxisFramePen>)
|
specialize TGenericChartMarks<TChartAxisBrush, TChartPen, TChartAxisFramePen>)
|
||||||
private
|
private
|
||||||
|
FListener: TListener;
|
||||||
FSource: TCustomChartSource;
|
FSource: TCustomChartSource;
|
||||||
function IsFormatStored: Boolean;
|
function IsFormatStored: Boolean;
|
||||||
procedure SetSource(const AValue: TCustomChartSource);
|
procedure SetSource(AValue: TCustomChartSource);
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TCustomChart);
|
constructor Create(AOwner: TCustomChart);
|
||||||
|
destructor Destroy; override;
|
||||||
published
|
published
|
||||||
property Distance default 1;
|
property Distance default 1;
|
||||||
property Format stored IsFormatStored;
|
property Format stored IsFormatStored;
|
||||||
@ -277,19 +279,30 @@ begin
|
|||||||
FDistance := 1;
|
FDistance := 1;
|
||||||
FFrame.Style := psClear;
|
FFrame.Style := psClear;
|
||||||
FLabelBrush.Style := bsClear;
|
FLabelBrush.Style := bsClear;
|
||||||
|
FListener := TListener.Create(@FSource, @StyleChanged);
|
||||||
FStyle := smsValue;
|
FStyle := smsValue;
|
||||||
FFormat := SERIES_MARK_FORMATS[FStyle];
|
FFormat := SERIES_MARK_FORMATS[FStyle];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TChartAxisMarks.Destroy;
|
||||||
|
begin
|
||||||
|
FListener.Free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
function TChartAxisMarks.IsFormatStored: Boolean;
|
function TChartAxisMarks.IsFormatStored: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := FStyle <> smsValue;
|
Result := FStyle <> smsValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartAxisMarks.SetSource(const AValue: TCustomChartSource);
|
procedure TChartAxisMarks.SetSource(AValue: TCustomChartSource);
|
||||||
begin
|
begin
|
||||||
if FSource = AValue then exit;
|
if FSource = AValue then exit;
|
||||||
|
if FListener.IsListening then
|
||||||
|
FSource.Broadcaster.Unsubscribe(FListener);
|
||||||
FSource := AValue;
|
FSource := AValue;
|
||||||
|
if FSource <> nil then
|
||||||
|
FSource.Broadcaster.Subscribe(FListener);
|
||||||
StyleChanged(Self);
|
StyleChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -302,8 +315,9 @@ begin
|
|||||||
FGrid.Assign(Grid);
|
FGrid.Assign(Grid);
|
||||||
FInverted := Inverted;
|
FInverted := Inverted;
|
||||||
FTitle.Assign(Title);
|
FTitle.Assign(Title);
|
||||||
end;
|
end
|
||||||
//inherited Assign(Source);
|
else
|
||||||
|
inherited Assign(Source);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TChartAxis.Create(ACollection: TCollection);
|
constructor TChartAxis.Create(ACollection: TCollection);
|
||||||
|
Loading…
Reference in New Issue
Block a user