IDEIntf: started TIDEWindowCreator for registering independent/dockable windows

git-svn-id: trunk@25597 -
This commit is contained in:
mattias 2010-05-24 00:58:44 +00:00
parent af0490ba94
commit 160b52476f
9 changed files with 439 additions and 185 deletions

View File

@ -45,6 +45,9 @@ uses
ComponentPalette, ComponentReg, PackageDefs, ExtDlgs, FormEditor, PropEdits, ComponentPalette, ComponentReg, PackageDefs, ExtDlgs, FormEditor, PropEdits,
LCLType, Menus, ButtonPanel, IDEWindowIntf; LCLType, Menus, ButtonPanel, IDEWindowIntf;
const
ComponentListFormName = 'ComponentList';
type type
{ TComponentListForm } { TComponentListForm }

View File

@ -200,7 +200,7 @@ type
var var
FPDocEditor: TFPDocEditor = nil; FPDocEditor: TFPDocEditor = nil;
procedure DoShowFPDocEditor; procedure DoShowFPDocEditor(Show: boolean);
implementation implementation
@ -208,18 +208,19 @@ implementation
{ TFPDocEditor } { TFPDocEditor }
procedure DoShowFPDocEditor; procedure DoShowFPDocEditor(Show: boolean);
begin begin
if FPDocEditor = Nil then begin if FPDocEditor = Nil then
Application.CreateForm(TFPDocEditor, FPDocEditor); Application.CreateForm(TFPDocEditor, FPDocEditor);
EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwFPDocEditorName).Apply;
end;
if not FPDocEditor.Visible then if Show then
begin
EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwFPDocEditorName).Apply;
FPDocEditor.DoEditorUpdate(SourceEditorManagerIntf.ActiveEditor);
FPDocEditor.UpdateButtons; FPDocEditor.UpdateButtons;
FPDocEditor.DoEditorUpdate(SourceEditorManagerIntf.ActiveEditor); FPDocEditor.Show;
FPDocEditor.Show; FPDocEditor.MakeFullyVisible;
FPDocEditor.MakeFullyVisible; end;
end; end;
function TFPDocEditor.GetFirstElement: TDOMNode; function TFPDocEditor.GetFirstElement: TDOMNode;

View File

