mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 14:12:37 +02:00
129 lines
3.5 KiB
PHP
129 lines
3.5 KiB
PHP
// included by actnlist.pas
|
|
|
|
{
|
|
*****************************************************************************
|
|
* *
|
|
* This file is part of the Lazarus Component Library (LCL) *
|
|
* *
|
|
* See the file COPYING.LCL, included in this distribution, *
|
|
* for details about the copyright. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
* *
|
|
*****************************************************************************
|
|
}
|
|
|
|
|
|
{ TContainedAction }
|
|
|
|
destructor TContainedAction.Destroy;
|
|
begin
|
|
if ActionList <> nil then ActionList.RemoveAction(Self);
|
|
inherited Destroy;
|
|
end;
|
|
|
|
function TContainedAction.GetIndex: Integer;
|
|
begin
|
|
if ActionList <> nil then
|
|
Result := ActionList.FActions.IndexOf(Self) else
|
|
Result := -1;
|
|
end;
|
|
|
|
function TContainedAction.IsCategoryStored: Boolean;
|
|
begin
|
|
Result := True;//GetParentComponent <> ActionList;
|
|
end;
|
|
|
|
function TContainedAction.GetParentComponent: TComponent;
|
|
begin
|
|
if ActionList <> nil then
|
|
Result := ActionList else
|
|
Result := inherited GetParentComponent;
|
|
end;
|
|
|
|
function TContainedAction.HasParent: Boolean;
|
|
begin
|
|
if ActionList <> nil then
|
|
Result := True else
|
|
Result := inherited HasParent;
|
|
end;
|
|
|
|
procedure TContainedAction.ReadState(Reader: TReader);
|
|
begin
|
|
inherited ReadState(Reader);
|
|
if Reader.Parent is TCustomActionList then
|
|
ActionList := TCustomActionList(Reader.Parent);
|
|
end;
|
|
|
|
procedure TContainedAction.SetIndex(Value: Integer);
|
|
var
|
|
CurIndex, Count: Integer;
|
|
begin
|
|
CurIndex := GetIndex;
|
|
if CurIndex >= 0 then
|
|
begin
|
|
Count := ActionList.FActions.Count;
|
|
if Value < 0 then Value := 0;
|
|
if Value >= Count then Value := Count - 1;
|
|
if Value <> CurIndex then
|
|
begin
|
|
ActionList.FActions.Delete(CurIndex);
|
|
ActionList.FActions.Insert(Value, Self);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TContainedAction.SetCategory(const Value: string);
|
|
begin
|
|
if Value <> Category then
|
|
begin
|
|
FCategory := Value;
|
|
if ActionList <> nil then
|
|
ActionList.Change;
|
|
end;
|
|
end;
|
|
|
|
procedure TContainedAction.SetActionList(AActionList: TCustomActionList);
|
|
begin
|
|
if AActionList <> ActionList then
|
|
begin
|
|
if ActionList <> nil then ActionList.RemoveAction(Self);
|
|
if AActionList <> nil then AActionList.AddAction(Self);
|
|
end;
|
|
end;
|
|
|
|
procedure TContainedAction.SetParentComponent(AParent: TComponent);
|
|
begin
|
|
if not (csLoading in ComponentState) and (AParent is TCustomActionList) then
|
|
ActionList := TCustomActionList(AParent);
|
|
end;
|
|
|
|
procedure TContainedAction.Change;
|
|
begin
|
|
inherited Change;
|
|
end;
|
|
|
|
function TContainedAction.Execute: Boolean;
|
|
begin
|
|
Result := (ActionList <> nil) and ActionList.ExecuteAction(Self)
|
|
or Application.ExecuteAction(Self)
|
|
or inherited Execute;
|
|
// ToDo:
|
|
//or (SendAppMessage(CM_ACTIONEXECUTE, 0, Longint(Self)) = 1);
|
|
end;
|
|
|
|
function TContainedAction.Update: Boolean;
|
|
begin
|
|
Result := (ActionList <> nil)
|
|
and ActionList.UpdateAction(Self)
|
|
or Application.UpdateAction(Self)
|
|
or inherited Update;
|
|
// ToDo:
|
|
//or (SendAppMessage(CM_ACTIONUPDATE, 0, Longint(Self)) = 1);
|
|
end;
|
|
|
|
// included by actnlist.pas
|
|
|