mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +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(
|
||||
specialize TGenericChartMarks<TChartAxisBrush, TChartPen, TChartAxisFramePen>)
|
||||
private
|
||||
FListener: TListener;
|
||||
FSource: TCustomChartSource;
|
||||
function IsFormatStored: Boolean;
|
||||
procedure SetSource(const AValue: TCustomChartSource);
|
||||
procedure SetSource(AValue: TCustomChartSource);
|
||||
public
|
||||
constructor Create(AOwner: TCustomChart);
|
||||
destructor Destroy; override;
|
||||
published
|
||||
property Distance default 1;
|
||||
property Format stored IsFormatStored;
|
||||
@ -277,19 +279,30 @@ begin
|
||||
FDistance := 1;
|
||||
FFrame.Style := psClear;
|
||||
FLabelBrush.Style := bsClear;
|
||||
FListener := TListener.Create(@FSource, @StyleChanged);
|
||||
FStyle := smsValue;
|
||||
FFormat := SERIES_MARK_FORMATS[FStyle];
|
||||
end;
|
||||
|
||||
destructor TChartAxisMarks.Destroy;
|
||||
begin
|
||||
FListener.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TChartAxisMarks.IsFormatStored: Boolean;
|
||||
begin
|
||||
Result := FStyle <> smsValue;
|
||||
end;
|
||||
|
||||
procedure TChartAxisMarks.SetSource(const AValue: TCustomChartSource);
|
||||
procedure TChartAxisMarks.SetSource(AValue: TCustomChartSource);
|
||||
begin
|
||||
if FSource = AValue then exit;
|
||||
if FListener.IsListening then
|
||||
FSource.Broadcaster.Unsubscribe(FListener);
|
||||
FSource := AValue;
|
||||
if FSource <> nil then
|
||||
FSource.Broadcaster.Subscribe(FListener);
|
||||
StyleChanged(Self);
|
||||
end;
|
||||
|
||||
@ -302,8 +315,9 @@ begin
|
||||
FGrid.Assign(Grid);
|
||||
FInverted := Inverted;
|
||||
FTitle.Assign(Title);
|
||||
end;
|
||||
//inherited Assign(Source);
|
||||
end
|
||||
else
|
||||
inherited Assign(Source);
|
||||
end;
|
||||
|
||||
constructor TChartAxis.Create(ACollection: TCollection);
|
||||
|
Loading…
Reference in New Issue
Block a user