@ -103,7 +103,7 @@ type
const const
// This is the list of IDE windows, that will not be automatically reopened // This is the list of IDE windows, that will not be automatically reopened
// on startup. // on startup. These windows are opened automatically when needed.
NonModalIDEWindowManualOpen = [ NonModalIDEWindowManualOpen = [
nmiwNone, nmiwNone,
nmiwMainIDEName, nmiwMainIDEName,

View File

@ -638,7 +638,8 @@ type
procedure SetupIDEMsgQuickFixItems; procedure SetupIDEMsgQuickFixItems;
procedure SetupStartProject; procedure SetupStartProject;
procedure SetupRemoteControl; procedure SetupRemoteControl;
procedure ReOpenIDEWindows; procedure SetupIDEWindowsLayout;
procedure RestoreIDEWindows;
procedure CloseIDEWindows; procedure CloseIDEWindows;
procedure FreeIDEWindows; procedure FreeIDEWindows;
function CloseQueryIDEWindows: boolean; function CloseQueryIDEWindows: boolean;
@ -798,13 +799,15 @@ type
function DoRevertMainUnit: TModalResult; function DoRevertMainUnit: TModalResult;
function DoViewUnitsAndForms(OnlyForms: boolean): TModalResult; function DoViewUnitsAndForms(OnlyForms: boolean): TModalResult;
function DoSelectFrame: TComponentClass; function DoSelectFrame: TComponentClass;
procedure DoViewUnitDependencies; procedure DoViewUnitDependencies(Show: boolean);
procedure DoViewJumpHistory(Show: boolean);
procedure DoViewUnitInfo; procedure DoViewUnitInfo;
procedure DoShowCodeExplorer; procedure DoShowCodeExplorer(Show: boolean);
procedure DoShowCodeBrowser; procedure DoShowCodeBrowser(Show: boolean);
procedure DoShowRestrictionBrowser(const RestrictedName: String = ''); procedure DoShowRestrictionBrowser(Show: boolean; const RestrictedName: String = '');
procedure DoShowComponentList; procedure DoShowComponentList(Show: boolean);
procedure DoShowFPDocEditor; procedure CreateIDEWindow(Sender: TObject; aFormName: string;
var AForm: TCustomForm);
function CreateNewUniqueFilename(const Prefix, Ext: string; function CreateNewUniqueFilename(const Prefix, Ext: string;
NewOwner: TObject; Flags: TSearchIDEFileFlags; TryWithoutNumber: boolean NewOwner: TObject; Flags: TSearchIDEFileFlags; TryWithoutNumber: boolean
): string; override; ): string; override;
@ -823,7 +826,7 @@ type
function DoPublishProject(Flags: TSaveFlags; function DoPublishProject(Flags: TSaveFlags;
ShowDialog: boolean): TModalResult; override; ShowDialog: boolean): TModalResult; override;
function DoImExportCompilerOptions(Sender: TObject; out ImportExportResult: TImportExportOptionsResult): TModalResult; override; function DoImExportCompilerOptions(Sender: TObject; out ImportExportResult: TImportExportOptionsResult): TModalResult; override;
function DoShowProjectInspector: TModalResult; override; procedure DoShowProjectInspector(Show: boolean); override;
function DoAddActiveUnitToProject: TModalResult; function DoAddActiveUnitToProject: TModalResult;
function DoRemoveFromProjectDialog: TModalResult; function DoRemoveFromProjectDialog: TModalResult;
function DoWarnAmbiguousFiles: TModalResult; function DoWarnAmbiguousFiles: TModalResult;
@ -1012,7 +1015,7 @@ type
// search results // search results
function DoJumpToSearchResult(FocusEditor: boolean): boolean; function DoJumpToSearchResult(FocusEditor: boolean): boolean;
procedure DoShowSearchResultsView; procedure DoShowSearchResultsView(Show: boolean);
// form editor and designer // form editor and designer
procedure DoBringToFrontFormOrUnit; procedure DoBringToFrontFormOrUnit;
@ -1025,7 +1028,7 @@ type
procedure InvalidateAllDesignerForms; procedure InvalidateAllDesignerForms;
procedure UpdateIDEComponentPalette; procedure UpdateIDEComponentPalette;
procedure ShowDesignerForm(AForm: TCustomForm); procedure ShowDesignerForm(AForm: TCustomForm);
procedure DoViewAnchorEditor; procedure DoViewAnchorEditor(Show: boolean);
procedure DoToggleViewComponentPalette; procedure DoToggleViewComponentPalette;
procedure DoToggleViewIDESpeedButtons; procedure DoToggleViewIDESpeedButtons;
@ -1257,6 +1260,7 @@ end;
constructor TMainIDE.Create(TheOwner: TComponent); constructor TMainIDE.Create(TheOwner: TComponent);
var var
Layout: TSimpleWindowLayout; Layout: TSimpleWindowLayout;
FormCreator: TIDEWindowCreator;
begin begin
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Create START');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Create START');{$ENDIF}
inherited Create(TheOwner); inherited Create(TheOwner);
@ -1299,14 +1303,17 @@ begin
// build and position the MainIDE form // build and position the MainIDE form
Application.CreateForm(TMainIDEBar,MainIDEBar); Application.CreateForm(TMainIDEBar,MainIDEBar);
MainIDEBar.OnDestroy:=@OnMainBarDestroy; MainIDEBar.OnDestroy:=@OnMainBarDestroy;
{$IFNDEF IDEDocking}
MainIDEBar.Constraints.MaxHeight:=110; MainIDEBar.Constraints.MaxHeight:=110;
{$ENDIF}
MainIDEBar.Name := NonModalIDEWindowNames[nmiwMainIDEName]; MainIDEBar.Name := NonModalIDEWindowNames[nmiwMainIDEName];
FormCreator:=IDEWindowCreators.Add(MainIDEBar.Name);
FormCreator.Width:='100%';
FormCreator.Height:='90';
Layout:=EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwMainIDEName); Layout:=EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwMainIDEName);
if not (Layout.WindowState in [iwsNormal,iwsMaximized]) then if not (Layout.WindowState in [iwsNormal,iwsMaximized]) then
Layout.WindowState:=iwsNormal; Layout.WindowState:=iwsNormal;
EnvironmentOptions.IDEWindowLayoutList.Apply(MainIDEBar,MainIDEBar.Name); EnvironmentOptions.IDEWindowLayoutList.Apply(MainIDEBar,MainIDEBar.Name);
HiddenWindowsOnRun:=TList.Create; HiddenWindowsOnRun:=TList.Create;
// menu // menu
@ -1373,11 +1380,13 @@ begin
Screen.AddHandlerRemoveForm(@OnScreenRemoveForm); Screen.AddHandlerRemoveForm(@OnScreenRemoveForm);
SetupHints; SetupHints;
SetupIDEWindowsLayout;
RestoreIDEWindows;
// Now load a project // Now load a project
SetupStartProject; SetupStartProject;
// reopen extra windows // reopen extra windows
ReOpenIDEWindows;
DoShowMessagesView; DoShowMessagesView;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.StartIDE END');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.StartIDE END');{$ENDIF}
end; end;
@ -1497,16 +1506,16 @@ begin
if ObjectInspector1.GetActivePropertyRow = nil then if ObjectInspector1.GetActivePropertyRow = nil then
begin begin
if C <> nil then if C <> nil then
DoShowRestrictionBrowser(C.ClassName) DoShowRestrictionBrowser(true,C.ClassName)
else else
DoShowRestrictionBrowser; DoShowRestrictionBrowser(true);
end end
else else
begin begin
if C <> nil then if C <> nil then
DoShowRestrictionBrowser(C.ClassName + '.' + ObjectInspector1.GetActivePropertyRow.Name) DoShowRestrictionBrowser(true,C.ClassName + '.' + ObjectInspector1.GetActivePropertyRow.Name)
else else
DoShowRestrictionBrowser; DoShowRestrictionBrowser(true);
end; end;
end; end;
@ -1884,27 +1893,6 @@ end;
procedure TMainIDE.SetupObjectInspector; procedure TMainIDE.SetupObjectInspector;
begin begin
ObjectInspector1 := TObjectInspectorDlg.Create(OwningComponent);
ObjectInspector1.BorderStyle:=bsSizeable;
ObjectInspector1.ShowFavorites:=True;
ObjectInspector1.ShowRestricted:=True;
ObjectInspector1.Favourites:=LoadOIFavouriteProperties;
ObjectInspector1.FindDeclarationPopupmenuItem.Visible:=true;
ObjectInspector1.OnAddToFavourites:=@OIOnAddToFavourites;
ObjectInspector1.OnFindDeclarationOfProperty:=@OIOnFindDeclarationOfProperty;
ObjectInspector1.OnUpdateRestricted := @OIOnUpdateRestricted;
ObjectInspector1.OnRemainingKeyDown:=@OIRemainingKeyDown;
ObjectInspector1.OnRemoveFromFavourites:=@OIOnRemoveFromFavourites;
ObjectInspector1.OnSelectPersistentsInOI:=@OIOnSelectPersistents;
ObjectInspector1.OnShowOptions:=@OIOnShowOptions;
ObjectInspector1.OnViewRestricted:=@OIOnViewRestricted;
ObjectInspector1.OnSelectionChange:=@OIOnSelectionChange;
ObjectInspector1.OnPropertyHint:=@OIOnPropertyHint;
ObjectInspector1.OnDestroy:=@OIOnDestroy;
MakeIDEWindowDockable(ObjectInspector1);
IDECmdScopeObjectInspectorOnly.AddWindowClass(TObjectInspectorDlg);
GlobalDesignHook:=TPropertyEditorHook.Create; GlobalDesignHook:=TPropertyEditorHook.Create;
GlobalDesignHook.GetPrivateDirectory:=AppendPathDelim(GetPrimaryConfigPath); GlobalDesignHook.GetPrivateDirectory:=AppendPathDelim(GetPrimaryConfigPath);
GlobalDesignHook.AddHandlerGetMethodName(@OnPropHookGetMethodName); GlobalDesignHook.AddHandlerGetMethodName(@OnPropHookGetMethodName);
@ -1923,7 +1911,31 @@ begin
GlobalDesignHook.AddHandlerGetComponentNames(@OnPropHookGetComponentNames); GlobalDesignHook.AddHandlerGetComponentNames(@OnPropHookGetComponentNames);
GlobalDesignHook.AddHandlerGetComponent(@OnPropHookGetComponent); GlobalDesignHook.AddHandlerGetComponent(@OnPropHookGetComponent);
IDECmdScopeObjectInspectorOnly.AddWindowClass(TObjectInspectorDlg);
ObjectInspector1 := TObjectInspectorDlg.Create(OwningComponent);
ObjectInspector1.Name:=DefaultObjectInspectorName;
ObjectInspector1.BorderStyle:=bsSizeable;
ObjectInspector1.ShowFavorites:=True;
ObjectInspector1.ShowRestricted:=True;
ObjectInspector1.Favourites:=LoadOIFavouriteProperties;
ObjectInspector1.FindDeclarationPopupmenuItem.Visible:=true;
ObjectInspector1.OnAddToFavourites:=@OIOnAddToFavourites;
ObjectInspector1.OnFindDeclarationOfProperty:=@OIOnFindDeclarationOfProperty;
ObjectInspector1.OnUpdateRestricted := @OIOnUpdateRestricted;
ObjectInspector1.OnRemainingKeyDown:=@OIRemainingKeyDown;
ObjectInspector1.OnRemoveFromFavourites:=@OIOnRemoveFromFavourites;
ObjectInspector1.OnSelectPersistentsInOI:=@OIOnSelectPersistents;
ObjectInspector1.OnShowOptions:=@OIOnShowOptions;
ObjectInspector1.OnViewRestricted:=@OIOnViewRestricted;
ObjectInspector1.OnSelectionChange:=@OIOnSelectionChange;
ObjectInspector1.OnPropertyHint:=@OIOnPropertyHint;
ObjectInspector1.OnDestroy:=@OIOnDestroy;
ObjectInspector1.PropertyEditorHook:=GlobalDesignHook; ObjectInspector1.PropertyEditorHook:=GlobalDesignHook;
IDEWindowCreators.Add(ObjectInspector1.Name,nil,'0','125','230','80%',
NonModalIDEWindowNames[nmiwSourceNoteBookName],alLeft);
MakeIDEWindowDockable(ObjectInspector1);
EnvironmentOptions.IDEWindowLayoutList.Apply(ObjectInspector1, EnvironmentOptions.IDEWindowLayoutList.Apply(ObjectInspector1,
DefaultObjectInspectorName); DefaultObjectInspectorName);
with EnvironmentOptions do begin with EnvironmentOptions do begin
@ -2172,12 +2184,49 @@ begin
FRemoteControlTimer.Enabled:=true; FRemoteControlTimer.Enabled:=true;
end; end;
procedure TMainIDE.ReOpenIDEWindows; procedure TMainIDE.SetupIDEWindowsLayout;
begin
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwCodeExplorerName],
@CreateIDEWindow,
'72%','130','170','70%',NonModalIDEWindowNames[nmiwSourceNoteBookName],alRight);
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwMessagesViewName],
@CreateIDEWindow,
'230','75%','70%','100',NonModalIDEWindowNames[nmiwSourceNoteBookName],alBottom);
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwUnitDependenciesName],
@CreateIDEWindow,'200','200','','');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwFPDocEditorName],
@CreateIDEWindow,'250','75%','70%','120');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwClipbrdHistoryName],
@CreateIDEWindow,'250','200','','');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwProjectInspector],
@CreateIDEWindow,'200','150','300','400');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwSearchResultsViewName],
@CreateIDEWindow,'250','250','70%','300');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwAnchorEditor],
@CreateIDEWindow,'250','250','','');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwCodeBrowser],
@CreateIDEWindow,'200','200','650','500');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwIssueBrowser],
@CreateIDEWindow,'250','250','','');
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwJumpHistory],
@CreateIDEWindow,'250','250','','');
IDEWindowCreators.Add(ComponentListFormName,
@CreateIDEWindow,'250','250','','');
end;
procedure TMainIDE.RestoreIDEWindows;
var var
i: Integer; i: Integer;
ALayout: TSimpleWindowLayout; ALayout: TSimpleWindowLayout;
FormEnum: TNonModalIDEWindow; FormEnum: TNonModalIDEWindow;
begin begin
if IDEDockMaster<>nil then
begin
IDEDockMaster.LoadDefaultLayout;
exit;
end;
for i:=0 to EnvironmentOptions.IDEWindowLayoutList.Count-1 do begin for i:=0 to EnvironmentOptions.IDEWindowLayoutList.Count-1 do begin
ALayout:=EnvironmentOptions.IDEWindowLayoutList[i]; ALayout:=EnvironmentOptions.IDEWindowLayoutList[i];
if not ALayout.Visible then continue; if not ALayout.Visible then continue;
@ -2185,17 +2234,17 @@ begin
if FormEnum in NonModalIDEWindowManualOpen then continue; if FormEnum in NonModalIDEWindowManualOpen then continue;
case FormEnum of case FormEnum of
nmiwUnitDependenciesName: nmiwUnitDependenciesName:
DoViewUnitDependencies; DoViewUnitDependencies(true);
nmiwProjectInspector: nmiwProjectInspector:
DoShowProjectInspector; DoShowProjectInspector(true);
nmiwCodeBrowser: nmiwCodeBrowser:
DoShowCodeBrowser; DoShowCodeBrowser(true);
nmiwCodeExplorerName: nmiwCodeExplorerName:
DoShowCodeExplorer; DoShowCodeExplorer(true);
nmiwFPDocEditorName: nmiwFPDocEditorName:
DoShowFPDocEditor; DoShowFPDocEditor(true);
nmiwAnchorEditor: nmiwAnchorEditor:
DoViewAnchorEditor; DoViewAnchorEditor(true);
nmiwMessagesViewName: nmiwMessagesViewName:
DoShowMessagesView; DoShowMessagesView;
nmiwDbgOutput: nmiwDbgOutput:
@ -2573,7 +2622,7 @@ end;
procedure TMainIDE.mnuViewAnchorEditorClicked(Sender: TObject); procedure TMainIDE.mnuViewAnchorEditorClicked(Sender: TObject);
begin begin
DoViewAnchorEditor; DoViewAnchorEditor(true);
end; end;
procedure TMainIDE.mnuViewComponentPaletteClicked(Sender: TObject); procedure TMainIDE.mnuViewComponentPaletteClicked(Sender: TObject);
@ -3026,19 +3075,19 @@ begin
MessagesView.EnsureVisible; MessagesView.EnsureVisible;
ecToggleCodeExpl: ecToggleCodeExpl:
DoShowCodeExplorer; DoShowCodeExplorer(true);
ecToggleCodeBrowser: ecToggleCodeBrowser:
DoShowCodeBrowser; DoShowCodeBrowser(true);
ecToggleRestrictionBrowser: ecToggleRestrictionBrowser:
DoShowRestrictionBrowser; DoShowRestrictionBrowser(true);
ecViewComponents: ecViewComponents:
DoShowComponentList; DoShowComponentList(true);
ecToggleFPDocEditor: ecToggleFPDocEditor:
DoShowFPDocEditor; DoShowFPDocEditor(true);
ecViewUnits: ecViewUnits:
DoViewUnitsAndForms(false); DoViewUnitsAndForms(false);
@ -3047,7 +3096,7 @@ begin
DoViewUnitsAndForms(true); DoViewUnitsAndForms(true);
ecProjectInspector: ecProjectInspector:
DoShowProjectInspector; DoShowProjectInspector(true);
ecConfigCustomComps: ecConfigCustomComps:
PkgBoss.ShowConfigureCustomComponents; PkgBoss.ShowConfigureCustomComponents;
@ -3381,11 +3430,12 @@ begin
LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL); LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL);
end; end;
procedure TMainIDE.DoViewAnchorEditor; procedure TMainIDE.DoViewAnchorEditor(Show: boolean);
begin begin
if AnchorDesigner=nil then if AnchorDesigner=nil then
AnchorDesigner:=TAnchorDesigner.Create(OwningComponent); AnchorDesigner:=TAnchorDesigner.Create(OwningComponent);
AnchorDesigner.EnsureVisible(true); if Show then
AnchorDesigner.EnsureVisible(true);
end; end;
procedure TMainIDE.DoToggleViewComponentPalette; procedure TMainIDE.DoToggleViewComponentPalette;
@ -3549,7 +3599,7 @@ end;
Procedure TMainIDE.mnuViewUnitDependenciesClicked(Sender: TObject); Procedure TMainIDE.mnuViewUnitDependenciesClicked(Sender: TObject);
begin begin
DoViewUnitDependencies; DoViewUnitDependencies(true);
end; end;
procedure TMainIDE.mnuViewUnitInfoClicked(Sender: TObject); procedure TMainIDE.mnuViewUnitInfoClicked(Sender: TObject);
@ -3559,22 +3609,22 @@ end;
Procedure TMainIDE.mnuViewCodeExplorerClick(Sender: TObject); Procedure TMainIDE.mnuViewCodeExplorerClick(Sender: TObject);
begin begin
DoShowCodeExplorer; DoShowCodeExplorer(true);
end; end;
Procedure TMainIDE.mnuViewCodeBrowserClick(Sender: TObject); Procedure TMainIDE.mnuViewCodeBrowserClick(Sender: TObject);
begin begin
DoShowCodeBrowser; DoShowCodeBrowser(true);
end; end;
Procedure TMainIDE.mnuViewComponentsClick(Sender: TObject); Procedure TMainIDE.mnuViewComponentsClick(Sender: TObject);
begin begin
DoShowComponentList; DoShowComponentList(true);
end; end;
procedure TMainIDE.mnuViewRestrictionBrowserClick(Sender: TObject); procedure TMainIDE.mnuViewRestrictionBrowserClick(Sender: TObject);
begin begin
DoShowRestrictionBrowser; DoShowRestrictionBrowser(true);
end; end;
Procedure TMainIDE.mnuViewMessagesClick(Sender: TObject); Procedure TMainIDE.mnuViewMessagesClick(Sender: TObject);
@ -3783,7 +3833,7 @@ end;
procedure TMainIDE.mnuProjectInspectorClicked(Sender: TObject); procedure TMainIDE.mnuProjectInspectorClicked(Sender: TObject);
begin begin
DoShowProjectInspector; DoShowProjectInspector(true);
end; end;
procedure TMainIDE.mnuAddToProjectClicked(Sender: TObject); procedure TMainIDE.mnuAddToProjectClicked(Sender: TObject);
@ -4036,7 +4086,7 @@ end;
procedure TMainIDE.mnuViewFPDocEditorClicked(Sender: TObject); procedure TMainIDE.mnuViewFPDocEditorClicked(Sender: TObject);
begin begin
DoShowFPDocEditor; DoShowFPDocEditor(true);
end; end;
procedure TMainIDE.mnuToolConvertDFMtoLFMClicked(Sender: TObject); procedure TMainIDE.mnuToolConvertDFMtoLFMClicked(Sender: TObject);
@ -8355,6 +8405,7 @@ function TMainIDE.DoOpenEditorFile(AFileName: string; PageIndex,
begin begin
Result := DoOpenEditorFile(AFileName, PageIndex, WindowIndex, nil, Flags); Result := DoOpenEditorFile(AFileName, PageIndex, WindowIndex, nil, Flags);
end; end;
function TMainIDE.DoOpenEditorFile(AFileName: string; PageIndex, function TMainIDE.DoOpenEditorFile(AFileName: string; PageIndex,
WindowIndex: integer; AEditorInfo: TUnitEditorInfo; Flags: TOpenFlags WindowIndex: integer; AEditorInfo: TUnitEditorInfo; Flags: TOpenFlags
): TModalResult; ): TModalResult;
@ -8876,10 +8927,9 @@ begin
Result := mrOk; Result := mrOk;
end; end;
procedure TMainIDE.DoViewUnitDependencies; procedure TMainIDE.DoViewUnitDependencies(Show: boolean);
var var
WasVisible: boolean; WasVisible: boolean;
ALayout: TSimpleWindowLayout;
begin begin
if UnitDependenciesView=nil then begin if UnitDependenciesView=nil then begin
UnitDependenciesView:=TUnitDependenciesView.Create(OwningComponent); UnitDependenciesView:=TUnitDependenciesView.Create(OwningComponent);
@ -8902,12 +8952,25 @@ begin
end; end;
end; end;
UnitDependenciesView.Show; if Show then
ALayout:=EnvironmentOptions.IDEWindowLayoutList. begin
ItemByEnum(nmiwUnitDependenciesName); EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwUnitDependenciesName).Apply;
ALayout.Apply; UnitDependenciesView.Show;
if not WasVisible then if (not WasVisible) then
UnitDependenciesView.ShowOnTop; UnitDependenciesView.ShowOnTop;
end;
end;
procedure TMainIDE.DoViewJumpHistory(Show: boolean);
begin
if JumpHistoryViewWin=nil then begin
JumpHistoryViewWin:=TJumpHistoryViewWin.Create(OwningComponent);
with JumpHistoryViewWin do begin
OnSelectionChanged := @JumpHistoryViewSelectionChanged;
end;
end;
if Show then
JumpHistoryViewWin.ShowOnTop;
end; end;
procedure TMainIDE.DoViewUnitInfo; procedure TMainIDE.DoViewUnitInfo;
@ -8939,7 +9002,7 @@ begin
DoGotoIncludeDirective; DoGotoIncludeDirective;
end; end;
procedure TMainIDE.DoShowCodeExplorer; procedure TMainIDE.DoShowCodeExplorer(Show: boolean);
begin begin
if CodeExplorerView=nil then if CodeExplorerView=nil then
begin begin
@ -8950,36 +9013,107 @@ begin
CodeExplorerView.OnShowOptions:=@OnCodeExplorerShowOptions; CodeExplorerView.OnShowOptions:=@OnCodeExplorerShowOptions;
end; end;
EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwCodeExplorerName).Apply; if Show then
CodeExplorerView.ShowOnTop; begin
CodeExplorerView.Refresh(true); EnvironmentOptions.IDEWindowLayoutList.ItemByEnum(nmiwCodeExplorerName).Apply;
CodeExplorerView.ShowOnTop;
CodeExplorerView.Refresh(true);
end;
end; end;
procedure TMainIDE.DoShowCodeBrowser; procedure TMainIDE.DoShowCodeBrowser(Show: boolean);
begin begin
CreateCodeBrowser; CreateCodeBrowser;
CodeBrowserView.ShowOnTop; if Show then
CodeBrowserView.ShowOnTop;
end; end;
procedure TMainIDE.DoShowRestrictionBrowser(const RestrictedName: String); procedure TMainIDE.DoShowRestrictionBrowser(Show: boolean;
const RestrictedName: String);
begin begin
if RestrictionBrowserView = nil then if RestrictionBrowserView = nil then
RestrictionBrowserView := TRestrictionBrowserView.Create(OwningComponent); RestrictionBrowserView := TRestrictionBrowserView.Create(OwningComponent);
RestrictionBrowserView.SetIssueName(RestrictedName); RestrictionBrowserView.SetIssueName(RestrictedName);
RestrictionBrowserView.ShowOnTop; if Show then
RestrictionBrowserView.ShowOnTop;
end; end;
procedure TMainIDE.DoShowComponentList; procedure TMainIDE.DoShowComponentList(Show: boolean);
begin begin
if not Assigned(ComponentListForm) if not Assigned(ComponentListForm) then
then ComponentListForm := TComponentListForm.Create(OwningComponent); begin
ComponentListForm.Show; ComponentListForm := TComponentListForm.Create(OwningComponent);
ComponentListForm.Name:=ComponentListFormName;
end;
if Show then
ComponentListForm.Show;
end; end;
procedure TMainIDE.DoShowFPDocEditor; procedure TMainIDE.CreateIDEWindow(Sender: TObject; aFormName: string; var
AForm: TCustomForm);
function ItIs(Prefix: string): boolean;
begin
Result:=SysUtils.CompareText(copy(aFormName,1,length(Prefix)),Prefix)=0;
end;
begin begin
FPDocEditWindow.DoShowFPDocEditor; if ItIs(NonModalIDEWindowNames[nmiwMessagesViewName]) then
AForm:=MessagesView
else if ItIs(NonModalIDEWindowNames[nmiwUnitDependenciesName]) then
begin
DoViewUnitDependencies(false);
AForm:=UnitDependenciesView;
end
else if ItIs(NonModalIDEWindowNames[nmiwCodeExplorerName]) then
begin
DoShowCodeExplorer(false);
AForm:=CodeExplorerView;
end
else if ItIs(NonModalIDEWindowNames[nmiwFPDocEditorName]) then
begin
DoShowFPDocEditor(false);
AForm:=FPDocEditor;
end
// ToDo: nmiwClipbrdHistoryName:
else if ItIs(NonModalIDEWindowNames[nmiwProjectInspector]) then
begin
DoShowProjectInspector(false);
AForm:=ProjInspector;
end
else if ItIs(NonModalIDEWindowNames[nmiwSearchResultsViewName]) then
begin
DoShowSearchResultsView(false);
AForm:=SearchResultsView;
end
else if ItIs(NonModalIDEWindowNames[nmiwAnchorEditor]) then
begin
DoViewAnchorEditor(false);
AForm:=AnchorDesigner;
end
else if ItIs(NonModalIDEWindowNames[nmiwCodeBrowser]) then
begin
DoShowCodeBrowser(false);
AForm:=CodeBrowserView;
end
else if ItIs(NonModalIDEWindowNames[nmiwIssueBrowser]) then
begin
DoShowRestrictionBrowser(false);
AForm:=RestrictionBrowserView;
end
else if ItIs(NonModalIDEWindowNames[nmiwJumpHistory]) then
begin
DoViewJumpHistory(false);
AForm:=JumpHistoryViewWin;
end
else if ItIs(ComponentListFormName) then
begin
DoShowComponentList(false);
AForm:=ComponentListForm;
end
else
raise Exception.Create('TMainIDE.CreateIDEWindow invalid formname: '+aFormName);
end; end;
function TMainIDE.CreateNewUniqueFilename(const Prefix, Ext: string; function TMainIDE.CreateNewUniqueFilename(const Prefix, Ext: string;
@ -9990,7 +10124,7 @@ begin
end; end;
end; end;
function TMainIDE.DoShowProjectInspector: TModalResult; procedure TMainIDE.DoShowProjectInspector(Show: boolean);
begin begin
if ProjInspector=nil then begin if ProjInspector=nil then begin
ProjInspector:=TProjectInspectorForm.Create(OwningComponent); ProjInspector:=TProjectInspectorForm.Create(OwningComponent);
@ -10006,8 +10140,8 @@ begin
ProjInspector.LazProject:=Project1; ProjInspector.LazProject:=Project1;
end; end;
ProjInspector.ShowOnTop; if Show then
Result:=mrOk; ProjInspector.ShowOnTop;
end; end;
function TMainIDE.DoCreateProjectForProgram( function TMainIDE.DoCreateProjectForProgram(
@ -12649,19 +12783,20 @@ begin
MessagesView.OnSelectionChanged := @MessagesViewSelectionChanged; MessagesView.OnSelectionChanged := @MessagesViewSelectionChanged;
end; end;
procedure TMainIDE.DoShowSearchResultsView; procedure TMainIDE.DoShowSearchResultsView(Show: boolean);
var var
WasVisible: boolean; WasVisible: boolean;
ALayout: TSimpleWindowLayout;
begin begin
WasVisible := SearchResultsView.Visible; WasVisible := SearchResultsView.Visible;
SearchResultsView.Visible:=true; if Show then
ALayout:=EnvironmentOptions.IDEWindowLayoutList. begin
ItemByEnum(nmiwSearchResultsViewName); SearchResultsView.Visible:=true;
ALayout.Apply; EnvironmentOptions.IDEWindowLayoutList.
if not WasVisible then ItemByEnum(nmiwSearchResultsViewName).Apply;
// the sourcenotebook is more interesting than the messages if not WasVisible then
SourceEditorManager.ShowActiveWindowOnTop(False); // the sourcenotebook is more interesting than the messages
SourceEditorManager.ShowActiveWindowOnTop(False);
end;
//set the event here for the selectionchanged event //set the event here for the selectionchanged event
if not assigned(SearchresultsView.OnSelectionChanged) then if not assigned(SearchresultsView.OnSelectionChanged) then
@ -15729,13 +15864,7 @@ end;
Procedure TMainIDE.OnSrcNotebookViewJumpHistory(Sender: TObject); Procedure TMainIDE.OnSrcNotebookViewJumpHistory(Sender: TObject);
begin begin
if JumpHistoryViewWin=nil then begin DoViewUnitDependencies(true);
JumpHistoryViewWin:=TJumpHistoryViewWin.Create(OwningComponent);
with JumpHistoryViewWin do begin
OnSelectionChanged := @JumpHistoryViewSelectionChanged;
end;
end;
JumpHistoryViewWin.ShowOnTop;
end; end;
procedure TMainIDE.OnSrcNoteBookPopupMenu( procedure TMainIDE.OnSrcNoteBookPopupMenu(
@ -17036,7 +17165,6 @@ var
begin begin
if (ALayout=nil) or (ALayout.Form=nil) then exit; if (ALayout=nil) or (ALayout.Form=nil) then exit;
// debugln('TMainIDE.OnApplyWindowLayout ',ALayout.Form.Name,' ',ALayout.Form.Classname,' ',IDEWindowPlacementNames[ALayout.WindowPlacement],' ',ALayout.CustomCoordinatesAreValid,' ',ALayout.Left,' ',ALayout.Top,' ',ALayout.Width,' ',ALayout.Height); // debugln('TMainIDE.OnApplyWindowLayout ',ALayout.Form.Name,' ',ALayout.Form.Classname,' ',IDEWindowPlacementNames[ALayout.WindowPlacement],' ',ALayout.CustomCoordinatesAreValid,' ',ALayout.Left,' ',ALayout.Top,' ',ALayout.Width,' ',ALayout.Height);
ALayout.Form.Constraints.MaxHeight:=0;
if ALayout.Form<>MainIDEBar then if ALayout.Form<>MainIDEBar then
MakeIDEWindowDockable(ALayout.Form); MakeIDEWindowDockable(ALayout.Form);
@ -17094,7 +17222,11 @@ begin
exit; exit;
end; end;
end; end;
// no layout found => use default // no layout found => use default
BarBottom:=MainIDEBar.Top+MainIDEBar.Height; BarBottom:=MainIDEBar.Top+MainIDEBar.Height;
// default window positions // default window positions
case WindowType of case WindowType of

View File

@ -159,7 +159,7 @@ type
function DoOpenMacroFile(Sender: TObject; function DoOpenMacroFile(Sender: TObject;
const AFilename: string): TModalResult; virtual; abstract; const AFilename: string): TModalResult; virtual; abstract;
function DoShowProjectInspector: TModalResult; virtual; abstract; procedure DoShowProjectInspector(Show: boolean); virtual; abstract;
function DoImExportCompilerOptions(Sender: TObject; out ImportExportResult: TImportExportOptionsResult): TModalResult; virtual; abstract; function DoImExportCompilerOptions(Sender: TObject; out ImportExportResult: TImportExportOptionsResult): TModalResult; virtual; abstract;
function PrepareForCompile: TModalResult; virtual; abstract; // stop things that interfere with compilation, like debugging function PrepareForCompile: TModalResult; virtual; abstract; // stop things that interfere with compilation, like debugging

View File

@ -945,6 +945,10 @@ type
read GetActiveSourceNotebook write SetActiveSourceNotebook; // reintroduce read GetActiveSourceNotebook write SetActiveSourceNotebook; // reintroduce
function ActiveOrNewSourceWindow: TSourceNotebook; function ActiveOrNewSourceWindow: TSourceNotebook;
function NewSourceWindow: TSourceNotebook; function NewSourceWindow: TSourceNotebook;
procedure CreateSourceWindow(Sender: TObject; aFormName: string;
var AForm: TCustomForm);
procedure GetDefaultLayout(Sender: TObject; aFormName: string;
out aBounds: TRect; out DockSibling: string; out DockAlign: TAlign);
function SourceWindowWithPage(const APage: TPage): TSourceNotebook; function SourceWindowWithPage(const APage: TPage): TSourceNotebook;
property SourceWindowByLastFocused[Index: Integer]: TSourceNotebook property SourceWindowByLastFocused[Index: Integer]: TSourceNotebook
read GetSourceNbByLastFocused; read GetSourceNbByLastFocused;
@ -8319,6 +8323,28 @@ begin
ActiveSourceWindow := Result; ActiveSourceWindow := Result;
end; end;
procedure TSourceEditorManager.CreateSourceWindow(Sender: TObject;
aFormName: string; var AForm: TCustomForm);
begin
debugln(['TSourceEditorManager.CreateSourceWindow Sender=',DbgSName(Sender),' FormName="',aFormName,'"']);
AForm := CreateNewWindow(false);
AForm.Name:=aFormName;
end;
procedure TSourceEditorManager.GetDefaultLayout(Sender: TObject;
aFormName: string; out aBounds: TRect; out DockSibling: string; out
DockAlign: TAlign);
var
i: LongInt;
begin
i:=StrToIntDef(
copy(aFormName,length(NonModalIDEWindowNames[nmiwSourceNoteBookName])+1,
length(aFormName)),-1);
debugln(['TSourceEditorManager.GetDefaultLayout ',aFormName,' i=',i]);
aBounds:=Bounds(250+30*i,130+30*i,
Min(1000,(Screen.Width*7) div 10),(Screen.Height*7) div 10);
end;
function TSourceEditorManager.SourceWindowWithPage(const APage: TPage function TSourceEditorManager.SourceWindowWithPage(const APage: TPage
): TSourceNotebook; ): TSourceNotebook;
var var
@ -8974,6 +9000,11 @@ begin
EndOfTokenChr:=' ()[]{},.;:"+-*^@$\<>='''; EndOfTokenChr:=' ()[]{},.;:"+-*^@$\<>=''';
end; end;
// layout
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwSourceNoteBookName],
@CreateSourceWindow,'250','100','70%','70%',
NonModalIDEWindowNames[nmiwMainIDEName],alBottom,
true,@GetDefaultLayout);
end; end;
destructor TSourceEditorManager.Destroy; destructor TSourceEditorManager.Destroy;

View File

@ -104,23 +104,31 @@ var
IDEDialogLayoutList: TIDEDialogLayoutList = nil;// set by the IDE IDEDialogLayoutList: TIDEDialogLayoutList = nil;// set by the IDE
type type
TIWDLState = ( TIWCState = (
iwdlsHidden, iwcsHidden,
iwdlsIconified, iwcsIconified,
iwdlsNormal, iwcsNormal,
iwdlsDocked iwcsDocked
); );
{ TIDEWindowDefaultLayout } TCreateIDEWindowEvent = procedure(Sender: TObject; aFormName: string;
var AForm: TCustomForm) of object;
TGetDefaultIDEWindowLayoutEvent = procedure(Sender: TObject; aFormName: string;
out aBounds: TRect; out DockSibling: string; out DockAlign: TAlign) of object;
TIDEWindowDefaultLayout = class { TIDEWindowCreator }
TIDEWindowCreator = class
private private
FCreateForm: TCreateIDEWindowEvent;
FDockAlign: TAlign; FDockAlign: TAlign;
FDockSibling: string; FDockSibling: string;
FFormName: string; FFormName: string;
FHeight: string; FHeight: string;
FLeft: string; FLeft: string;
FState: TIWDLState; FMulti: boolean;
FOnGetLayout: TGetDefaultIDEWindowLayoutEvent;
FState: TIWCState;
FTop: string; FTop: string;
FWidth: string; FWidth: string;
procedure SetHeight(const AValue: string); procedure SetHeight(const AValue: string);
@ -128,47 +136,70 @@ type
procedure SetTop(const AValue: string); procedure SetTop(const AValue: string);
procedure SetWidth(const AValue: string); procedure SetWidth(const AValue: string);
public public
property FormName: string read FFormName; constructor Create(aFormName: string); overload;
property State: TIWDLState read FState write FState; constructor Create(aFormName: string;
CreateFormEvent: TCreateIDEWindowEvent;
aLeft, aTop, aWidth, aHeight: string;
aDockSibling : string = '';
aDockAlign: TAlign = alNone;
aMulti: boolean = false;
GetLayoutEvent: TGetDefaultIDEWindowLayoutEvent = nil); overload;
property FormName: string read FFormName; // prefix for all forms
property Multi: boolean read FMulti; // there can be more than one of this form, e.g. the source editors and the package editors
property State: TIWCState read FState write FState;
property Left: string read FLeft write SetLeft; // '12' for 12 pixel, '10%' for 10 percent of screen.width property Left: string read FLeft write SetLeft; // '12' for 12 pixel, '10%' for 10 percent of screen.width
property Top: string read FTop write SetTop; // '12' for 12 pixel, '10%' for 10 percent of screen.height property Top: string read FTop write SetTop; // '12' for 12 pixel, '10%' for 10 percent of screen.height
property Width: string read FWidth write SetWidth; // '12' for 12 pixel, '10%' for 10 percent of screen.width property Width: string read FWidth write SetWidth; // '12' for 12 pixel, '10%' for 10 percent of screen.width
property Height: string read FHeight write SetHeight; // '12' for 12 pixel, '10%' for 10 percent of screen.height property Height: string read FHeight write SetHeight; // '12' for 12 pixel, '10%' for 10 percent of screen.height
property DockSibling: string read FDockSibling write FDockSibling; // another form name property DockSibling: string read FDockSibling write FDockSibling; // another form name
property DockAlign: TAlign read FDockAlign write FDockAlign; property DockAlign: TAlign read FDockAlign write FDockAlign;
property OnCreateForm: TCreateIDEWindowEvent read FCreateForm write FCreateForm;
property OnGetLayout: TGetDefaultIDEWindowLayoutEvent read FOnGetLayout
write FOnGetLayout;
procedure CheckBoundValue(s: string); procedure CheckBoundValue(s: string);
constructor Create(aFormName: string); overload;
constructor Create(aFormName: string; aLeft, aTop, aWidth, aHeight: integer;
aUnit: string = ''; aDockSibling : string = '';
aDockAlign: TAlign = alNone); overload;
end; end;
{ TIDEWindowDefaultLayoutList } { TIDEWindowCreatorList }
TIDEWindowDefaultLayoutList = class TIDEWindowCreatorList = class
private private
fItems: TFPList; // list of TIDEWindowDefaultLayout fItems: TFPList; // list of TIDEWindowCreator
function GetItems(Index: integer): TIDEWindowDefaultLayout; function GetItems(Index: integer): TIDEWindowCreator;
procedure ErrorIfFormExists(FormName: string);
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure Clear; procedure Clear;
function Count: integer; function Count: integer;
property Items[Index: integer]: TIDEWindowDefaultLayout read GetItems; property Items[Index: integer]: TIDEWindowCreator read GetItems;
function Add(aLayout: TIDEWindowDefaultLayout): integer; function Add(aLayout: TIDEWindowCreator): integer; overload;
function Add(aFormName: string): TIDEWindowCreator; overload;
function Add(aFormName: string;
CreateFormEvent: TCreateIDEWindowEvent;
aLeft, aTop, aWidth, aHeight: string;
aDockSibling : string = '';
aDockAlign: TAlign = alNone;
aMulti: boolean = false;
GetLayoutEvent: TGetDefaultIDEWindowLayoutEvent = nil
): TIDEWindowCreator; overload;
procedure Delete(Index: integer); procedure Delete(Index: integer);
function IndexOfName(FormName: string): integer; function IndexOfName(FormName: string): integer;
function FindLayoutWithName(FormName: string): TIDEWindowDefaultLayout; function FindWithName(FormName: string): TIDEWindowCreator;
end; end;
var
IDEWindowCreators: TIDEWindowCreatorList = nil; // set by the IDE
type type
{ TIDEDockMaster } { TIDEDockMaster }
TIDEDockMaster = class TIDEDockMaster = class
public public
// ToDo: save/restore layout
procedure MakeIDEWindowDockable(AControl: TWinControl); virtual; abstract; procedure MakeIDEWindowDockable(AControl: TWinControl); virtual; abstract;
procedure MakeIDEWindowDockSite(AForm: TCustomForm); virtual; abstract; procedure MakeIDEWindowDockSite(AForm: TCustomForm); virtual; abstract;
procedure LoadDefaultLayout; virtual; abstract; // called before opening the first project
end; end;
var var
@ -432,37 +463,37 @@ begin
inherited Destroy; inherited Destroy;
end; end;
{ TIDEWindowDefaultLayout } { TIDEWindowCreator }
procedure TIDEWindowDefaultLayout.SetHeight(const AValue: string); procedure TIDEWindowCreator.SetHeight(const AValue: string);
begin begin
CheckBoundValue(AValue); CheckBoundValue(AValue);
if FHeight=AValue then exit; if FHeight=AValue then exit;
FHeight:=AValue; FHeight:=AValue;
end; end;
procedure TIDEWindowDefaultLayout.SetLeft(const AValue: string); procedure TIDEWindowCreator.SetLeft(const AValue: string);
begin begin
CheckBoundValue(AValue); CheckBoundValue(AValue);
if FLeft=AValue then exit; if FLeft=AValue then exit;
FLeft:=AValue; FLeft:=AValue;
end; end;
procedure TIDEWindowDefaultLayout.SetTop(const AValue: string); procedure TIDEWindowCreator.SetTop(const AValue: string);
begin begin
CheckBoundValue(AValue); CheckBoundValue(AValue);
if FTop=AValue then exit; if FTop=AValue then exit;
FTop:=AValue; FTop:=AValue;
end; end;
procedure TIDEWindowDefaultLayout.SetWidth(const AValue: string); procedure TIDEWindowCreator.SetWidth(const AValue: string);
begin begin
CheckBoundValue(AValue); CheckBoundValue(AValue);
if FWidth=AValue then exit; if FWidth=AValue then exit;
FWidth:=AValue; FWidth:=AValue;
end; end;
procedure TIDEWindowDefaultLayout.CheckBoundValue(s: string); procedure TIDEWindowCreator.CheckBoundValue(s: string);
var var
p: Integer; p: Integer;
begin begin
@ -477,45 +508,55 @@ begin
raise Exception.Create('TIDEWindowDefaultLayout.CheckBoundValue: expected number, but '+s+' found'); raise Exception.Create('TIDEWindowDefaultLayout.CheckBoundValue: expected number, but '+s+' found');
end; end;
constructor TIDEWindowDefaultLayout.Create(aFormName: string); constructor TIDEWindowCreator.Create(aFormName: string);
begin begin
FFormName:=aFormName; FFormName:=aFormName;
end; end;
constructor TIDEWindowDefaultLayout.Create(aFormName: string; aLeft, aTop, constructor TIDEWindowCreator.Create(aFormName: string;
aWidth, aHeight: integer; aUnit: string; aDockSibling: string; CreateFormEvent: TCreateIDEWindowEvent; aLeft, aTop, aWidth, aHeight: string;
aDockAlign: TAlign); aDockSibling: string; aDockAlign: TAlign;
aMulti: boolean; GetLayoutEvent: TGetDefaultIDEWindowLayoutEvent);
begin begin
Create(aFormName); Create(aFormName);
Left:=IntToStr(aLeft)+aUnit; FMulti:=aMulti;
Top:=IntToStr(aTop)+aUnit; Left:=aLeft;
Width:=IntToStr(aWidth)+aUnit; Top:=aTop;
Height:=IntToStr(aHeight)+aUnit; Width:=aWidth;
Height:=aHeight;
DockSibling:=aDockSibling; DockSibling:=aDockSibling;
DockAlign:=aDockAlign; DockAlign:=aDockAlign;
OnCreateForm:=CreateFormEvent;
OnGetLayout:=GetLayoutEvent;
end; end;
{ TIDEWindowDefaultLayoutList } { TIDEWindowCreatorList }
function TIDEWindowDefaultLayoutList.GetItems(Index: integer function TIDEWindowCreatorList.GetItems(Index: integer
): TIDEWindowDefaultLayout; ): TIDEWindowCreator;
begin begin
Result:=TIDEWindowDefaultLayout(fItems[Index]); Result:=TIDEWindowCreator(fItems[Index]);
end; end;
constructor TIDEWindowDefaultLayoutList.Create; procedure TIDEWindowCreatorList.ErrorIfFormExists(FormName: string);
begin
if IndexOfName(FormName)>=0 then
raise Exception.Create('TIDEWindowDefaultLayoutList.Add: form name '+FormName+' already exists');
end;
constructor TIDEWindowCreatorList.Create;
begin begin
fItems:=TFPList.Create; fItems:=TFPList.Create;
end; end;
destructor TIDEWindowDefaultLayoutList.Destroy; destructor TIDEWindowCreatorList.Destroy;
begin begin
Clear; Clear;
FreeAndNil(fItems); FreeAndNil(fItems);
inherited Destroy; inherited Destroy;
end; end;
procedure TIDEWindowDefaultLayoutList.Clear; procedure TIDEWindowCreatorList.Clear;
var var
i: Integer; i: Integer;
begin begin
@ -523,34 +564,60 @@ begin
TObject(fItems[i]).Free; TObject(fItems[i]).Free;
end; end;
function TIDEWindowDefaultLayoutList.Count: integer; function TIDEWindowCreatorList.Count: integer;
begin begin
Result:=fItems.Count; Result:=fItems.Count;
end; end;
function TIDEWindowDefaultLayoutList.Add(aLayout: TIDEWindowDefaultLayout function TIDEWindowCreatorList.Add(aLayout: TIDEWindowCreator
): integer; ): integer;
begin begin
if IndexOfName(aLayout.FormName)>=0 then ErrorIfFormExists(aLayout.FormName);
raise Exception.Create('TIDEWindowDefaultLayoutList.Add: form name already exists');
Result:=fItems.Add(aLayout); Result:=fItems.Add(aLayout);
end; end;
procedure TIDEWindowDefaultLayoutList.Delete(Index: integer); function TIDEWindowCreatorList.Add(aFormName: string
): TIDEWindowCreator;
begin
ErrorIfFormExists(aFormName);
Result:=TIDEWindowCreator.Create(aFormName);
Add(Result);
end;
function TIDEWindowCreatorList.Add(aFormName: string;
CreateFormEvent: TCreateIDEWindowEvent; aLeft, aTop, aWidth, aHeight: string;
aDockSibling: string; aDockAlign: TAlign;
aMulti: boolean;
GetLayoutEvent: TGetDefaultIDEWindowLayoutEvent): TIDEWindowCreator;
begin
ErrorIfFormExists(aFormName);
Result:=TIDEWindowCreator.Create(aFormName,CreateFormEvent,
aLeft,aTop,aWidth,aHeight,aDockSibling,aDockAlign,aMulti,GetLayoutEvent);
Add(Result);
end;
procedure TIDEWindowCreatorList.Delete(Index: integer);
begin begin
TObject(fItems[Index]).Free; TObject(fItems[Index]).Free;
fItems.Delete(Index); fItems.Delete(Index);
end; end;
function TIDEWindowDefaultLayoutList.IndexOfName(FormName: string): integer; function TIDEWindowCreatorList.IndexOfName(FormName: string): integer;
var
Item: TIDEWindowCreator;
begin begin
Result:=Count-1; Result:=Count-1;
while (Result>=0) and (SysUtils.CompareText(FormName,Items[Result].FormName)<>0) do while (Result>=0) do begin
Item:=Items[Result];
if (SysUtils.CompareText(copy(FormName,1,length(Item.FormName)),Item.FormName)=0)
then
exit;
dec(Result); dec(Result);
end;
end; end;
function TIDEWindowDefaultLayoutList.FindLayoutWithName(FormName: string function TIDEWindowCreatorList.FindWithName(FormName: string
): TIDEWindowDefaultLayout; ): TIDEWindowCreator;
var var
i: LongInt; i: LongInt;
begin begin
@ -561,5 +628,10 @@ begin
Result:=nil; Result:=nil;
end; end;
initialization
IDEWindowCreators:=TIDEWindowCreatorList.Create;
finalization
FreeAndNil(IDEWindowCreators);
end. end.

View File

@ -1649,7 +1649,6 @@ begin
AddFile('newitemintf.pas','NewItemIntf',pftUnit,[],cpBase); AddFile('newitemintf.pas','NewItemIntf',pftUnit,[],cpBase);
AddFile('macrointf.pas','MacroIntf',pftUnit,[],cpBase); AddFile('macrointf.pas','MacroIntf',pftUnit,[],cpBase);
AddFile('menuintf.pas','MenuIntf',pftUnit,[],cpBase); AddFile('menuintf.pas','MenuIntf',pftUnit,[],cpBase);
AddFile('newintf.pas','NewIntf',pftUnit,[],cpBase);
AddFile('objectinspector.pp','ObjectInspector',pftUnit,[],cpBase); AddFile('objectinspector.pp','ObjectInspector',pftUnit,[],cpBase);
AddFile('objinspstrconsts.pas','ObjInspStrConsts',pftUnit,[],cpBase); AddFile('objinspstrconsts.pas','ObjInspStrConsts',pftUnit,[],cpBase);
AddFile('packageintf.pas','PackageIntf',pftUnit,[],cpBase); AddFile('packageintf.pas','PackageIntf',pftUnit,[],cpBase);

View File

@ -50,18 +50,18 @@ uses
CodeToolsConfig, CodeToolManager, CodeCache, NonPascalCodeTools, CodeToolsConfig, CodeToolManager, CodeCache, NonPascalCodeTools,
BasicCodeTools, DefineTemplates, FileProcs, AVL_Tree, Laz_XMLCfg, BasicCodeTools, DefineTemplates, FileProcs, AVL_Tree, Laz_XMLCfg,
// IDE Interface // IDE Interface
SrcEditorIntf, IDEExternToolIntf, NewItemIntf, ProjectIntf, PackageIntf, MenuIntf, SrcEditorIntf, IDEExternToolIntf, NewItemIntf, ProjectIntf, PackageIntf,
PropEdits, IDEMsgIntf, MacroIntf, LazIDEIntf, MenuIntf, IDEWindowIntf, PropEdits, IDEMsgIntf, MacroIntf, LazIDEIntf,
// IDE // IDE
LazConf, LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs, IDECommands, LazConf, LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs, IDECommands,
EnvironmentOpts, MiscOptions, InputHistory, ProjectDefs, Project, IDEOptionDefs, EnvironmentOpts, MiscOptions, InputHistory, ProjectDefs,
ComponentReg, UComponentManMain, PackageEditor, AddToPackageDlg, PackageDefs, Project, ComponentReg, UComponentManMain, PackageEditor, AddToPackageDlg,
PackageLinks, PackageSystem, OpenInstalledPkgDlg, PkgGraphExplorer, PackageDefs, PackageLinks, PackageSystem, OpenInstalledPkgDlg,
BrokenDependenciesDlg, CompilerOptions, ExtToolEditDlg, IDETranslations, PkgGraphExplorer, BrokenDependenciesDlg, CompilerOptions, ExtToolEditDlg,
TransferMacros, MsgView, BuildLazDialog, NewDialog, IDEDialogs, TodoList, IDETranslations, TransferMacros, MsgView, BuildLazDialog, NewDialog,
ProjectInspector, ComponentPalette, SourceEditor, AddFileToAPackageDlg, IDEDialogs, TodoList, ProjectInspector, ComponentPalette, SourceEditor,
LazarusPackageIntf, PublishProjectDlg, PkgLinksDlg, InstallPkgSetDlg, AddFileToAPackageDlg, LazarusPackageIntf, PublishProjectDlg, PkgLinksDlg,
ConfirmPkgListDlg, InstallPkgSetDlg, ConfirmPkgListDlg,
// bosses // bosses
BaseBuildManager, BasePkgManager, BaseBuildManager, BasePkgManager,
MainBar, MainIntf, MainBase; MainBar, MainIntf, MainBase;
@ -158,6 +158,8 @@ type
procedure OnCheckInstallPackageList(PkgIDList: TFPList; var Ok: boolean); procedure OnCheckInstallPackageList(PkgIDList: TFPList; var Ok: boolean);
function LoadDependencyList(FirstDependency: TPkgDependency): TModalResult; function LoadDependencyList(FirstDependency: TPkgDependency): TModalResult;
procedure OnOpenPackageForCurrentSrcEditFile(Sender: TObject); procedure OnOpenPackageForCurrentSrcEditFile(Sender: TObject);
procedure CreateIDEWindow(Sender: TObject; aFormName: string;
var AForm: TCustomForm);
private private
// helper functions // helper functions
FLastLazarusSrcDir: string; FLastLazarusSrcDir: string;
@ -228,7 +230,7 @@ type
// package graph // package graph
function AddPackageToGraph(APackage: TLazPackage; Replace: boolean): TModalResult; function AddPackageToGraph(APackage: TLazPackage; Replace: boolean): TModalResult;
function DoShowPackageGraph: TModalResult; procedure DoShowPackageGraph(Show: boolean);
procedure DoShowPackageGraphPathList(PathList: TFPList); override; procedure DoShowPackageGraphPathList(PathList: TFPList); override;
function ShowBrokenDependenciesReport(Dependencies: TFPList): TModalResult; function ShowBrokenDependenciesReport(Dependencies: TFPList): TModalResult;
procedure RebuildDefineTemplates; override; procedure RebuildDefineTemplates; override;
@ -397,7 +399,7 @@ end;
procedure TPkgManager.MainIDEitmPkgPkgGraphClick(Sender: TObject); procedure TPkgManager.MainIDEitmPkgPkgGraphClick(Sender: TObject);
begin begin
DoShowPackageGraph; DoShowPackageGraph(true);
end; end;
procedure TPkgManager.MainIDEitmPkgEditInstallPkgsClick(Sender: TObject); procedure TPkgManager.MainIDEitmPkgEditInstallPkgsClick(Sender: TObject);
@ -714,6 +716,16 @@ begin
DoOpenPackage(PkgFile.LazPackage,[],false); DoOpenPackage(PkgFile.LazPackage,[],false);
end; end;
procedure TPkgManager.CreateIDEWindow(Sender: TObject; aFormName: string; var
AForm: TCustomForm);
begin
if SysUtils.CompareText(aFormName,NonModalIDEWindowNames[nmiwPkgGraphExplorer])=0
then begin
DoShowPackageGraph(false);
AForm:=PackageGraphExplorer;
end;
end;
procedure TPkgManager.MainIDEitmPkgAddCurUnitToPkgClick(Sender: TObject); procedure TPkgManager.MainIDEitmPkgAddCurUnitToPkgClick(Sender: TObject);
begin begin
DoAddActiveUnitToAPackage; DoAddActiveUnitToAPackage;
@ -955,7 +967,8 @@ function TPkgManager.PackageGraphExplorerOpenProject(Sender: TObject;
AProject: TProject): TModalResult; AProject: TProject): TModalResult;
begin begin
if AProject<>Project1 then exit(mrCancel); if AProject<>Project1 then exit(mrCancel);
Result:=MainIDE.DoShowProjectInspector; MainIDE.DoShowProjectInspector(true);
Result:=mrOk;
end; end;
procedure TPkgManager.PackageGraphAddPackage(Pkg: TLazPackage); procedure TPkgManager.PackageGraphAddPackage(Pkg: TLazPackage);
@ -1526,7 +1539,7 @@ begin
if Dependency is TPkgDependency then begin if Dependency is TPkgDependency then begin
// check if project // check if project
if Dependency.Owner is TProject then begin if Dependency.Owner is TProject then begin
MainIDE.DoShowProjectInspector; MainIDE.DoShowProjectInspector(true);
Result:=IDEMessageDialog(lisPkgMangBrokenDependency, Result:=IDEMessageDialog(lisPkgMangBrokenDependency,
Format(lisPkgMangTheProjectRequiresThePackageButItWasNotFound, [ Format(lisPkgMangTheProjectRequiresThePackageButItWasNotFound, [
'"', Dependency.AsString, '"', #13]), '"', Dependency.AsString, '"', #13]),
@ -1863,6 +1876,9 @@ begin
end; end;
SetRecentPackagesMenu; SetRecentPackagesMenu;
IDEWindowCreators.Add(NonModalIDEWindowNames[nmiwPkgGraphExplorer],
@CreateIDEWindow,'250','200','400','300');
end; end;
procedure TPkgManager.ConnectSourceNotebookEvents; procedure TPkgManager.ConnectSourceNotebookEvents;
@ -2620,7 +2636,7 @@ begin
Result:=mrOk; Result:=mrOk;
end; end;
function TPkgManager.DoShowPackageGraph: TModalResult; procedure TPkgManager.DoShowPackageGraph(Show: boolean);
begin begin
if PackageGraphExplorer=nil then begin if PackageGraphExplorer=nil then begin
PackageGraphExplorer:=TPkgGraphExplorerDlg.Create(Application); PackageGraphExplorer:=TPkgGraphExplorerDlg.Create(Application);
@ -2628,8 +2644,8 @@ begin
PackageGraphExplorer.OnOpenProject:=@PackageGraphExplorerOpenProject; PackageGraphExplorer.OnOpenProject:=@PackageGraphExplorerOpenProject;
PackageGraphExplorer.OnUninstallPackage:=@PackageGraphExplorerUninstallPackage; PackageGraphExplorer.OnUninstallPackage:=@PackageGraphExplorerUninstallPackage;
end; end;
PackageGraphExplorer.ShowOnTop; if Show then
Result:=mrOk; PackageGraphExplorer.ShowOnTop;
end; end;
function TPkgManager.DoCloseAllPackageEditors: TModalResult; function TPkgManager.DoCloseAllPackageEditors: TModalResult;
@ -2646,7 +2662,7 @@ end;
procedure TPkgManager.DoShowPackageGraphPathList(PathList: TFPList); procedure TPkgManager.DoShowPackageGraphPathList(PathList: TFPList);
begin begin
if DoShowPackageGraph<>mrOk then exit; DoShowPackageGraph(true);
PackageGraphExplorer.ShowPath(PathList); PackageGraphExplorer.ShowPath(PathList);
end; end;
@ -2674,7 +2690,7 @@ begin
if (ADependency.Owner is TProject) then begin if (ADependency.Owner is TProject) then begin
// broken dependency used by project -> show project inspector // broken dependency used by project -> show project inspector
if ADependency.Owner=Project1 then begin if ADependency.Owner=Project1 then begin
Result:=MainIDE.DoShowProjectInspector; MainIDE.DoShowProjectInspector(true);
Msg:=Format(lisSeeProjectProjectInspector, [Msg]); Msg:=Format(lisSeeProjectProjectInspector, [Msg]);
end; end;
end; end;