IDE: Move method OpenFilePopupMenuPopup from MainIDE to MainIDEBar.

git-svn-id: trunk@49493 -
This commit is contained in:
juha 2015-07-02 18:50:35 +00:00
parent ce0d1dead7
commit 7edc951749
2 changed files with 60 additions and 55 deletions

View File

@ -385,7 +385,6 @@ type
procedure mnuPackageClicked(Sender: TObject); // package menu
// see pkgmanager.pas
procedure OpenFilePopupMenuPopup(Sender: TObject);
procedure mnuOpenFilePopupClick(Sender: TObject);
procedure SetBuildModePopupMenuPopup(Sender: TObject);
procedure mnuChgBuildModeClicked(Sender: TObject);
@ -1469,8 +1468,8 @@ begin
SetupStandardIDEMenuItems;
SetupMainMenu;
MainIDEBar.Setup(OwningComponent);
MainIDEBar.OpenFilePopupHandler := @mnuOpenFilePopupClick;
MainIDEBar.OptionsMenuItem.OnClick := @ToolBarOptionsClick;
MainIDEBar.OpenFilePopupMenu.OnPopup := @OpenFilePopupMenuPopup;
MainIDEBar.SetBuildModePopupMenu.OnPopup := @SetBuildModePopupMenuPopup;
ConnectMainBarEvents;
finally
@ -2691,9 +2690,7 @@ end;
procedure TMainIDE.SetupWindowsMenu;
begin
inherited SetupWindowsMenu;
with MainIDEBar do begin
itmWindowManager.OnClick := @mnuWindowManagerClicked;
end;
MainIDEBar.itmWindowManager.OnClick := @mnuWindowManagerClicked;
end;
procedure TMainIDE.SetupHelpMenu;
@ -3333,55 +3330,6 @@ end;
{------------------------------------------------------------------------------}
procedure TMainIDE.OpenFilePopupMenuPopup(Sender: TObject);
var
CurIndex: integer;
OpenMenuItem: TPopupMenu;
procedure AddFile(const Filename: string);
var
AMenuItem: TMenuItem;
begin
if MainIDEBar.OpenFilePopupMenu.Items.Count > CurIndex then
AMenuItem := MainIDEBar.OpenFilePopupMenu.Items[CurIndex]
else
begin
AMenuItem := TMenuItem.Create(OwningComponent);
AMenuItem.Name := MainIDEBar.OpenFilePopupMenu.Name + 'Recent' + IntToStr(CurIndex);
AMenuItem.OnClick := @mnuOpenFilePopupClick;
MainIDEBar.OpenFilePopupMenu.Items.Add(AMenuItem);
end;
AMenuItem.Caption := Filename;
inc(CurIndex);
end;
procedure AddFiles(List: TStringList; MaxCount: integer);
var
i: integer;
begin
i := 0;
while (i < List.Count) and (i < MaxCount) do
begin
AddFile(List[i]);
inc(i);
end;
end;
begin
// fill the PopupMenu:
CurIndex := 0;
// first add 8 recent projects
AddFiles(EnvironmentOptions.RecentProjectFiles, 8);
// add a separator
AddFile('-');
// add 12 recent files
AddFiles(EnvironmentOptions.RecentOpenFiles, 12);
OpenMenuItem := MainIDEBar.OpenFilePopupMenu;
// remove unused menuitems
while OpenMenuItem.Items.Count > CurIndex do
OpenMenuItem.Items[OpenMenuItem.Items.Count - 1].Free;
end;
procedure TMainIDE.mnuOpenFilePopupClick(Sender: TObject);
var
TheMenuItem: TMenuItem;

View File

@ -50,8 +50,10 @@ type
TMainIDEBar = class(TForm)
private
OptionsPopupMenu: TPopupMenu;
FMainOwningComponent: TComponent;
FOldWindowState: TWindowState;
FOnActive: TNotifyEvent;
FOpenFilePopupHandler: TNotifyEvent;
procedure CreatePopupMenus(TheOwner: TComponent);
procedure NewUnitFormDefaultClick(Sender: TObject);
procedure NewUnitFormPopupMenuPopup(Sender: TObject);
@ -381,12 +383,14 @@ type
procedure MainSplitterMoved(Sender: TObject);
procedure SetMainIDEHeightEvent(Sender: TObject);
procedure OnMainBarActive(Sender: TObject);
procedure OpenFilePopupMenuPopup(Sender: TObject);
procedure Setup(TheOwner: TComponent);
procedure SetupHints;
procedure UpdateIDEComponentPalette(IfFormChanged: boolean);
procedure HideIDE;
procedure UnhideIDE;
property OnActive: TNotifyEvent read FOnActive write FOnActive;
property OpenFilePopupHandler: TNotifyEvent read FOpenFilePopupHandler write FOpenFilePopupHandler;
procedure UpdateDockCaption({%H-}Exclude: TControl); override;
procedure RefreshCoolbar;
procedure SetMainIDEHeight;
@ -608,6 +612,57 @@ begin
end;
end;
procedure TMainIDEBar.OpenFilePopupMenuPopup(Sender: TObject);
var
CurIndex: integer;
OpenMenuItem: TPopupMenu;
procedure AddFile(const Filename: string);
var
AMenuItem: TMenuItem;
begin
if OpenFilePopupMenu.Items.Count > CurIndex then
AMenuItem := OpenFilePopupMenu.Items[CurIndex]
else
begin
Assert(Assigned(FMainOwningComponent));
AMenuItem := TMenuItem.Create(FMainOwningComponent);
AMenuItem.Name := OpenFilePopupMenu.Name + 'Recent' + IntToStr(CurIndex);
Assert(Assigned(OpenFilePopupHandler));
AMenuItem.OnClick := OpenFilePopupHandler; // mnuOpenFilePopupClick;
OpenFilePopupMenu.Items.Add(AMenuItem);
end;
AMenuItem.Caption := Filename;
inc(CurIndex);
end;
procedure AddFiles(List: TStringList; MaxCount: integer);
var
i: integer;
begin
i := 0;
while (i < List.Count) and (i < MaxCount) do
begin
AddFile(List[i]);
inc(i);
end;
end;
begin
// fill the PopupMenu:
CurIndex := 0;
// first add 8 recent projects
AddFiles(EnvironmentOptions.RecentProjectFiles, 8);
// add a separator
AddFile('-');
// add 12 recent files
AddFiles(EnvironmentOptions.RecentOpenFiles, 12);
OpenMenuItem := OpenFilePopupMenu;
// remove unused menuitems
while OpenMenuItem.Items.Count > CurIndex do
OpenMenuItem.Items[OpenMenuItem.Items.Count - 1].Free;
end;
procedure TMainIDEBar.WndProc(var Message: TLMessage);
begin
inherited WndProc(Message);
@ -675,6 +730,7 @@ end;
procedure TMainIDEBar.Setup(TheOwner: TComponent);
begin
FMainOwningComponent := TheOwner;
OnActive:=@OnMainBarActive;
MainSplitter := TSplitter.Create(TheOwner);
@ -700,12 +756,13 @@ begin
CoolBar.OnChange := @CoolBarOnChange;
CreatePopupMenus(TheOwner);
CoolBar.PopupMenu := OptionsPopupMenu;
OpenFilePopupMenu.OnPopup := @OpenFilePopupMenuPopup;
// Component palette
ComponentPageControl := TPageControl.Create(TheOwner);
ComponentPageControl.Name := 'ComponentPageControl';
ComponentPageControl.Align := alClient;
ComponentPageControl.Visible:=EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible;
ComponentPageControl.Visible := EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible;
ComponentPageControl.Parent := Self;
end;