diff --git a/examples/anchordocking/design/registeranchordocking.pas b/examples/anchordocking/design/registeranchordocking.pas index 4828d6bbcb..0864b51191 100644 --- a/examples/anchordocking/design/registeranchordocking.pas +++ b/examples/anchordocking/design/registeranchordocking.pas @@ -64,6 +64,7 @@ type destructor Destroy; override; procedure MakeIDEWindowDockSite(AForm: TCustomForm); override; procedure MakeIDEWindowDockable(AControl: TWinControl); override; + function AddableInWindowMenu(AForm: TCustomForm): boolean; override; function GetDefaultLayoutFilename: string; procedure LoadDefaultLayout; procedure LoadUserLayout; @@ -175,6 +176,14 @@ begin DockMaster.MakeDockable(AControl,false); end; +function TIDEAnchorDockMaster.AddableInWindowMenu(AForm: TCustomForm): boolean; +begin + Result:=false; + if AForm is TAnchorDockHostSite then exit; + if (DockMaster.FindControl(AForm.Name)=nil) and (AForm.Parent<>nil) then exit; + Result:=true; +end; + function TIDEAnchorDockMaster.GetDefaultLayoutFilename: string; begin Result:=AppendPathDelim(LazarusIDE.GetPrimaryConfigPath)+DefaultConfigFileName; diff --git a/ide/mainbase.pas b/ide/mainbase.pas index bcbeae166b..b574d7a1e3 100644 --- a/ide/mainbase.pas +++ b/ide/mainbase.pas @@ -61,7 +61,7 @@ uses CodeToolManager, CodeCache, AVL_Tree, SynEditKeyCmds, // IDEIntf LazConf, LazarusIDEStrConsts, SrcEditorIntf, LazIDEIntf, MenuIntf, - IDECommands, IDEMsgIntf, + IDECommands, IDEMsgIntf, IDEWindowIntf, // IDE ProjectDefs, Project, PublishModule, BuildLazDialog, Compiler, ComponentReg, OutputFilter, @@ -209,8 +209,7 @@ begin while (i>=0) do begin if Screen.CustomForms[i].Caption=(Sender as TIDEMenuCommand).Caption then begin - Screen.CustomForms[i].Show; - Screen.CustomForms[i].BringToFront; + IDEWindowCreators.ShowForm(Screen.CustomForms[i],true); break; end; dec(i); @@ -1048,10 +1047,17 @@ begin // add special IDE windows for i:=0 to Screen.FormCount-1 do begin AForm:=Screen.Forms[i]; - if (AForm.Parent=nil) and (AForm<>MainIDEBar) and (AForm<>SplashForm) - and (AForm.Designer=nil) and (AForm.Visible) - and (WindowsList.IndexOf(AForm)<0) then - WindowsList.Add(AForm); + //debugln(['TMainIDEBase.UpdateWindowMenu ',DbgSName(AForm),' Vis=',AForm.IsVisible,' Des=',DbgSName(AForm.Designer)]); + if (not AForm.IsVisible) or (AForm=MainIDEBar) or (AForm=SplashForm) + or (AForm.Designer<>nil) or (WindowsList.IndexOf(AForm)>=0) then + continue; + if IDEDockMaster<>nil then + begin + if not IDEDockMaster.AddableInWindowMenu(AForm) then continue; + end else begin + if AForm.Parent<>nil then continue; + end; + WindowsList.Add(AForm); end; // add designer forms and datamodule forms for i:=0 to Screen.FormCount-1 do begin diff --git a/ideintf/idewindowintf.pas b/ideintf/idewindowintf.pas index 6eca89ae9c..10d3d2d646 100644 --- a/ideintf/idewindowintf.pas +++ b/ideintf/idewindowintf.pas @@ -343,6 +343,7 @@ type procedure MakeIDEWindowDockable(AControl: TWinControl); virtual; abstract; // make AControl dockable, it can be docked and other dockable windows can be docked to it, this does not make it visible procedure MakeIDEWindowDockSite(AForm: TCustomForm); virtual; abstract; // make AForm a dock site, AForm can not be docked, its Parent must be kept nil, this does not make it visible procedure ShowForm(AForm: TCustomForm; BringToFront: boolean); virtual; abstract; // make a form visible, set BringToFront=true if form should be shown on active screen and on front of other windows, normally this focus the form + function AddableInWindowMenu(AForm: TCustomForm): boolean; virtual; procedure CloseAll; virtual; // close all forms, called after IDE has saved all and shuts down end; @@ -1479,6 +1480,11 @@ end; { TIDEDockMaster } +function TIDEDockMaster.AddableInWindowMenu(AForm: TCustomForm): boolean; +begin + Result:=true; +end; + procedure TIDEDockMaster.CloseAll; begin CloseAllForms;