mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 21:36:27 +02:00
IDE: GetForm: prefer non designer form
This commit is contained in:
parent
c14e043e4a
commit
4829be3ad1
@ -2165,15 +2165,40 @@ function TIDEWindowCreatorList.GetForm(aFormName: string; AutoCreate: boolean;
|
|||||||
DisableAutoSizing: boolean): TCustomForm;
|
DisableAutoSizing: boolean): TCustomForm;
|
||||||
var
|
var
|
||||||
Item: TIDEWindowCreator;
|
Item: TIDEWindowCreator;
|
||||||
|
aForm: TCustomForm;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=Screen.FindForm(aFormName);
|
Result:=nil;
|
||||||
|
for i:=0 to Screen.CustomFormCount-1 do
|
||||||
|
begin
|
||||||
|
aForm:=Screen.CustomForms[i];
|
||||||
|
if not SameText(aForm.Name,aFormName) then continue;
|
||||||
|
if (Result=nil) or not (csDesigning in Result.ComponentState) then
|
||||||
|
Result:=aForm;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Item:=nil;
|
||||||
|
if (Result<>nil) and (csDesigning in Result.ComponentState) then
|
||||||
|
begin
|
||||||
|
if AutoCreate then
|
||||||
|
begin
|
||||||
|
Item:=FindWithName(aFormName);
|
||||||
|
if (Item<>nil) then begin
|
||||||
|
// there is designer for a form that can be autocreated
|
||||||
|
//debugln(['TIDEWindowCreatorList.GetForm ',DbgSName(Result),' Design=',csDesigning in Result.ComponentState,' Owner=',DbgSName(Result.Owner)]);
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
if Result<>nil then begin
|
if Result<>nil then begin
|
||||||
if DisableAutoSizing then
|
if DisableAutoSizing then
|
||||||
Result.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF};
|
Result.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF};
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if AutoCreate then begin
|
if AutoCreate then begin
|
||||||
Item:=FindWithName(aFormName);
|
if Item=nil then
|
||||||
|
Item:=FindWithName(aFormName);
|
||||||
if Item=nil then begin
|
if Item=nil then begin
|
||||||
debugln(['TIDEWindowCreatorList.GetForm no creator for ',aFormName]);
|
debugln(['TIDEWindowCreatorList.GetForm no creator for ',aFormName]);
|
||||||
exit;
|
exit;
|
||||||
|
@ -1521,9 +1521,9 @@ begin
|
|||||||
AMenuItem.Caption := AForm.Caption;
|
AMenuItem.Caption := AForm.Caption;
|
||||||
else // form
|
else // form
|
||||||
if EnvironmentOptions.Desktop.IDENameForDesignedFormList then
|
if EnvironmentOptions.Desktop.IDENameForDesignedFormList then
|
||||||
AMenuItem.Caption := AForm.Name
|
AMenuItem.Caption := AForm.Name+' - Designer'
|
||||||
else
|
else
|
||||||
AMenuItem.Caption := AForm.Caption;
|
AMenuItem.Caption := AForm.Caption+' - Designer';
|
||||||
end;
|
end;
|
||||||
AMenuItem.UserTag := {%H-}PtrUInt(AForm);
|
AMenuItem.UserTag := {%H-}PtrUInt(AForm);
|
||||||
end;
|
end;
|
||||||
@ -1531,9 +1531,23 @@ end;
|
|||||||
procedure TMainIDEBase.UpdateWindowMenu;
|
procedure TMainIDEBase.UpdateWindowMenu;
|
||||||
var
|
var
|
||||||
WindowsList: TFPList;
|
WindowsList: TFPList;
|
||||||
|
|
||||||
|
function CanBeAdded(aForm: TCustomForm): boolean;
|
||||||
|
begin
|
||||||
|
if WindowsList.IndexOf(AForm)>=0 then
|
||||||
|
exit(false);
|
||||||
|
if IDEDockMaster<>nil then
|
||||||
|
begin
|
||||||
|
Result:=IDEDockMaster.AddableInWindowMenu(AForm);
|
||||||
|
end else begin
|
||||||
|
Result:=(AForm.Parent=nil) and AForm.IsVisible;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
i, EditorIndex, ItemCountProject, ItemCountOther, IconInd: Integer;
|
i, EditorIndex, ItemCountProject, ItemCountOther, IconInd: Integer;
|
||||||
CurMenuItem: TIDEMenuItem;
|
CurMenuItem: TIDEMenuItem;
|
||||||
AForm: TForm;
|
AForm: TCustomForm;
|
||||||
EdList: TStringListUTF8Fast;
|
EdList: TStringListUTF8Fast;
|
||||||
se: TSourceEditor;
|
se: TSourceEditor;
|
||||||
P: TIDEPackage;
|
P: TIDEPackage;
|
||||||
@ -1557,35 +1571,30 @@ begin
|
|||||||
for i := 0 to Screen.FormCount-1 do begin
|
for i := 0 to Screen.FormCount-1 do begin
|
||||||
AForm := Screen.Forms[i];
|
AForm := Screen.Forms[i];
|
||||||
//debugln(['TMainIDEBase.UpdateWindowMenu ',DbgSName(AForm),' Vis=',AForm.IsVisible,' Des=',DbgSName(AForm.Designer)]);
|
//debugln(['TMainIDEBase.UpdateWindowMenu ',DbgSName(AForm),' Vis=',AForm.IsVisible,' Des=',DbgSName(AForm.Designer)]);
|
||||||
if (AForm=MainIDEBar) or (AForm=SplashForm) or IsFormDesign(AForm)
|
if (AForm=MainIDEBar) or (AForm=SplashForm) or IsFormDesign(AForm) then
|
||||||
or (WindowsList.IndexOf(AForm)>=0) then
|
|
||||||
continue;
|
continue;
|
||||||
if IDEDockMaster<>nil then
|
if not CanBeAdded(AForm) then continue;
|
||||||
begin
|
|
||||||
if not IDEDockMaster.AddableInWindowMenu(AForm) then continue;
|
|
||||||
end else begin
|
|
||||||
if (AForm.Parent<>nil) or not AForm.IsVisible then continue;
|
|
||||||
end;
|
|
||||||
WindowsList.Add(AForm);
|
WindowsList.Add(AForm);
|
||||||
end;
|
end;
|
||||||
// add designer forms and datamodule forms
|
// add designer forms and datamodule forms
|
||||||
for i := 0 to Screen.FormCount-1 do begin
|
for i := 0 to Screen.FormCount-1 do begin
|
||||||
AForm := Screen.Forms[i];
|
AForm := Screen.Forms[i];
|
||||||
if (AForm.Designer<>nil) and (WindowsList.IndexOf(AForm)<0) then
|
if (AForm.Designer<>nil) and CanBeAdded(AForm) then
|
||||||
WindowsList.Add(AForm);
|
WindowsList.Add(AForm);
|
||||||
end;
|
end;
|
||||||
// create menuitems for all windows
|
// create menuitems for all windows
|
||||||
for i := 0 to WindowsList.Count-1 do
|
for i := 0 to WindowsList.Count-1 do
|
||||||
begin
|
begin
|
||||||
IconInd := GetIconIndex(TWinControl(WindowsList[i]));
|
AForm:=TCustomForm(WindowsList[i]);
|
||||||
|
IconInd := GetIconIndex(AForm);
|
||||||
// in the 'bring to front' list
|
// in the 'bring to front' list
|
||||||
CurMenuItem := GetMenuItem(i, itmWindowLists);
|
CurMenuItem := GetMenuItem(i, itmWindowLists);
|
||||||
InitMenuItem(CurMenuItem, TCustomForm(WindowsList[i]), IconInd);
|
InitMenuItem(CurMenuItem, AForm, IconInd);
|
||||||
CurMenuItem.Checked := WindowMenuActiveForm = TCustomForm(WindowsList[i]);
|
CurMenuItem.Checked := WindowMenuActiveForm = AForm;
|
||||||
CurMenuItem.OnClick := @mnuWindowItemClick;
|
CurMenuItem.OnClick := @mnuWindowItemClick;
|
||||||
// in the 'center' list
|
// in the 'center' list
|
||||||
CurMenuItem := GetMenuItem(i, itmCenterWindowLists);
|
CurMenuItem := GetMenuItem(i, itmCenterWindowLists);
|
||||||
InitMenuItem(CurMenuItem, TCustomForm(WindowsList[i]), IconInd);
|
InitMenuItem(CurMenuItem, AForm, IconInd);
|
||||||
CurMenuItem.OnClick := @mnuCenterWindowItemClick;
|
CurMenuItem.OnClick := @mnuCenterWindowItemClick;
|
||||||
end;
|
end;
|
||||||
//create source page menuitems
|
//create source page menuitems
|
||||||
|
Loading…
Reference in New Issue
Block a user