2
$Id: action.inc,v 1.2 2005/02/14 17:13:11 peter Exp $
3
This file is part of the Free Component Library (FCL)
4
Copyright (c) 1999-2000 by the Free Pascal development team
6
See the file COPYING.FPC, included in this distribution,
7
for details about the copyright.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
**********************************************************************}
15
{****************************************************************************}
16
{* TBasicActionLink *}
17
{****************************************************************************}
19
constructor TBasicActionLink.Create(AClient: TObject);
22
AssignClient(AClient);
26
procedure TBasicActionLink.AssignClient(AClient: TObject);
31
destructor TBasicActionLink.Destroy;
33
if FAction <> nil then
34
FAction.UnRegisterChanges(Self);
39
procedure TBasicActionLink.Change;
41
if Assigned(OnChange) then
46
function TBasicActionLink.Execute(AComponent: TComponent): Boolean;
48
FAction.ActionComponent := AComponent;
50
Result := FAction.Execute;
52
if FAction <> nil then
53
FAction.ActionComponent := nil;
58
procedure TBasicActionLink.SetAction(Value: TBasicAction);
60
if Value <> FAction then
62
if FAction <> nil then FAction.UnRegisterChanges(Self);
64
if Value <> nil then Value.RegisterChanges(Self);
69
function TBasicActionLink.IsOnExecuteLinked: Boolean;
75
procedure TBasicActionLink.SetOnExecute(Value: TNotifyEvent);
80
function TBasicActionLink.Update: Boolean;
82
Result := FAction.Update;
85
{****************************************************************************}
87
{****************************************************************************}
89
constructor TBasicAction.Create(AOwner: TComponent);
91
inherited Create(AOwner);
92
FClients := TList.Create;
96
destructor TBasicAction.Destroy;
99
while FClients.Count > 0 do
100
UnRegisterChanges(TBasicActionLink(FClients.Last));
105
function TBasicAction.HandlesTarget(Target: TObject): Boolean;
111
procedure TBasicAction.ExecuteTarget(Target: TObject);
116
procedure TBasicAction.UpdateTarget(Target: TObject);
121
function TBasicAction.Execute: Boolean;
123
if Assigned(FOnExecute) then
133
function TBasicAction.Update: Boolean;
135
if Assigned(FOnUpdate) then
145
procedure TBasicAction.SetOnExecute(Value: TNotifyEvent);
149
if (TMethod(Value).Code <> TMethod(OnExecute).Code) or
150
(TMethod(Value).Data <> TMethod(OnExecute).Data) then
152
for I := 0 to FClients.Count - 1 do
153
TBasicActionLink(FClients[I]).SetOnExecute(Value);
160
procedure TBasicAction.Change;
162
if Assigned(FOnChange) then
167
procedure TBasicAction.RegisterChanges(Value: TBasicActionLink);
169
Value.FAction := Self;
174
procedure TBasicAction.UnRegisterChanges(Value: TBasicActionLink);
178
for I := 0 to FClients.Count - 1 do
179
if TBasicActionLink(FClients[I]) = Value then
181
Value.FAction := nil;
190
Revision 1.2 2005/02/14 17:13:11 peter