MG: fixed sourcenotebook closing and form-unit switching

git-svn-id: trunk@1433 -
This commit is contained in:
lazarus 2002-02-09 21:09:20 +00:00
parent f52032df06
commit f8f190fabb
2 changed files with 26 additions and 37 deletions

View File

@ -2824,6 +2824,8 @@ writeln('TMainIDE.DoCloseEditorUnit A PageIndex=',PageIndex);
Result:=mrCancel; Result:=mrCancel;
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo); GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
if ActiveUnitInfo=nil then exit; if ActiveUnitInfo=nil then exit;
if ActiveUnitInfo.Form=FLastFormActivated then
FLastFormActivated:=nil;
ActiveUnitInfo.ReadOnly:=ActiveSrcEdit.ReadOnly; ActiveUnitInfo.ReadOnly:=ActiveSrcEdit.ReadOnly;
ActiveUnitInfo.TopLine:=ActiveSrcEdit.EditorComponent.TopLine; ActiveUnitInfo.TopLine:=ActiveSrcEdit.EditorComponent.TopLine;
ActiveUnitInfo.CursorPos:=ActiveSrcEdit.EditorComponent.CaretXY; ActiveUnitInfo.CursorPos:=ActiveSrcEdit.EditorComponent.CaretXY;
@ -4662,40 +4664,32 @@ procedure TMainIDE.DoBringToFrontFormOrUnit;
var AForm: TCustomForm; var AForm: TCustomForm;
ActiveUnitInfo: TUnitInfo; ActiveUnitInfo: TUnitInfo;
begin begin
if FCodeLastActivated then AForm:=nil;
begin if FCodeLastActivated then begin
if SourceNoteBook.NoteBook<>nil then if SourceNoteBook.NoteBook<>nil then begin
AForm:=SourceNotebook AForm:=SourceNotebook;
else if FLastFormActivated<>nil then begin
AForm:=nil;
//if AForm is set, make sure the right tab is being displayed.
if AForm <> nil then
begin
ActiveUnitInfo := Project.UnitWithForm(FLastFormActivated); ActiveUnitInfo := Project.UnitWithForm(FLastFormActivated);
if ActiveUnitInfo <> nil then if (ActiveUnitInfo <> nil) and (ActiveUnitInfo.EditorIndex>=0) then
begin begin
SourceNotebook.Notebook.PageIndex := ActiveUnitInfo.EditorIndex; SourceNotebook.Notebook.PageIndex := ActiveUnitInfo.EditorIndex;
end; end;
end;
end; end;
end end
else else
begin begin
if (SourceNoteBook.NoteBook<>nil) then if (SourceNoteBook.NoteBook<>nil) then begin
begin
ActiveUnitInfo:=Project.UnitWithEditorIndex( ActiveUnitInfo:=Project.UnitWithEditorIndex(
SourceNoteBook.NoteBook.PageIndex); SourceNoteBook.NoteBook.PageIndex);
if (ActiveUnitInfo<>nil) then if (ActiveUnitInfo<>nil) then
AForm:=TCustomForm(ActiveUnitInfo.Form); AForm:=TCustomForm(ActiveUnitInfo.Form);
FLastFormActivated := AForm; FLastFormActivated := AForm;
end;
end;
end; end;
if AForm<>nil then begin
if AForm<>nil then
begin
BringWindowToTop(AForm.Handle); BringWindowToTop(AForm.Handle);
end; end;
end; end;
procedure TMainIDE.OnMacroSubstitution(TheMacro: TTransferMacro; var s:string; procedure TMainIDE.OnMacroSubstitution(TheMacro: TTransferMacro; var s:string;
@ -5850,6 +5844,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.219 2002/02/09 21:09:19 lazarus
MG: fixed sourcenotebook closing and form-unit switching
Revision 1.218 2002/02/09 20:32:08 lazarus Revision 1.218 2002/02/09 20:32:08 lazarus
MG: many fixes on my way to events MG: many fixes on my way to events

View File

@ -256,8 +256,6 @@ type
FUnUsedEditorComponents: TList; // list of TSynEdit FUnUsedEditorComponents: TList; // list of TSynEdit
FProcessingCommand: boolean; FProcessingCommand: boolean;
FSaveDialog : TSaveDialog;
FOnAddJumpPoint: TOnAddJumpPoint; FOnAddJumpPoint: TOnAddJumpPoint;
FOnCloseClicked: TNotifyEvent; FOnCloseClicked: TNotifyEvent;
FOnDeleteLastJumpPoint: TNotifyEvent; FOnDeleteLastJumpPoint: TNotifyEvent;
@ -516,8 +514,8 @@ begin
if (FAOwner<>nil) and (FEditor<>nil) then begin if (FAOwner<>nil) and (FEditor<>nil) then begin
FEditor.Visible:=false; FEditor.Visible:=false;
FEditor.Parent:=nil; FEditor.Parent:=nil;
TSourceNoteBook(FAOwner).FSourceEditorList.Remove(FEditor); TSourceNoteBook(FAOwner).FSourceEditorList.Remove(Self);
TSourceNoteBook(FAOwner).FUnUsedEditorComponents.Remove(FEditor); TSourceNoteBook(FAOwner).FUnUsedEditorComponents.Add(FEditor);
end; end;
//writeln('TSourceEditor.Destroy B '); //writeln('TSourceEditor.Destroy B ');
inherited Destroy; inherited Destroy;
@ -1565,7 +1563,6 @@ begin
OnGetSource:=@OnWordCompletionGetSource; OnGetSource:=@OnWordCompletionGetSource;
end; end;
end; end;
FSaveDialog := TSaveDialog.Create(Self);
BuildPopupMenu; BuildPopupMenu;
@ -1663,7 +1660,6 @@ end;
destructor TSourceNotebook.Destroy; destructor TSourceNotebook.Destroy;
var i: integer; var i: integer;
begin begin
//writeln('[TSourceNotebook.Destroy]');
FProcessingCommand:=false; FProcessingCommand:=false;
for i:=FSourceEditorList.Count-1 downto 0 do for i:=FSourceEditorList.Count-1 downto 0 do
Editors[i].Free; Editors[i].Free;
@ -2674,11 +2670,7 @@ writeln('TSourceNotebook.CloseFile A PageIndex=',PageIndex);
TempEditor:=FindSourceEditorWithPageIndex(PageIndex); TempEditor:=FindSourceEditorWithPageIndex(PageIndex);
if TempEditor=nil then exit; if TempEditor=nil then exit;
TempEditor.Close; TempEditor.Close;
FSourceEditorList.Remove(TempEditor); TempEditor.Free;
if FProcessingCommand then
FUnUsedEditorComponents.Add(TempEditor)
else
TempEditor.Free;
if Notebook.Pages.Count>1 then begin if Notebook.Pages.Count>1 then begin
//writeln('TSourceNotebook.CloseFile B PageIndex=',PageIndex); //writeln('TSourceNotebook.CloseFile B PageIndex=',PageIndex);
Notebook.Pages.Delete(PageIndex); Notebook.Pages.Delete(PageIndex);