IDE: formatting and some comments

git-svn-id: trunk@33005 -
This commit is contained in:
juha 2011-10-21 15:44:26 +00:00
parent 436d4002ce
commit 3ddecfefbe
4 changed files with 47 additions and 80 deletions

View File

@ -279,8 +279,7 @@ begin
end;
end;
procedure TDesktopOptionsFrame.LoadDesktopSettingsFromFileButtonClick(
Sender: TObject);
procedure TDesktopOptionsFrame.LoadDesktopSettingsFromFileButtonClick(Sender: TObject);
var
AnEnvironmentOptions: TEnvironmentOptions;
OpenDialog: TOpenDialog;

View File

@ -137,8 +137,7 @@ begin
LazarusHelp.ShowHelpForIDEControl(Self);
end;
procedure TIDEOptionsDialog.IDEOptionsDialogKeyPress(Sender: TObject;
var Key: char);
procedure TIDEOptionsDialog.IDEOptionsDialogKeyPress(Sender: TObject; var Key: char);
begin
debugln(['TIDEOptionsDialog.IDEOptionsDialogKeyPress ',ord(Key)]);
end;
@ -263,19 +262,15 @@ end;
procedure TIDEOptionsDialog.ReadAll;
type
TStage = (
sBefore,
sRead,
sAfter
);
TStage = (sBefore, sRead, sAfter);
var
i: integer;
Rec: PIDEOptionsGroupRec;
Instance: TAbstractIDEOptions;
InstanceList: TFPList;
s: TStage;
stag: TStage;
begin
for s:=low(TStage) to High(TStage) do
for stag:=low(TStage) to High(TStage) do
begin
InstanceList:=TFPList.Create;
for i := 0 to IDEEditorGroups.Count - 1 do
@ -283,27 +278,24 @@ begin
Rec := IDEEditorGroups[i];
if not PassesFilter(Rec) then
Continue;
if Rec^.Items <> nil then
if Assigned(Rec^.Items) and Assigned(Rec^.GroupClass) then
begin
if Rec^.GroupClass <> nil then
Instance := Rec^.GroupClass.GetInstance;
if (InstanceList.IndexOf(Instance)<0) and Assigned(Instance) then
begin
Instance := Rec^.GroupClass.GetInstance;
if (InstanceList.IndexOf(Instance)<0) and (Instance <> nil) then
begin
InstanceList.Add(Instance);
case s of
sBefore:
Instance.DoBeforeRead;
sRead:
TraverseSettings(Instance,iodaRead);
sAfter:
Instance.DoAfterRead;
end;
InstanceList.Add(Instance);
case stag of
sBefore:
Instance.DoBeforeRead;
sRead:
TraverseSettings(Instance,iodaRead);
sAfter:
Instance.DoAfterRead;
end;
end;
end;
end;
if s=sRead then
if stag=sRead then
TraverseSettings(nil,iodaRead); // load settings that does not belong to any group
InstanceList.Free;
end;
@ -311,48 +303,41 @@ end;
procedure TIDEOptionsDialog.WriteAll(Restore: boolean);
type
TStage = (
sBefore,
sWrite,
sAfter
);
TStage = (sBefore, sWrite, sAfter);
var
i: integer;
Rec: PIDEOptionsGroupRec;
Instance: TAbstractIDEOptions;
s: TStage;
stag: TStage;
begin
for s:=low(TStage) to High(TStage) do
for stag:=low(TStage) to High(TStage) do
begin
for i := 0 to IDEEditorGroups.Count - 1 do
begin
Rec := IDEEditorGroups[i];
if not PassesFilter(Rec) then
Continue;
if Rec^.Items <> nil then
if Assigned(Rec^.Items) and Assigned(Rec^.GroupClass) then
begin
if Rec^.GroupClass <> nil then
Instance := Rec^.GroupClass.GetInstance;
if Assigned(Instance) then
begin
Instance := Rec^.GroupClass.GetInstance;
if Instance <> nil then
begin
case s of
sBefore:
Instance.DoBeforeWrite(Restore);
sWrite:
if Restore then
TraverseSettings(Instance,iodaRestore)
else
TraverseSettings(Instance,iodaWrite);
sAfter:
Instance.DoAfterWrite(Restore);
end;
case stag of
sBefore:
Instance.DoBeforeWrite(Restore);
sWrite:
if Restore then
TraverseSettings(Instance,iodaRestore)
else
TraverseSettings(Instance,iodaWrite);
sAfter:
Instance.DoAfterWrite(Restore);
end;
end;
end;
end;
if s=sWrite then
if stag=sWrite then
TraverseSettings(nil,iodaWrite); // save settings that does not belong to any group
end;
end;
@ -401,13 +386,10 @@ procedure TIDEOptionsDialog.CreateEditors;
Result := nil;
if Node = nil then
Exit;
if (Node.Data <> nil) and (TAbstractIDEOptionsEditor(Node.Data).Tag = Index) then
Result := Node;
if Result <> nil then
Exit;
Result := SearchNode(Node.GetFirstChild, Index);
if Result <> nil then
Exit;

