mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 13:32:31 +02:00
lcl: add TActionListEnumerator class and TCustomActionList.GetEnumerator method
git-svn-id: trunk@22407 -
This commit is contained in:
parent
0690273f72
commit
c0db1937f5
@ -61,6 +61,19 @@ type
|
|||||||
|
|
||||||
TContainedActionClass = class of TContainedAction;
|
TContainedActionClass = class of TContainedAction;
|
||||||
|
|
||||||
|
{ TActionListEnumerator }
|
||||||
|
|
||||||
|
TActionListEnumerator = class
|
||||||
|
private
|
||||||
|
FList: TCustomActionList;
|
||||||
|
FPosition: Integer;
|
||||||
|
function GetCurrent: TContainedAction;
|
||||||
|
public
|
||||||
|
constructor Create(AList: TCustomActionList);
|
||||||
|
function MoveNext: Boolean;
|
||||||
|
property Current: TContainedAction read GetCurrent;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TCustomActionList }
|
{ TCustomActionList }
|
||||||
|
|
||||||
@ -96,13 +109,15 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function ActionByName(const ActionName: string): TContainedAction;
|
||||||
function ExecuteAction(Action: TBasicAction): Boolean; override;
|
function ExecuteAction(Action: TBasicAction): Boolean; override;
|
||||||
|
function GetEnumerator: TActionListEnumerator;
|
||||||
|
function IndexOfName(const ActionName: string): integer;
|
||||||
function IsShortCut(var Message: TLMKey): Boolean;
|
function IsShortCut(var Message: TLMKey): Boolean;
|
||||||
function UpdateAction(Action: TBasicAction): Boolean; override;
|
function UpdateAction(Action: TBasicAction): Boolean; override;
|
||||||
function IndexOfName(const ActionName: string): integer;
|
|
||||||
function ActionByName(const ActionName: string): TContainedAction;
|
property Actions[Index: Integer]: TContainedAction read GetAction write SetAction; default;
|
||||||
property Actions[Index: Integer]: TContainedAction
|
|
||||||
read GetAction write SetAction; default;
|
|
||||||
property ActionCount: Integer read GetActionCount;
|
property ActionCount: Integer read GetActionCount;
|
||||||
property Images: TCustomImageList read FImages write SetImages;
|
property Images: TCustomImageList read FImages write SetImages;
|
||||||
property State: TActionListState read FState write SetState default asNormal;
|
property State: TActionListState read FState write SetState default asNormal;
|
||||||
@ -333,12 +348,6 @@ begin
|
|||||||
raise Exception.Create(SInvalidActionCreation);
|
raise Exception.Create(SInvalidActionCreation);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Register;
|
|
||||||
begin
|
|
||||||
RegisterComponents('Standard',[TActionList]);
|
|
||||||
RegisterNoIcon([TAction]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$I containedaction.inc}
|
{$I containedaction.inc}
|
||||||
{$I customactionlist.inc}
|
{$I customactionlist.inc}
|
||||||
{$I actionlink.inc}
|
{$I actionlink.inc}
|
||||||
@ -346,6 +355,32 @@ end;
|
|||||||
{$I customaction.inc}
|
{$I customaction.inc}
|
||||||
{$I lclaction.inc}
|
{$I lclaction.inc}
|
||||||
|
|
||||||
|
{ TActionListEnumerator }
|
||||||
|
|
||||||
|
function TActionListEnumerator.GetCurrent: TContainedAction;
|
||||||
|
begin
|
||||||
|
Result := FList.Actions[FPosition];
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TActionListEnumerator.Create(AList: TCustomActionList);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FList := AList;
|
||||||
|
FPosition := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TActionListEnumerator.MoveNext: Boolean;
|
||||||
|
begin
|
||||||
|
inc(FPosition);
|
||||||
|
Result := FPosition < FList.ActionCount;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
RegisterComponents('Standard',[TActionList]);
|
||||||
|
RegisterNoIcon([TAction]);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
ApplicationActionComponent:=nil;
|
ApplicationActionComponent:=nil;
|
||||||
|
|
||||||
|
@ -161,6 +161,11 @@ begin
|
|||||||
if Assigned(FOnExecute) then FOnExecute(Action, Result);
|
if Assigned(FOnExecute) then FOnExecute(Action, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomActionList.GetEnumerator: TActionListEnumerator;
|
||||||
|
begin
|
||||||
|
Result := TActionListEnumerator.Create(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomActionList.UpdateAction(Action: TBasicAction): Boolean;
|
function TCustomActionList.UpdateAction(Action: TBasicAction): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
Loading…
Reference in New Issue
Block a user