From fe13dc559ae9a6acdb1db314ae5b50b7f49b59ea Mon Sep 17 00:00:00 2001 From: lazarus Date: Wed, 20 Dec 2000 20:53:35 +0000 Subject: [PATCH] Fixed toggling between forms and units. It the form is open but the source isn't it'll toggle now. git-svn-id: trunk@74 - --- ide/dlgmessage.pp | 4 +-- ide/uniteditor.pp | 65 +++++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/ide/dlgmessage.pp b/ide/dlgmessage.pp index 41fe25a3fd..b42b1aeb40 100644 --- a/ide/dlgmessage.pp +++ b/ide/dlgmessage.pp @@ -36,7 +36,7 @@ TMessageDlg = class(TForm) private Function GetMessage : String; public - constructor Create(AOwner : TComponent); + constructor Create(AOwner : TComponent); override; Procedure Add(Texts : String); Procedure Clear; Function GetSelectedLineIndex : Integer; @@ -78,7 +78,7 @@ end; {------------------------------------------------------------------------------} Procedure TMessageDlg.Clear; Begin -MEssageView.Items.Clear; +MEssageView.Clear; end; {------------------------------------------------------------------------------} diff --git a/ide/uniteditor.pp b/ide/uniteditor.pp index 8694a6b1a1..16048f4d88 100644 --- a/ide/uniteditor.pp +++ b/ide/uniteditor.pp @@ -44,7 +44,7 @@ type TSourceEditor = class private - FAOwner : TComponent; //this will likeley be the notebook page it's on + FAOwner : TComponent; //Owned by a TSourceNotebook {$ifdef NEW_EDITOR_SYNEDIT} FHighlighter: TSynPasSyn; FEditor : TSynEditor @@ -75,6 +75,9 @@ type Procedure SetCurrentCursorYLine(num : Integer); Function GetAncestor : String; Function GetModified : Boolean; + + Procedure CreateEditor(AOwner : TComponent; AParent: TWinControl); + protected Procedure DisplayControl; Procedure ReParent(AParent : TWinControl); @@ -149,12 +152,33 @@ uses { TSourceEditor } + constructor TSourceEditor.create(AOwner : TComponent; AParent : TWinControl); Begin inherited Create; FAOwner := AOwner; FSource := TStringList.create; +CreateEditor(AOwner,AParent); + +end; + +destructor TSourceEditor.destroy; +begin + FHighlighter.free; + FEditor.Free; + FSource.free; + inherited; +end; + + +Procedure TSourceEditor.CreateEditor(AOwner : TComponent; AParent: TWinControl); +Begin +if assigned(FEditor) then + Begin + FSource.Assign(FEditor.Lines); + FEditor.Free; + end; FEditor := TmwCustomEdit.Create(FAOwner); with FEditor do @@ -187,19 +211,10 @@ FEditor := TmwCustomEdit.Create(FAOwner); end; OnKeyPress := @KeyPRessed; end; - +FEditor.Lines.Assign(FSource); end; -destructor TSourceEditor.destroy; -begin - FHighlighter.free; - FEditor.Free; - FSource.free; - inherited; -end; - - Procedure TSourceEditor.AddControlCode(_Control : TComponent); var PT : PTypeData; @@ -319,6 +334,8 @@ Begin Result := FSource <> FEditor.Lines; end; +//Get's the ancestor of the FControl. +//For example the ancestor of a TForm1 = class(xxxx) is the xxxx Function TSourceEditor.GetAncestor : String; var PI : PTypeInfo; @@ -356,7 +373,7 @@ Begin Add('type'); Add(Format(' T%s = class(T%s)', [nmForm,nmAncestor])); Add(' private'); - Add(' { private declarations}'); + Add(' { private declarations }'); Add(' public'); Add(' { public declarations }'); Add(' end;'); @@ -448,15 +465,7 @@ end; Procedure TSourceEditor.ReParent(AParent : TWInControl); Begin -with FEditor do - Begin - Parent := AParent; - Top := 25; - Left := 0; - Align := alClient; - Width := TWinControl(FAOwner).ClientWidth - 10;//clientwidth;//500; - Height :=TWinControl(FAOwner).ClientHeight -10;//clientheight;//250; - end; +CreateEditor(FAOwner,AParent); End; @@ -515,7 +524,8 @@ Var Notebook_Just_Created : Boolean; PageIndex : Integer; begin - Notebook_Just_Created := (not assigned(Notebook1)) or (Notebook1.Pages.Count = 0); + Notebook_Just_Created := (not assigned(Notebook1)) or + (Notebook1.Pages.Count = 0); if Notebook_Just_Created then TempSourceEditor := NewSe(0) @@ -535,7 +545,7 @@ Function TSOurceNotebook.NewSe(PageNum : Integer) : TSourceEditor; Begin if CreateNotebook then Pagenum := 0; -if Pagenum = -1 then +if Pagenum = -1 then //add a new page Pagenum := Notebook1.Pages.Add('title'); Result := TSourceEditor.Create(Self,Notebook1.Page[PageNum]); Notebook1.Pageindex := Pagenum; @@ -586,10 +596,15 @@ Begin TempEditor := Controls[I]; Break; end; - if SE.Editor = TempEditor then Break; + if SE.Editor = TempEditor then Begin + Writeln('The editor was found on page '+inttostr(x)); + Break; + end; End; - if X < Notebook1.Pages.Count then +Writeln('X = '+inttostr(x)); + + if SE.Editor = TempEditor then Begin Notebook1.PageIndex := X; //Bringtofront does not work yet.