mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 23:38:15 +02:00
converted IDE FileMenu to use menuintf
git-svn-id: trunk@7762 -
This commit is contained in:
parent
04627f89c3
commit
da84b52103
@ -84,6 +84,7 @@ type
|
||||
itmFileSaveAll: TIDEMenuCommand;
|
||||
itmFileClose: TIDEMenuCommand;
|
||||
itmFileCloseAll: TIDEMenuCommand;
|
||||
itmFileDirectories: TIDEMenuSection;
|
||||
itmFileCleanDirectory: TIDEMenuCommand;
|
||||
itmFileIDEStart: TIDEMenuSection;
|
||||
itmFileRestart: TIDEMenuCommand;
|
||||
|
@ -81,6 +81,20 @@ type
|
||||
OwningComponent: TComponent;
|
||||
|
||||
function CreateMenuSeparator : TMenuItem;
|
||||
{$IFDEF UseMenuIntf}
|
||||
procedure CreateMenuItem(Section: TIDEMenuSection;
|
||||
var MenuItem: TIDEMenuCommand;
|
||||
const MenuItemName, MenuItemCaption: String;
|
||||
const bmpName: String = '';
|
||||
mnuEnabled: Boolean = true);
|
||||
procedure CreateMenuSeparatorSection(ParentSection: TIDEMenuSection;
|
||||
var Section: TIDEMenuSection; const AName: String);
|
||||
procedure CreateMenuSubSection(ParentSection: TIDEMenuSection;
|
||||
var Section: TIDEMenuSection;
|
||||
const AName, ACaption: String);
|
||||
procedure CreateMainMenuItem(var Section: TIDEMenuSection;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
{$ELSE}
|
||||
procedure CreateMenuItem(MenuItemParent, MenuItem: TMenuItem;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
procedure CreateMenuItem(MenuItemParent, MenuItem: TMenuItem;
|
||||
@ -89,10 +103,6 @@ type
|
||||
procedure CreateMenuItem(MenuItemParent, MenuItem: TMenuItem;
|
||||
const MenuItemName, MenuItemCaption: String;
|
||||
const bmpName: String; mnuEnabled: Boolean);
|
||||
{$IFDEF UseMenuIntf}
|
||||
procedure CreateMainMenuItem(var Section: TIDEMenuSection;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
{$ELSE}
|
||||
procedure CreateMainMenuItem(MainMenu: TMainMenu; var MenuItem: TMenuItem;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
{$ENDIF}
|
||||
@ -277,6 +287,39 @@ begin
|
||||
Result.Caption := '-';
|
||||
end;
|
||||
|
||||
{$IFDEF UseMenuIntf}
|
||||
procedure TMainIDEBase.CreateMenuItem(Section: TIDEMenuSection;
|
||||
var MenuItem: TIDEMenuCommand; const MenuItemName, MenuItemCaption: String;
|
||||
const bmpName: String; mnuEnabled: Boolean);
|
||||
begin
|
||||
MenuItem:=RegisterIDEMenuCommand(Section.GetPath,MenuItemName,MenuItemCaption);
|
||||
MenuItem.Enabled:=mnuEnabled;
|
||||
if bmpName<>'' then
|
||||
MenuItem.Bitmap.LoadFromLazarusResource(bmpName);
|
||||
end;
|
||||
|
||||
procedure TMainIDEBase.CreateMenuSeparatorSection(
|
||||
ParentSection: TIDEMenuSection; var Section: TIDEMenuSection;
|
||||
const AName: String);
|
||||
begin
|
||||
Section:=RegisterIDEMenuSection(ParentSection.GetPath,AName);
|
||||
Section.ChildsAsSubMenu := false;
|
||||
end;
|
||||
|
||||
procedure TMainIDEBase.CreateMenuSubSection(ParentSection: TIDEMenuSection;
|
||||
var Section: TIDEMenuSection; const AName, ACaption: String);
|
||||
begin
|
||||
Section:=RegisterIDEMenuSection(ParentSection.GetPath,AName);
|
||||
Section.Caption:=ACaption;
|
||||
end;
|
||||
|
||||
procedure TMainIDEBase.CreateMainMenuItem(var Section: TIDEMenuSection;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
begin
|
||||
Section:=RegisterIDEMenuSection(MainIDEBar.mnuMain.GetPath,MenuItemName);
|
||||
Section.Caption := MenuItemCaption;
|
||||
end;
|
||||
{$ELSE}
|
||||
procedure TMainIDEBase.CreateMenuItem(MenuItemParent, MenuItem: TMenuItem;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
begin
|
||||
@ -304,14 +347,6 @@ begin
|
||||
MenuItemParent.Add(MenuItem);
|
||||
end;
|
||||
|
||||
{$IFDEF UseMenuIntf}
|
||||
procedure TMainIDEBase.CreateMainMenuItem(var Section: TIDEMenuSection;
|
||||
const MenuItemName, MenuItemCaption: String);
|
||||
begin
|
||||
Section:=RegisterIDEMenuSection(MainIDEBar.mnuMain.GetPath,MenuItemName);
|
||||
Section.Caption := MenuItemCaption;
|
||||
end;
|
||||
{$ELSE}
|
||||
procedure TMainIDEBase.CreateMainMenuItem(MainMenu: TMainMenu;
|
||||
var MenuItem: TMenuItem; const MenuItemName, MenuItemCaption: String);
|
||||
begin
|
||||
@ -362,35 +397,51 @@ end;
|
||||
|
||||
procedure TMainIDEBase.SetupFileMenu;
|
||||
var
|
||||
ParentMI: TMenuItem;
|
||||
ParentMI: {$IFDEF UseMenuIntf}TIDEMenuSection{$ELSE}TMenuItem{$ENDIF};
|
||||
begin
|
||||
ParentMI:=MainIDEBar.mnuFile;
|
||||
with MainIDEBar do begin
|
||||
{$IFDEF UseMenuIntf}
|
||||
CreateMenuSeparatorSection(ParentMI,itmFileNew,'itmFileNew');
|
||||
{$ENDIF}
|
||||
CreateMenuItem(ParentMI,itmFileNewUnit,'itmFileNewUnit',lisMenuNewUnit,'menu_new');
|
||||
CreateMenuItem(ParentMI,itmFileNewForm,'itmFileNewForm',lisMenuNewForm,'menu_new');
|
||||
CreateMenuItem(ParentMI,itmFileNewOther,'itmFileNewOther',lisMenuNewOther,'menu_new');
|
||||
|
||||
{$IFDEF UseMenuIntf}
|
||||
CreateMenuSeparatorSection(ParentMI,itmFileOpenSave,'itmFileOpenSave');
|
||||
{$ELSE}
|
||||
ParentMI.Add(CreateMenuSeparator);
|
||||
{$ENDIF}
|
||||
|
||||
CreateMenuItem(ParentMI,itmFileOpen,'itmFileOpen',lisMenuOpen,'menu_open');
|
||||
CreateMenuItem(ParentMI,itmFileRevert,'itmFileRevert',lisMenuRevert,'menu_undo');
|
||||
CreateMenuItem(ParentMI,itmFileRecentOpen,'itmFileRecentOpen',lisMenuOpenRecent,'');
|
||||
{$IFDEF UseMenuIntf}
|
||||
CreateMenuSubSection(ParentMI,itmFileRecentOpen,'itmFileRecentOpen',lisMenuOpenRecent);
|
||||
{$ELSE}
|
||||
CreateMenuItem(ParentMI,itmFileRecentOpen,'itmFileRecentOpen',lisMenuOpenRecent);
|
||||
{$ENDIF}
|
||||
CreateMenuItem(ParentMI,itmFileSave,'itmFileSave',lisMenuSave,'menu_save');
|
||||
CreateMenuItem(ParentMI,itmFileSaveAs,'itmFileSaveAs',lisMenuSaveAs,'menu_save');
|
||||
CreateMenuItem(ParentMI,itmFileSaveAll,'itmFileSaveAll',lisMenuSaveAll,'menu_save');
|
||||
CreateMenuItem(ParentMI,itmFileClose,'itmFileClose',lisMenuClose,'menu_close',false);
|
||||
CreateMenuItem(ParentMI,itmFileCloseAll,'itmFileCloseAll',lisMenuCloseAll,'',false);
|
||||
|
||||
{$IFDEF UseMenuIntf}
|
||||
CreateMenuSeparatorSection(ParentMI,itmFileDirectories,'itmFileDirectories');
|
||||
{$ELSE}
|
||||
ParentMI.Add(CreateMenuSeparator);
|
||||
{$ENDIF}
|
||||
|
||||
CreateMenuItem(ParentMI,itmFileCleanDirectory,'itmFileCleanDirectory',lisMenuCleanDirectory);
|
||||
|
||||
{$IFDEF UseMenuIntf}
|
||||
CreateMenuSeparatorSection(ParentMI,itmFileIDEStart,'itmFileIDEStart');
|
||||
{$ELSE}
|
||||
ParentMI.Add(CreateMenuSeparator);
|
||||
{$ENDIF}
|
||||
|
||||
CreateMenuItem(ParentMI,itmFileRestart,'itmFileRestart',lisMenuRestart);
|
||||
|
||||
ParentMI.Add(CreateMenuSeparator);
|
||||
|
||||
CreateMenuItem(ParentMI,itmFileQuit,'itmFileQuit',lisMenuQuit);
|
||||
end;
|
||||
end;
|
||||
|
@ -68,6 +68,7 @@ type
|
||||
FLastVisibleActive: boolean;
|
||||
procedure MenuItemClick(Sender: TObject);
|
||||
procedure MenuItemDestroy(Sender: TObject);
|
||||
procedure BitmapChange(Sender: TObject);
|
||||
protected
|
||||
function GetBitmap: TBitmap; virtual;
|
||||
function GetCaption: string; virtual;
|
||||
@ -373,6 +374,11 @@ begin
|
||||
FAutoFreeMenuItem:=false;
|
||||
end;
|
||||
|
||||
procedure TIDEMenuItem.BitmapChange(Sender: TObject);
|
||||
begin
|
||||
if MenuItem<>nil then MenuItem.Bitmap:=Bitmap;
|
||||
end;
|
||||
|
||||
procedure TIDEMenuItem.SetEnabled(const AValue: Boolean);
|
||||
begin
|
||||
if FEnabled=AValue then exit;
|
||||
@ -383,8 +389,10 @@ end;
|
||||
|
||||
function TIDEMenuItem.GetBitmap: TBitmap;
|
||||
begin
|
||||
if FBitmap=nil then
|
||||
if FBitmap=nil then begin
|
||||
FBitmap:=TBitmap.Create;
|
||||
FBitmap.OnChange:=@BitmapChange;
|
||||
end;
|
||||
FBitmap.Transparent:=True;
|
||||
Result:=FBitmap;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user