View File

@ -4765,22 +4765,19 @@ end;
//------------------------------------------------------------------------------
procedure TMainIDE.SaveDesktopSettings(TheEnvironmentOptions: TEnvironmentOptions);
// Called also before reading EnvironmentOptions
begin
IDEWindowCreators.SimpleLayoutStorage.StoreWindowPositions;
// do not auto show the search results view
IDEWindowCreators.SimpleLayoutStorage.ItemByFormID(
NonModalIDEWindowNames[nmiwSearchResultsViewName]).Visible:=false;
with TheEnvironmentOptions do begin
ObjectInspectorOptions.Assign(ObjectInspector1);
end;
TheEnvironmentOptions.ObjectInspectorOptions.Assign(ObjectInspector1);
end;
procedure TMainIDE.LoadDesktopSettings(TheEnvironmentOptions: TEnvironmentOptions);
begin
with TheEnvironmentOptions do begin
ObjectInspectorOptions.AssignTo(ObjectInspector1);
end;
TheEnvironmentOptions.ObjectInspectorOptions.AssignTo(ObjectInspector1);
end;
procedure TMainIDE.UpdateDefaultPascalFileExtensions;
@ -4827,7 +4824,6 @@ var
i: Integer;
begin
IDEOptionsDialog := TIDEOptionsDialog.Create(nil);
try
if ACaption <> '' then
IDEOptionsDialog.Caption := ACaption;
@ -4848,13 +4844,9 @@ begin
IDEOptionsDialog.OptionsFilter := OptionsFilter;
IDEOptionsDialog.Settings := ASettings;
IDEOptionsDialog.OpenEditor(AEditor);
with IDEOptionsDialog do
begin
OnLoadIDEOptions:=@Self.OnLoadIDEOptions;
OnSaveIDEOptions:=@Self.OnSaveIDEOptions;
ReadAll;
end;
IDEOptionsDialog.OnLoadIDEOptions:=@Self.OnLoadIDEOptions;
IDEOptionsDialog.OnSaveIDEOptions:=@Self.OnSaveIDEOptions;
IDEOptionsDialog.ReadAll;
if IDEOptionsDialog.ShowModal = mrOk then begin
IDEOptionsDialog.WriteAll(false);
UpdateHighlighters(True);
@ -4864,8 +4856,7 @@ begin
else
Application.TaskBarBehavior := tbDefault;
end else begin
// restore
IDEOptionsDialog.WriteAll(true);
IDEOptionsDialog.WriteAll(true); // restore
end;
finally
IDEOptionsDialog.Free;
@ -4878,16 +4869,14 @@ begin
SaveDesktopSettings(EnvironmentOptions);
end;
procedure TMainIDE.DoEnvironmentOptionsBeforeWrite(Sender: TObject;
Restore: boolean);
procedure TMainIDE.DoEnvironmentOptionsBeforeWrite(Sender: TObject; Restore: boolean);
begin
if Restore then exit;
OldCompilerFilename:=EnvironmentOptions.CompilerFilename;
OldLanguage:=EnvironmentOptions.LanguageID;
end;
procedure TMainIDE.DoEnvironmentOptionsAfterWrite(Sender: TObject;
Restore: boolean);
procedure TMainIDE.DoEnvironmentOptionsAfterWrite(Sender: TObject; Restore: boolean);
var
MacroValueChanged,
FPCSrcDirChanged, FPCCompilerChanged,
@ -4998,8 +4987,7 @@ begin
CodeToolsOpts.AssignTo(CodeToolBoss);
end;
procedure TMainIDE.DoCodeExplorerOptionsAfterWrite(Sender: TObject;
Restore: boolean);
procedure TMainIDE.DoCodeExplorerOptionsAfterWrite(Sender: TObject; Restore: boolean);
begin
if Restore then exit;
if CodeExplorerView<>nil then

View File

@ -1441,8 +1441,7 @@ begin
dec(Result);
end;
function TIDEWindowCreatorList.FindWithName(FormName: string
): TIDEWindowCreator;
function TIDEWindowCreatorList.FindWithName(FormName: string): TIDEWindowCreator;
var
i: LongInt;
begin
@ -1485,15 +1484,14 @@ begin
end;
end;
procedure TIDEWindowCreatorList.ShowForm(AForm: TCustomForm;
BringToFront: boolean);
procedure TIDEWindowCreatorList.ShowForm(AForm: TCustomForm; BringToFront: boolean);
var
Layout: TSimpleWindowLayout;
begin
if (AForm.Name='') or (not IsValidIdent(AForm.Name)) then
raise Exception.Create('TIDEWindowCreatorList.ShowForm invalid form name '+AForm.Name);
// auto create a storage for every shown form
// auto create a layput storage for every shown form
Layout:=SimpleLayoutStorage.ItemByFormID(AForm.Name);
if Layout=nil then begin
if not (csDesigning in AForm.ComponentState) then