IDE: Group tabs in Window menu too

git-svn-id: trunk@36234 -
This commit is contained in:
martin 2012-03-23 01:29:14 +00:00
parent 59d651babf
commit dd081fe601
2 changed files with 96 additions and 22 deletions

View File

@ -57,7 +57,7 @@ uses
{$ENDIF} {$ENDIF}
Classes, LCLType, LCLProc, LCLIntf, StdCtrls, Buttons, Menus, ComCtrls, Classes, LCLType, LCLProc, LCLIntf, StdCtrls, Buttons, Menus, ComCtrls,
SysUtils, Controls, Graphics, ExtCtrls, Dialogs, FileUtil, Forms, SysUtils, Controls, Graphics, ExtCtrls, Dialogs, FileUtil, Forms,
CodeToolManager, CodeCache, AVL_Tree, SynEditKeyCmds, CodeToolManager, CodeCache, AVL_Tree, SynEditKeyCmds, PackageIntf,
// IDEIntf // IDEIntf
IDEImagesIntf, SrcEditorIntf, LazIDEIntf, MenuIntf, IDEImagesIntf, SrcEditorIntf, LazIDEIntf, MenuIntf,
IDECommands, IDEMsgIntf, IDEWindowIntf, IDECommands, IDEMsgIntf, IDEWindowIntf,
@ -784,6 +784,10 @@ begin
CreateMenuItem(ParentMI,itmWindowManager,'itmWindowManager', lisDlgEditorWindowManager, 'pkg_files'); CreateMenuItem(ParentMI,itmWindowManager,'itmWindowManager', lisDlgEditorWindowManager, 'pkg_files');
// Populated later with a list of editor names // Populated later with a list of editor names
CreateMenuSeparatorSection(mnuWindow,itmWindowLists,'itmWindowLists'); CreateMenuSeparatorSection(mnuWindow,itmWindowLists,'itmWindowLists');
CreateMenuSeparatorSection(mnuWindow,itmTabLists,'itmTabLists');
CreateMenuSubSection(mnuWindow,itmTabListProject,'itmTabListProject', dlgEnvProject);
CreateMenuSeparatorSection(mnuWindow, itmTabListPackage, 'itmTabListPackage');
CreateMenuSubSection(mnuWindow,itmTabListOther,'itmTabListOther', lisMEOther);
end; end;
end; end;
@ -1052,20 +1056,32 @@ procedure TMainIDEBase.UpdateWindowMenu(Immediately: boolean = false);
const const
UpdatePause = 5/864000; // half a second UpdatePause = 5/864000; // half a second
function GetMenuItem(Index: Integer): TIDEMenuItem; inline; function GetMenuItem(Index: Integer; ASection: TIDEMenuSection): TIDEMenuItem; inline;
begin begin
if itmWindowLists.Count > Index then if ASection.Count > Index then
Result := itmWindowLists.Items[Index] Result := ASection.Items[Index]
else else
Result := RegisterIDEMenuCommand(itmWindowLists.GetPath,'Window'+IntToStr(Index),''); Result := RegisterIDEMenuCommand(ASection.GetPath,'Window'+IntToStr(Index)+ASection.Name,'');
end;
procedure ClearMenuItem(ARemainCount: Integer; ASection: TIDEMenuSection); inline;
begin
with ASection do
while Count > ARemainCount do
Items[Count-1].Free;
end; end;
var var
WindowsList: TFPList; WindowsList: TFPList;
i, ItemCount: Integer; i, ItemCount, ItemCountProject, ItemCountOther: Integer;
CurMenuItem: TIDEMenuItem; CurMenuItem: TIDEMenuItem;
AForm: TForm; AForm: TForm;
t: TDateTime; t: TDateTime;
EdList: TStringList;
EditorCur: TSourceEditor;
P: TIDEPackage;
M: TIDEMenuSection;
s: String;
begin begin
t:=Now; t:=Now;
if (not Immediately) then begin if (not Immediately) then begin
@ -1106,36 +1122,90 @@ begin
ItemCount := WindowsList.Count; ItemCount := WindowsList.Count;
for i:=0 to WindowsList.Count-1 do for i:=0 to WindowsList.Count-1 do
begin begin
CurMenuItem := GetMenuItem(i); CurMenuItem := GetMenuItem(i, itmWindowLists);
CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption; CurMenuItem.Caption:=TCustomForm(WindowsList[i]).Caption;
CurMenuItem.MenuItem.Checked := Screen.ActiveCustomForm = TCustomForm(WindowsList[i]); CurMenuItem.MenuItem.Checked := Screen.ActiveCustomForm = TCustomForm(WindowsList[i]);
CurMenuItem.OnClick:=@mnuWindowItemClick; CurMenuItem.OnClick:=@mnuWindowItemClick;
end; end;
//create source page menuitems //create source page menuitems
itmTabListProject.Visible := False;
itmTabListOther.Visible := False;
itmTabListPackage.Clear;
if (SourceEditorManager.SourceWindowCount > 0) if SourceEditorManager.SourceEditorCount > 0 then begin
and not (nbcPageListPopup in SourceEditorManager.SourceWindows[0].GetCapabilities) then ItemCountProject := 0;
begin ItemCountOther := 0;
CurMenuItem := GetMenuItem(ItemCount); EdList := TStringList.Create;
CurMenuItem.OnClick:=nil; EdList.OwnsObjects := False;
CurMenuItem.Caption:='-'; EdList.Sorted := True;
inc(ItemCount); // sort
for i := 0 to SourceEditorManager.SourceEditorCount - 1 do for i := 0 to SourceEditorManager.SourceEditorCount - 1 do
EdList.AddObject(SourceEditorManager.SourceEditors[i].PageName+' '
+SourceEditorManager.SourceEditors[i].FileName
+SourceEditorManager.SourceEditors[i].Owner.Name,
SourceEditorManager.SourceEditors[i]);
for i := 0 to EdList.Count - 1 do
begin begin
CurMenuItem := GetMenuItem(ItemCount); EditorCur := TSourceEditor(EdList.Objects[i]);
CurMenuItem.Caption := SourceEditorManager.SourceEditors[i].PageName;
CurMenuItem.MenuItem.Checked := SourceEditorManager.ActiveEditor = SourceEditorManager.SourceEditors[i] ; if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then begin
M := itmTabListProject;
CurMenuItem := GetMenuItem(ItemCountProject, M);
inc(ItemCountProject);
end else begin
SourceEditorManager.OnPackageForSourceEditor(P, EditorCur);
if P <> nil then begin
s := Format(lisTabsFor, [p.Name]);
if itmTabListPackage.FindByName(S) is TIDEMenuSection then
M := TIDEMenuSection(itmTabListPackage.FindByName(S))
else
M := RegisterIDESubMenu(itmTabListPackage, S, S);
CurMenuItem := GetMenuItem(M.Count, M);
end else begin
M := itmTabListOther;
CurMenuItem := GetMenuItem(ItemCountOther, M);
inc(ItemCountOther);
end;
end;
M.Visible := True;
if EditorCur.SharedEditorCount > 1 then
CurMenuItem.Caption := EditorCur.PageName + ' ('+TForm(EditorCur.Owner).Caption+')'
//CurMenuItem.Caption := EditorCur.PageName
// + ' ('+IntToStr(1+SourceEditorManager.IndexOfSourceWindow(TSourceEditorWindowInterface(EditorCur.Owner)))+')'
else
CurMenuItem.Caption := EditorCur.PageName;
CurMenuItem.MenuItem.Checked := SourceEditorManager.ActiveEditor = EditorCur;
M.MenuItem.Checked := SourceEditorManager.ActiveEditor = EditorCur;
CurMenuItem.OnClick := @mnuWindowSourceItemClick; CurMenuItem.OnClick := @mnuWindowSourceItemClick;
CurMenuItem.Tag := i; CurMenuItem.Tag := i;
inc(ItemCount);
end; end;
EdList.Free;
ClearMenuItem(ItemCountProject, itmTabListProject);
ClearMenuItem(ItemCountOther, itmTabListOther);
for i := 0 to itmTabListPackage.Count - 1 do begin
if itmTabListPackage.Items[i] is TIDEMenuSection then begin
M := itmTabListPackage.Items[i] as TIDEMenuSection;
M.Caption := M.Caption + Format(' (%d)', [M.Count]);
end;
end;
itmTabListProject.Caption := dlgEnvProject + Format(' (%d)', [itmTabListProject.Count]);
itmTabListOther.Caption := lisMEOther + Format(' (%d)', [itmTabListOther.Count]);
if itmTabListPackage.TopSeparator <> nil then
itmTabListPackage.TopSeparator.Visible := False;
if itmTabListOther.TopSeparator <> nil then
itmTabListOther.TopSeparator.Visible := False;
end; end;
// remove unused menuitems // remove unused menuitems
with itmWindowLists do ClearMenuItem(ItemCount, itmWindowLists);
while Count > ItemCount do
Items[Count-1].Free;
// clean up // clean up
WindowsList.Free; WindowsList.Free;

View File

@ -370,6 +370,10 @@ var
mnuWindow: TIDEMenuSection; mnuWindow: TIDEMenuSection;
itmWindowManagers: TIDEMenuSection; itmWindowManagers: TIDEMenuSection;
itmWindowLists: TIDEMenuSection; itmWindowLists: TIDEMenuSection;
itmTabLists: TIDEMenuSection;
itmTabListProject: TIDEMenuSection;
itmTabListOther: TIDEMenuSection;
itmTabListPackage: TIDEMenuSection;
// help menu // help menu
mnuHelp: TIDEMenuSection; mnuHelp: TIDEMenuSection;