From d2928d98c7fccbda163428ac74011b9e65f9f0a9 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 26 Sep 2005 10:40:10 +0000 Subject: [PATCH] added menuintf register functions git-svn-id: trunk@7834 - --- ideintf/menuintf.pas | 61 ++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/ideintf/menuintf.pas b/ideintf/menuintf.pas index 04488e5f5d..61fac072a2 100644 --- a/ideintf/menuintf.pas +++ b/ideintf/menuintf.pas @@ -383,11 +383,24 @@ var function RegisterIDEMenuRoot(const Name: string; MenuItem: TMenuItem = nil ): TIDEMenuSection; +function RegisterIDEMenuSection(Parent: TIDEMenuSection; + const Name: string): TIDEMenuSection; function RegisterIDEMenuSection(const Path, Name: string): TIDEMenuSection; +function RegisterIDESubMenu(Parent: TIDEMenuSection; + const Name, Caption: string; + const OnClickMethod: TNotifyEvent = nil; + const OnClickProc: TNotifyProcedure = nil + ): TIDEMenuSection; function RegisterIDESubMenu(const Path, Name, Caption: string; const OnClickMethod: TNotifyEvent = nil; const OnClickProc: TNotifyProcedure = nil ): TIDEMenuSection; +function RegisterIDEMenuCommand(Parent: TIDEMenuSection; + const Name, Caption: string; + const OnClickMethod: TNotifyEvent = nil; + const OnClickProc: TNotifyProcedure = nil; + const Command: TIDECommand = nil + ): TIDEMenuCommand; function RegisterIDEMenuCommand(const Path, Name, Caption: string; const OnClickMethod: TNotifyEvent = nil; const OnClickProc: TNotifyProcedure = nil; @@ -399,24 +412,38 @@ implementation function RegisterIDEMenuRoot(const Name: string; MenuItem: TMenuItem ): TIDEMenuSection; begin - {$IFDEF VerboseMenuIntf} //debugln('RegisterIDEMenuRoot Name="',Name,'"'); - {$ENDIF} Result:=TIDEMenuSection.Create(Name); IDEMenuRoots.RegisterMenuRoot(Result); Result.MenuItem:=MenuItem; end; +function RegisterIDEMenuSection(Parent: TIDEMenuSection; const Name: string + ): TIDEMenuSection; +begin + Result:=TIDEMenuSection.Create(Name); + Result.ChildsAsSubMenu:=false; + Parent.AddLast(Result); +end; + function RegisterIDEMenuSection(const Path, Name: string): TIDEMenuSection; var Parent: TIDEMenuSection; begin - {$IFDEF VerboseMenuIntf} //debugln('RegisterIDEMenuSection Path="',Path,'" Name="',Name,'"'); - {$ENDIF} Parent:=IDEMenuRoots.FindByPath(Path,true) as TIDEMenuSection; + Result:=RegisterIDEMenuSection(Parent,Name); +end; + +function RegisterIDESubMenu(Parent: TIDEMenuSection; const Name, + Caption: string; const OnClickMethod: TNotifyEvent; + const OnClickProc: TNotifyProcedure): TIDEMenuSection; +begin Result:=TIDEMenuSection.Create(Name); - Result.ChildsAsSubMenu:=false; + Result.ChildsAsSubMenu:=true; + Result.Caption:=Caption; + Result.OnClick:=OnClickMethod; + Result.OnClickProc:=OnClickProc; Parent.AddLast(Result); end; @@ -426,15 +453,21 @@ function RegisterIDESubMenu(const Path, Name, Caption: string; var Parent: TIDEMenuSection; begin - {$IFDEF VerboseMenuIntf} //debugln('RegisterIDESubMenu Path="',Path,'" Name="',Name,'"'); - {$ENDIF} Parent:=IDEMenuRoots.FindByPath(Path,true) as TIDEMenuSection; - Result:=TIDEMenuSection.Create(Name); - Result.ChildsAsSubMenu:=true; + Result:=RegisterIDESubMenu(Parent,Name,Caption,OnClickMethod,OnClickProc); +end; + +function RegisterIDEMenuCommand(Parent: TIDEMenuSection; const Name, + Caption: string; const OnClickMethod: TNotifyEvent; + const OnClickProc: TNotifyProcedure; const Command: TIDECommand + ): TIDEMenuCommand; +begin + Result:=TIDEMenuCommand.Create(Name); Result.Caption:=Caption; Result.OnClick:=OnClickMethod; Result.OnClickProc:=OnClickProc; + Result.Command:=Command; Parent.AddLast(Result); end; @@ -444,16 +477,10 @@ function RegisterIDEMenuCommand(const Path, Name, Caption: string; var Parent: TIDEMenuSection; begin - {$IFDEF VerboseMenuIntf} //debugln('RegisterIDEMenuCommand Path="',Path,'" Name="',Name,'"'); - {$ENDIF} Parent:=IDEMenuRoots.FindByPath(Path,true) as TIDEMenuSection; - Result:=TIDEMenuCommand.Create(Name); - Result.Caption:=Caption; - Result.OnClick:=OnClickMethod; - Result.OnClickProc:=OnClickProc; - Result.Command:=Command; - Parent.AddLast(Result); + Result:=RegisterIDEMenuCommand(Parent,Name,Caption,OnClickMethod,OnClickProc, + Command); end; { TIDEMenuItem }