mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 11:38:19 +02:00
DockedFormEditor: Refactoring: Move SourceEditor into SourcePageControl to reduce code overhead
git-svn-id: trunk@64946 -
This commit is contained in:
parent
8191d53f6c
commit
e7b765a763
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1345,14 +1345,13 @@ components/dockedformeditor/source/dockeddesignform.pas svneol=native#text/pasca
|
||||
components/dockedformeditor/source/dockedformaccesses.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedgrip.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedmainide.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedmodulepagecontrol.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedoptionsframe.lfm svneol=native#text/plain
|
||||
components/dockedformeditor/source/dockedoptionsframe.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedoptionside.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedregister.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedresizecontrol.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedresizer.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedsourceeditorpagecontrols.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedsourcepagecontrol.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedsourcewindow.pas svneol=native#text/pascal
|
||||
components/dockedformeditor/source/dockedtools.pas svneol=native#text/pascal
|
||||
components/education/README.txt svneol=native#text/plain
|
||||
|
@ -22,7 +22,7 @@
|
||||
<CustomOptions Value="$(IDEBuildOptions)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Files Count="18">
|
||||
<Files Count="17">
|
||||
<Item1>
|
||||
<Filename Value="source\dockedregister.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
@ -62,41 +62,37 @@
|
||||
<UnitName Value="DockedDesignForm"/>
|
||||
</Item9>
|
||||
<Item10>
|
||||
<Filename Value="source\dockedmodulepagecontrol.pas"/>
|
||||
<UnitName Value="DockedModulePageControl"/>
|
||||
<Filename Value="source\dockedsourcepagecontrol.pas"/>
|
||||
<UnitName Value="DockedSourcePageControl"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
<Filename Value="source\dockedsourcewindow.pas"/>
|
||||
<UnitName Value="DockedSourceWindow"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
<Filename Value="source\dockedsourceeditorpagecontrols.pas"/>
|
||||
<UnitName Value="DockedSourceEditorPageControls"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="source\dockedanchordesigner.pas"/>
|
||||
<UnitName Value="DockedAnchorDesigner"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="source\dockedbasicanchordesigner.pas"/>
|
||||
<UnitName Value="DockedBasicAnchorDesigner"/>
|
||||
</Item14>
|
||||
<Item15>
|
||||
</Item13>
|
||||
<Item14>
|
||||
<Filename Value="source\dockedanchorcontrol.pas"/>
|
||||
<UnitName Value="DockedAnchorControl"/>
|
||||
</Item15>
|
||||
<Item16>
|
||||
</Item14>
|
||||
<Item15>
|
||||
<Filename Value="source\dockedgrip.pas"/>
|
||||
<UnitName Value="DockedGrip"/>
|
||||
</Item16>
|
||||
<Item17>
|
||||
</Item15>
|
||||
<Item16>
|
||||
<Filename Value="source\dockedoptionsframe.lfm"/>
|
||||
<Type Value="LFM"/>
|
||||
</Item17>
|
||||
<Item18>
|
||||
</Item16>
|
||||
<Item17>
|
||||
<Filename Value="source\dockedresizecontrol.pas"/>
|
||||
<UnitName Value="DockedResizeControl"/>
|
||||
</Item18>
|
||||
</Item17>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
<i18n>
|
||||
|
@ -10,10 +10,9 @@ interface
|
||||
uses
|
||||
DockedRegister, DockedStrConsts, DockedFormAccesses, DockedMainIDE,
|
||||
DockedResizer, DockedOptionsIDE, DockedOptionsFrame, DockedTools,
|
||||
DockedDesignForm, DockedModulePageControl, DockedSourceWindow,
|
||||
DockedSourceEditorPageControls, DockedAnchorDesigner,
|
||||
DockedBasicAnchorDesigner, DockedAnchorControl, DockedGrip,
|
||||
DockedResizeControl, LazarusPackageIntf;
|
||||
DockedDesignForm, DockedSourcePageControl, DockedSourceWindow,
|
||||
DockedAnchorDesigner, DockedBasicAnchorDesigner, DockedAnchorControl,
|
||||
DockedGrip, DockedResizeControl, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -37,8 +37,8 @@ uses
|
||||
// IdeIntf
|
||||
SrcEditorIntf, LazIDEIntf, FormEditingIntf, PropEdits, LazLoggerBase,
|
||||
// DockedFormEditor
|
||||
DockedResizer, DockedModulePageControl, DockedTools,
|
||||
DockedSourceEditorPageControls, DockedOptionsIDE, DockedDesignForm,
|
||||
DockedResizer, DockedSourcePageControl, DockedTools,
|
||||
DockedOptionsIDE, DockedDesignForm,
|
||||
DockedSourceWindow;
|
||||
|
||||
type
|
||||
@ -70,7 +70,7 @@ type
|
||||
|
||||
TDockedMainIDE = class(TObject)
|
||||
public
|
||||
class function GetCurrentPageControl: TModulePageControl;
|
||||
class function GetCurrentPageControl: TSourcePageControl;
|
||||
|
||||
class procedure Screen_FormAdded(Sender: TObject; AForm: TCustomForm);
|
||||
class procedure Screen_FormDel(Sender: TObject; AForm: TCustomForm);
|
||||
@ -115,11 +115,11 @@ end;
|
||||
|
||||
function TDockedTabMaster.GetTabDisplayStateEditor(ASourceEditor: TSourceEditorInterface): TTabDisplayState;
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
if ASourceEditor = nil then
|
||||
Exit(tdsNone);
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(ASourceEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(ASourceEditor);
|
||||
if LPageCtrl = nil then Exit(tdsNone);
|
||||
case LPageCtrl.PageIndex of
|
||||
0: Exit(tdsCode);
|
||||
@ -196,22 +196,22 @@ end;
|
||||
|
||||
procedure TDockedTabMaster.ShowCode(ASourceEditor: TSourceEditorInterface);
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedTabMaster.ShowCode'); {$ENDIF}
|
||||
if ASourceEditor = nil then Exit;
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(ASourceEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(ASourceEditor);
|
||||
LPageCtrl.ShowCode;
|
||||
ASourceEditor.EditorControl.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TDockedTabMaster.ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer);
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedTabMaster.ShowDesigner'); {$ENDIF}
|
||||
if ASourceEditor = nil then Exit;
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(ASourceEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(ASourceEditor);
|
||||
LPageCtrl.ShowDesigner(AIndex);
|
||||
end;
|
||||
|
||||
@ -227,10 +227,10 @@ end;
|
||||
|
||||
procedure TDockedTabMaster.OptionsModified;
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
LPageIndex: Integer;
|
||||
begin
|
||||
LPageCtrl := SourceWindows.LastActiveModulePageControl;
|
||||
LPageCtrl := SourceWindows.LastActivePageControl;
|
||||
LPageIndex := LPageCtrl.PageIndex;
|
||||
DesignForms.RemoveAllAnchorDesigner;
|
||||
SourceWindows.ShowCodeTabSkipCurrent(nil, nil);
|
||||
@ -243,7 +243,7 @@ end;
|
||||
|
||||
{ TDockedMainIDE }
|
||||
|
||||
class function TDockedMainIDE.GetCurrentPageControl: TModulePageControl;
|
||||
class function TDockedMainIDE.GetCurrentPageControl: TSourcePageControl;
|
||||
var
|
||||
LForm: TCustomForm;
|
||||
LDesignForm: TDesignForm;
|
||||
@ -256,14 +256,14 @@ begin
|
||||
if LDesignForm = nil then Exit;
|
||||
LSourceWindowIntf := LDesignForm.LastActiveSourceWindow;
|
||||
if not Assigned(LSourceWindowIntf) then Exit;
|
||||
Result := SourceWindows.FindModulePageControl(LSourceWindowIntf.ActiveEditor);
|
||||
Result := SourceWindows.FindPageControl(LSourceWindowIntf.ActiveEditor);
|
||||
end;
|
||||
|
||||
class procedure TDockedMainIDE.Screen_FormAdded(Sender: TObject; AForm: TCustomForm);
|
||||
var
|
||||
LSourceEditor: TSourceEditorInterface;
|
||||
LDesignForm: TDesignForm;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
if IsFormDesign(AForm) then
|
||||
begin
|
||||
@ -279,7 +279,7 @@ begin
|
||||
LSourceEditor := FindSourceEditorForDesigner(AForm.Designer);
|
||||
if LSourceEditor <> nil then
|
||||
begin
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(LSourceEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(LSourceEditor);
|
||||
if LPageCtrl <> nil then
|
||||
begin
|
||||
LPageCtrl.DesignForm := LDesignForm;
|
||||
@ -298,7 +298,7 @@ end;
|
||||
class procedure TDockedMainIDE.Screen_FormDel(Sender: TObject; AForm: TCustomForm);
|
||||
var
|
||||
LSourceWindow: TSourceWindow;
|
||||
LSourceEditorPageControl: TSourceEditorPageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
if IsFormDesign(AForm) then
|
||||
begin
|
||||
@ -312,12 +312,12 @@ begin
|
||||
// don't set ActiveDesignForm := nil! we can't call OnChange tab, because tab don't exist anymore
|
||||
LSourceWindow.RemoveActiveDesignForm;
|
||||
|
||||
for LSourceEditorPageControl in LSourceWindow.PageControlList do
|
||||
if LSourceEditorPageControl.PageControl.DesignForm <> nil then
|
||||
if LSourceEditorPageControl.PageControl.DesignForm.Form = AForm then
|
||||
for LPageCtrl in LSourceWindow.PageControlList do
|
||||
if LPageCtrl.DesignForm <> nil then
|
||||
if LPageCtrl.DesignForm.Form = AForm then
|
||||
begin
|
||||
LSourceEditorPageControl.PageControl.DesignForm := nil;
|
||||
LSourceEditorPageControl.PageControl.PageIndex := 0;
|
||||
LPageCtrl.DesignForm := nil;
|
||||
LPageCtrl.PageIndex := 0;
|
||||
end;
|
||||
end;
|
||||
DesignForms.Remove(AForm);
|
||||
@ -383,7 +383,7 @@ var
|
||||
LDesigner: TIDesigner;
|
||||
LSourceEditor: TSourceEditorInterface;
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
LSourceWindowIntf: TSourceEditorWindowInterface;
|
||||
LDesignForm: TDesignForm;
|
||||
begin
|
||||
@ -395,7 +395,7 @@ begin
|
||||
'] SourceWindow[' + SourceWindowCaption(LSourceEditor) + ']');
|
||||
{$ENDIF}
|
||||
// if we create directly new project then Activate is called without EditorCreate...
|
||||
if not (LSourceEditor.EditorControl.Parent.Parent is TModulePageControl) then
|
||||
if not (LSourceEditor.EditorControl.Parent.Parent is TSourcePageControl) then
|
||||
begin
|
||||
// possible is situation when we moved tab into other window
|
||||
// then was not called event EditorDestroy - that generates problems with switching tabs
|
||||
@ -405,8 +405,8 @@ begin
|
||||
EditorCreate(Sender);
|
||||
end;
|
||||
LDesigner := LSourceEditor.GetDesigner(True);
|
||||
// should be performed during EditorCreate (parent of parent is module page ctrl)
|
||||
LPageCtrl := TModulePageControl(LSourceEditor.EditorControl.Parent.Parent);
|
||||
// should be performed during EditorCreate (parent of parent is SourcePageControl)
|
||||
LPageCtrl := TSourcePageControl(LSourceEditor.EditorControl.Parent.Parent);
|
||||
if LPageCtrl = nil then Exit;
|
||||
|
||||
LDesignForm := SourceWindows.FindDesignForm(LPageCtrl);
|
||||
@ -466,25 +466,21 @@ class procedure TDockedMainIDE.EditorCreate(Sender: TObject);
|
||||
var
|
||||
LSourceEditor: TSourceEditorInterface;
|
||||
LSourceWindowIntf: TSourceEditorWindowInterface;
|
||||
LParent: TWinControl;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedMainIDE.EditorCreate'); {$ENDIF}
|
||||
LSourceEditor := Sender as TSourceEditorInterface;
|
||||
if LSourceEditor.EditorControl.Parent.Parent is TModulePageControl then Exit;
|
||||
LParent := LSourceEditor.EditorControl.Parent;
|
||||
LPageCtrl := TModulePageControl.Create(LSourceEditor.EditorControl.Owner);
|
||||
LSourceEditor.EditorControl.Parent := LPageCtrl.Pages[0]; // ! SynEdit :)
|
||||
if LSourceEditor.EditorControl.Parent.Parent is TSourcePageControl then Exit;
|
||||
LPageCtrl := TSourcePageControl.Create(LSourceEditor);
|
||||
LPageCtrl.OnChange := @TabChange;
|
||||
LPageCtrl.Parent := LParent;
|
||||
LSourceWindowIntf := TSourceEditorWindowInterface(LPageCtrl.Owner);
|
||||
SourceWindows.SourceWindow[LSourceWindowIntf].AddPageCtrl(LSourceEditor, LPageCtrl);
|
||||
LSourceWindowIntf := SourceWindowGet(LSourceEditor);
|
||||
SourceWindows.SourceWindow[LSourceWindowIntf].AddPageCtrl(LPageCtrl);
|
||||
end;
|
||||
|
||||
class procedure TDockedMainIDE.EditorDestroyed(Sender: TObject);
|
||||
var
|
||||
LSourceEditor: TSourceEditorInterface;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
LSourceWindowIntf: TSourceEditorWindowInterface;
|
||||
LDesignForm: TDesignForm;
|
||||
begin
|
||||
@ -498,9 +494,9 @@ begin
|
||||
|
||||
// parent don't exist anymore and we must search in each window...
|
||||
if Sender = nil then // but not for Sender = nil :P
|
||||
LPageCtrl := SourceWindows.LastActiveModulePageControl
|
||||
LPageCtrl := SourceWindows.LastActivePageControl
|
||||
else
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(LSourceEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(LSourceEditor);
|
||||
|
||||
if LPageCtrl = nil then Exit;
|
||||
|
||||
@ -528,7 +524,7 @@ var
|
||||
LSourceWindow: TSourceWindow;
|
||||
LDesigner: TIDesigner;
|
||||
LDesignForm: TDesignForm;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedMainIDE.TabChange'); {$ENDIF}
|
||||
// activate proper source editor window when user is clicking on page.
|
||||
@ -537,11 +533,10 @@ begin
|
||||
if LSourceWindowIntf <> SourceEditorManagerIntf.ActiveSourceWindow then
|
||||
SourceEditorManagerIntf.ActiveSourceWindow := LSourceWindowIntf;
|
||||
|
||||
LPageCtrl := TModulePageControl(Sender);
|
||||
LPageCtrl := TSourcePageControl(Sender);
|
||||
if LSourceWindowIntf.ActiveEditor = nil then Exit;
|
||||
if LPageCtrl = nil then Exit;
|
||||
|
||||
// in case there is no module and is visible page other than code page.
|
||||
LDesigner := LSourceWindowIntf.ActiveEditor.GetDesigner(True);
|
||||
LDesignForm := DesignForms.Find(LDesigner);
|
||||
if LDesignForm = nil then Exit;
|
||||
@ -567,7 +562,7 @@ var
|
||||
LSourceWindowIntf: TSourceEditorWindowInterface;
|
||||
LSourceWindow: TSourceWindow;
|
||||
LDesignForm: TDesignForm;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
LResizer: TResizer;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedMainIDE.GlobalSNOnChangeBounds'); {$ENDIF}
|
||||
@ -586,7 +581,7 @@ begin
|
||||
LSourceWindow.ActiveDesignForm := LDesignForm;
|
||||
if LDesignForm <> nil then
|
||||
begin
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(LSourceWindowIntf.ActiveEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(LSourceWindowIntf.ActiveEditor);
|
||||
if not Assigned(LPageCtrl) then Exit;
|
||||
LResizer := LPageCtrl.Resizer;
|
||||
if not Assigned(LResizer) then Exit;
|
||||
@ -600,25 +595,25 @@ class procedure TDockedMainIDE.OnShowDesignerForm(Sender: TObject; AEditor: TSou
|
||||
AComponentPaletteClassSelected: Boolean);
|
||||
var
|
||||
LDesignForm: TDesignForm;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
LSourceWindow: TSourceWindow;
|
||||
LSourceEditorInterface: TSourceEditorInterface;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedMainIDE.OnShowDesignerForm'); {$ENDIF}
|
||||
LDesignForm := DesignForms.Find(TCustomForm(Sender).Designer);
|
||||
if (LDesignForm = nil) or LDesignForm.Hiding then Exit;
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(SourceEditorManagerIntf.ActiveEditor);
|
||||
LPageCtrl := SourceWindows.FindPageControl(SourceEditorManagerIntf.ActiveEditor);
|
||||
if LPageCtrl = nil then Exit;
|
||||
|
||||
if AComponentPaletteClassSelected then
|
||||
begin
|
||||
// if form is already opened do nothing, if not then show form for active module.
|
||||
// if form is already opened do nothing, if not then show form
|
||||
for LSourceWindow in SourceWindows do
|
||||
begin
|
||||
LSourceEditorInterface := LSourceWindow.SourceWindowIntf.ActiveEditor;
|
||||
if (LSourceEditorInterface = nil) or (LSourceEditorInterface.GetDesigner(True) <> LDesignForm.Designer) then
|
||||
Continue;
|
||||
LPageCtrl := SourceWindows.FindModulePageControl(LSourceEditorInterface);
|
||||
LPageCtrl := SourceWindows.FindPageControl(LSourceEditorInterface);
|
||||
if LPageCtrl.FormPageActive then
|
||||
Exit;
|
||||
end;
|
||||
@ -667,7 +662,7 @@ end;
|
||||
|
||||
class procedure TDockedMainIDE.OnDesignRefreshPropertyValues;
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
|
||||
function RootIsSelected: Boolean;
|
||||
var
|
||||
@ -702,7 +697,7 @@ end;
|
||||
|
||||
class procedure TDockedMainIDE.OnDesignModified(Sender: TObject);
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TDockedMainIDE.OnDesignModified'); {$ENDIF}
|
||||
LPageCtrl := GetCurrentPageControl;
|
||||
@ -726,7 +721,7 @@ end;
|
||||
class procedure TDockedMainIDE.OnDesignMouseDown(Sender: TObject;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} writeln('TDockedMainIDE.OnDesignMouseDown'); {$ENDIF}
|
||||
LPageCtrl := GetCurrentPageControl;
|
||||
|
@ -1,143 +0,0 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
See the file COPYING.modifiedLGPL.txt, included in this distribution,
|
||||
for details about the license.
|
||||
*****************************************************************************
|
||||
|
||||
Author: Michael W. Vogel
|
||||
|
||||
List of ModulePageControls linked to SourceEditorInterfaces. This List is used
|
||||
in just one SourceEditor window.
|
||||
|
||||
}
|
||||
|
||||
unit DockedSourceEditorPageControls;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$modeswitch advancedrecords}
|
||||
{$modeswitch typehelpers}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
// RTL
|
||||
Classes, SysUtils, fgl,
|
||||
// LCL
|
||||
Forms,
|
||||
// IDEIntf
|
||||
SrcEditorIntf,
|
||||
// DockedFormEditor
|
||||
DockedModulePageControl;
|
||||
|
||||
type
|
||||
|
||||
{ TSourceEditorPageControl }
|
||||
|
||||
TSourceEditorPageControl = record
|
||||
PageControl: TModulePageControl;
|
||||
SourceEditor: TSourceEditorInterface;
|
||||
class operator = (Item1, Item2: TSourceEditorPageControl): Boolean;
|
||||
end;
|
||||
|
||||
{ TSourceEditorPageControls }
|
||||
|
||||
TSourceEditorPageControls = class(specialize TFPGList<TSourceEditorPageControl>)
|
||||
private
|
||||
function GetPageControl(ASrcEditor: TSourceEditorInterface): TModulePageControl;
|
||||
function GetSourceEditor(APageControl: TModulePageControl): TSourceEditorInterface;
|
||||
public
|
||||
procedure Add(ASrcEditor: TSourceEditorInterface; APageControl: TModulePageControl); overload;
|
||||
function Contains(APageControl: TModulePageControl): Boolean;
|
||||
function Contains(ASrcEditor: TSourceEditorInterface): Boolean;
|
||||
function IndexOf(APageControl: TModulePageControl): Integer; overload;
|
||||
function IndexOf(ASrcEditor: TSourceEditorInterface): Integer; overload;
|
||||
procedure Remove(ASrcEditor: TSourceEditorInterface); overload;
|
||||
public
|
||||
property PageControl[ASrcEditor: TSourceEditorInterface]: TModulePageControl read GetPageControl;
|
||||
property SourceEditor[APageControl: TModulePageControl]: TSourceEditorInterface read GetSourceEditor;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TSourceEditorPageControl }
|
||||
|
||||
class operator TSourceEditorPageControl. = (Item1, Item2: TSourceEditorPageControl): Boolean;
|
||||
begin
|
||||
Result := (Item1.PageControl = Item2.PageControl) and
|
||||
(Item1.SourceEditor = Item2.SourceEditor);
|
||||
end;
|
||||
|
||||
{ TSourceEditorPageControls }
|
||||
|
||||
function TSourceEditorPageControls.GetPageControl(ASrcEditor: TSourceEditorInterface): TModulePageControl;
|
||||
var
|
||||
LIndex: Integer;
|
||||
begin
|
||||
LIndex := IndexOf(ASrcEditor);
|
||||
if LIndex >= 0 then
|
||||
Result := Items[LIndex].PageControl
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TSourceEditorPageControls.GetSourceEditor(APageControl: TModulePageControl): TSourceEditorInterface;
|
||||
var
|
||||
LIndex: Integer;
|
||||
begin
|
||||
LIndex := IndexOf(APageControl);
|
||||
if LIndex >= 0 then
|
||||
Result := Items[LIndex].SourceEditor
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TSourceEditorPageControls.Add(ASrcEditor: TSourceEditorInterface; APageControl: TModulePageControl);
|
||||
var
|
||||
LSourceEditorPageControl: TSourceEditorPageControl;
|
||||
begin
|
||||
LSourceEditorPageControl.SourceEditor := ASrcEditor;
|
||||
LSourceEditorPageControl.PageControl := APageControl;
|
||||
Add(LSourceEditorPageControl);
|
||||
end;
|
||||
|
||||
function TSourceEditorPageControls.Contains(APageControl: TModulePageControl): Boolean;
|
||||
begin
|
||||
Result := IndexOf(APageControl) >= 0;
|
||||
end;
|
||||
|
||||
function TSourceEditorPageControls.Contains(ASrcEditor: TSourceEditorInterface): Boolean;
|
||||
begin
|
||||
Result := IndexOf(ASrcEditor) >= 0;
|
||||
end;
|
||||
|
||||
function TSourceEditorPageControls.IndexOf(APageControl: TModulePageControl): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := -1;
|
||||
for i := 0 to Count - 1 do
|
||||
if Items[i].PageControl = APageControl then
|
||||
Exit(i);
|
||||
end;
|
||||
|
||||
function TSourceEditorPageControls.IndexOf(ASrcEditor: TSourceEditorInterface): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := -1;
|
||||
for i := 0 to Count - 1 do
|
||||
if Items[i].SourceEditor = ASrcEditor then
|
||||
Exit(i);
|
||||
end;
|
||||
|
||||
procedure TSourceEditorPageControls.Remove(ASrcEditor: TSourceEditorInterface);
|
||||
var
|
||||
LIndex: Integer;
|
||||
begin
|
||||
LIndex := IndexOf(ASrcEditor);
|
||||
if LIndex < 0 then Exit;
|
||||
Delete(LIndex);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
}
|
||||
|
||||
unit DockedModulePageControl;
|
||||
unit DockedSourcePageControl;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{ $define DEBUGDOCKEDFORMEDITOR}
|
||||
@ -21,7 +21,7 @@ interface
|
||||
|
||||
uses
|
||||
// RTL
|
||||
Classes, SysUtils,
|
||||
Classes, SysUtils, fgl,
|
||||
// LCL
|
||||
Forms, ComCtrls, Controls, LCLProc,
|
||||
// IDEIntf
|
||||
@ -32,23 +32,24 @@ uses
|
||||
|
||||
type
|
||||
|
||||
{ TModulePageControl }
|
||||
{ TSourcePageControl }
|
||||
|
||||
TModulePageControl = class(TPageControl)
|
||||
TSourcePageControl = class(TPageControl)
|
||||
private
|
||||
FDesignerSetFocusAsyncCount: Integer;
|
||||
FDesignForm: TDesignForm;
|
||||
FResizer: TResizer;
|
||||
FSourceEditor: TSourceEditorInterface;
|
||||
FTabSheetAnchors: TTabSheet;
|
||||
FTabSheetCode: TTabSheet;
|
||||
FTabSheetDesigner: TTabSheet;
|
||||
procedure AsyncDesignerSetFocus({%H-}Data: PtrInt);
|
||||
procedure ModulePageControlMouseUp(Sender: TObject; {%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
|
||||
procedure SourcePageControlMouseUp(Sender: TObject; {%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
|
||||
procedure OnAdjustPage(Sender: TObject);
|
||||
protected
|
||||
procedure SetDesignForm(const AValue: TDesignForm); virtual;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
constructor Create(ASourceEditor: TSourceEditorInterface); reintroduce;
|
||||
destructor Destroy; override;
|
||||
procedure AdjustPage;
|
||||
function AnchorPageActive: Boolean;
|
||||
@ -67,32 +68,50 @@ type
|
||||
public
|
||||
property DesignForm: TDesignForm read FDesignForm write SetDesignForm;
|
||||
property Resizer: TResizer read FResizer;
|
||||
property SourceEditor: TSourceEditorInterface read FSourceEditor;
|
||||
end;
|
||||
|
||||
{ TSourcePageControls }
|
||||
|
||||
TSourcePageControls = class(specialize TFPGList<TSourcePageControl>)
|
||||
private
|
||||
function GetPageControl(ASrcEditor: TSourceEditorInterface): TSourcePageControl;
|
||||
function GetSourceEditor(APageControl: TSourcePageControl): TSourceEditorInterface;
|
||||
public
|
||||
function Contains(APageControl: TSourcePageControl): Boolean;
|
||||
function Contains(ASrcEditor: TSourceEditorInterface): Boolean;
|
||||
function IndexOf(APageControl: TSourcePageControl): Integer; overload;
|
||||
function IndexOf(ASrcEditor: TSourceEditorInterface): Integer; overload;
|
||||
procedure Remove(ASrcEditor: TSourceEditorInterface); overload;
|
||||
public
|
||||
property PageControl[ASrcEditor: TSourceEditorInterface]: TSourcePageControl read GetPageControl;
|
||||
property SourceEditor[APageControl: TSourcePageControl]: TSourceEditorInterface read GetSourceEditor;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TModulePageControl }
|
||||
{ TSourcePageControl }
|
||||
|
||||
procedure TModulePageControl.OnAdjustPage(Sender: TObject);
|
||||
procedure TSourcePageControl.OnAdjustPage(Sender: TObject);
|
||||
begin
|
||||
AdjustPage;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.ModulePageControlMouseUp(Sender: TObject;
|
||||
procedure TSourcePageControl.SourcePageControlMouseUp(Sender: TObject;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
if DesignerPageActive then
|
||||
DesignerSetFocus;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.AsyncDesignerSetFocus(Data: PtrInt);
|
||||
procedure TSourcePageControl.AsyncDesignerSetFocus(Data: PtrInt);
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.AsyncDesignerSetFocus'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.AsyncDesignerSetFocus'); {$ENDIF}
|
||||
DesignerSetFocus;
|
||||
FDesignerSetFocusAsyncCount := 0;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.SetDesignForm(const AValue: TDesignForm);
|
||||
procedure TSourcePageControl.SetDesignForm(const AValue: TDesignForm);
|
||||
begin
|
||||
if (AValue = FDesignForm) then
|
||||
// for show lfm code, if we want after editing lfm go back to form without any error
|
||||
@ -101,7 +120,7 @@ begin
|
||||
or ((AValue <> nil) and (FResizer.DesignForm = AValue)) then
|
||||
Exit;
|
||||
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.SetDesignForm: ', DbgSName(AValue)); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.SetDesignForm: ', DbgSName(AValue)); {$ENDIF}
|
||||
|
||||
FDesignForm := AValue;
|
||||
if AValue = nil then
|
||||
@ -117,111 +136,119 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TModulePageControl.Create(TheOwner: TComponent);
|
||||
constructor TSourcePageControl.Create(ASourceEditor: TSourceEditorInterface);
|
||||
var
|
||||
LParent: TWinControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.Create'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.Create'); {$ENDIF}
|
||||
|
||||
inherited Create(TheOwner);
|
||||
inherited Create(ASourceEditor.EditorControl.Owner);
|
||||
FSourceEditor := ASourceEditor;
|
||||
FDesignerSetFocusAsyncCount := 0;
|
||||
FResizer := nil;
|
||||
|
||||
TabPosition := DockedOptions.TabPosition;
|
||||
Align := alClient;
|
||||
ShowTabs := False;
|
||||
OnMouseUp := @ModulePageControlMouseUp;
|
||||
OnMouseUp := @SourcePageControlMouseUp;
|
||||
|
||||
FTabSheetCode := TTabSheet.Create(Self);
|
||||
FTabSheetCode.PageControl := Self;
|
||||
FTabSheetCode.Caption := SCode;
|
||||
|
||||
// place SynEdit into code tab
|
||||
LParent := ASourceEditor.EditorControl.Parent;
|
||||
ASourceEditor.EditorControl.Parent := FTabSheetCode;
|
||||
Parent := LParent;
|
||||
end;
|
||||
|
||||
destructor TModulePageControl.Destroy;
|
||||
destructor TSourcePageControl.Destroy;
|
||||
begin
|
||||
DesignForm := nil;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.AdjustPage;
|
||||
procedure TSourcePageControl.AdjustPage;
|
||||
begin
|
||||
if not DesignerPageActive then Exit;
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.AdjustPage'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.AdjustPage'); {$ENDIF}
|
||||
if Assigned(FResizer) then
|
||||
FResizer.AdjustResizer(nil);
|
||||
end;
|
||||
|
||||
function TModulePageControl.AnchorPageActive: Boolean;
|
||||
function TSourcePageControl.AnchorPageActive: Boolean;
|
||||
begin
|
||||
Result := ActivePage = FTabSheetAnchors;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.CreateResizer;
|
||||
procedure TSourcePageControl.CreateResizer;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.CreateResizer'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.CreateResizer'); {$ENDIF}
|
||||
if Assigned(FResizer) then
|
||||
raise Exception.Create('TModulePageControl.CreateResizer: Resizer already created');
|
||||
raise Exception.Create('TSourcePageControl.CreateResizer: Resizer already created');
|
||||
FResizer := TResizer.Create(Self);
|
||||
if not Assigned(FTabSheetDesigner) then
|
||||
CreateTabSheetDesigner;
|
||||
FResizer.Parent := FTabSheetDesigner;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.CreateTabSheetAnchors;
|
||||
procedure TSourcePageControl.CreateTabSheetAnchors;
|
||||
begin
|
||||
if not DockedOptions.AnchorTabVisible then Exit;
|
||||
if Assigned(FTabSheetAnchors) then Exit;
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.CreateTabSheetAnchors'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.CreateTabSheetAnchors'); {$ENDIF}
|
||||
FTabSheetAnchors := TTabSheet.Create(Self);
|
||||
FTabSheetAnchors.PageControl := Self;
|
||||
FTabSheetAnchors.Caption := SAnchors;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.CreateTabSheetDesigner;
|
||||
procedure TSourcePageControl.CreateTabSheetDesigner;
|
||||
begin
|
||||
if Assigned(FTabSheetDesigner) then Exit;
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.CreateTabSheetDesigner'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.CreateTabSheetDesigner'); {$ENDIF}
|
||||
FTabSheetDesigner := TTabSheet.Create(Self);
|
||||
FTabSheetDesigner.PageControl := Self;
|
||||
FTabSheetDesigner.Caption := SDesigner;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.DesignerSetFocus;
|
||||
procedure TSourcePageControl.DesignerSetFocus;
|
||||
begin
|
||||
if not Assigned(Resizer) then Exit;
|
||||
if not Assigned(DesignForm) then Exit;
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.DesignerSetFocus'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControl.DesignerSetFocus'); {$ENDIF}
|
||||
Resizer.DesignerSetFocus;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.DesignerSetFocusAsync;
|
||||
procedure TSourcePageControl.DesignerSetFocusAsync;
|
||||
begin
|
||||
if FDesignerSetFocusAsyncCount = 0 then
|
||||
Application.QueueAsyncCall(@AsyncDesignerSetFocus, 0);
|
||||
Inc(FDesignerSetFocusAsyncCount);
|
||||
end;
|
||||
|
||||
function TModulePageControl.DesignerPageActive: Boolean;
|
||||
function TSourcePageControl.DesignerPageActive: Boolean;
|
||||
begin
|
||||
Result := (ActivePage = FTabSheetDesigner) or
|
||||
(ActivePage = FTabSheetAnchors);
|
||||
end;
|
||||
|
||||
function TModulePageControl.FormPageActive: Boolean;
|
||||
function TSourcePageControl.FormPageActive: Boolean;
|
||||
begin
|
||||
Result := ActivePage = FTabSheetDesigner;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.RemoveDesignPages;
|
||||
procedure TSourcePageControl.RemoveDesignPages;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.RemoveDesignPages'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControls.RemoveDesignPages'); {$ENDIF}
|
||||
FreeAndNil(FTabSheetAnchors);
|
||||
FreeAndNil(FTabSheetDesigner);
|
||||
ShowTabs := False;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.InitPage;
|
||||
procedure TSourcePageControl.InitPage;
|
||||
begin
|
||||
ShowTabs := PageCount > 1;
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.InitPage: ShowTabs[' + ShowTabs.ToString(TUseBoolStrs.True) + ']'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControls.InitPage: ShowTabs[' + ShowTabs.ToString(TUseBoolStrs.True) + ']'); {$ENDIF}
|
||||
if ActivePage = FTabSheetDesigner then
|
||||
begin
|
||||
Resizer.Parent := FTabSheetDesigner;
|
||||
@ -242,24 +269,24 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.RefreshResizer;
|
||||
procedure TSourcePageControl.RefreshResizer;
|
||||
begin
|
||||
if not Assigned(FResizer) then Exit;
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.RefreshResizer'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControls.RefreshResizer'); {$ENDIF}
|
||||
FreeAndNil(FResizer);
|
||||
CreateResizer;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.ShowCode;
|
||||
procedure TSourcePageControl.ShowCode;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.ShowCode'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControls.ShowCode'); {$ENDIF}
|
||||
PageIndex := 0;
|
||||
InitPage;
|
||||
end;
|
||||
|
||||
procedure TModulePageControl.ShowDesigner(AIndex: Integer);
|
||||
procedure TSourcePageControl.ShowDesigner(AIndex: Integer);
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TModulePageControl.ShowDesigner'); {$ENDIF}
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourcePageControls.ShowDesigner'); {$ENDIF}
|
||||
if (AIndex = 0) or not (Pages[AIndex].TabVisible) then
|
||||
AIndex := 1;
|
||||
if PageCount <= AIndex then Exit;
|
||||
@ -269,5 +296,68 @@ begin
|
||||
OnChange(Self);
|
||||
end;
|
||||
|
||||
{ TSourcePageControls }
|
||||
|
||||
function TSourcePageControls.GetPageControl(ASrcEditor: TSourceEditorInterface): TSourcePageControl;
|
||||
var
|
||||
LIndex: Integer;
|
||||
begin
|
||||
LIndex := IndexOf(ASrcEditor);
|
||||
if LIndex >= 0 then
|
||||
Result := Items[LIndex]
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TSourcePageControls.GetSourceEditor(APageControl: TSourcePageControl): TSourceEditorInterface;
|
||||
var
|
||||
LIndex: Integer;
|
||||
begin
|
||||
LIndex := IndexOf(APageControl);
|
||||
if LIndex >= 0 then
|
||||
Result := Items[LIndex].SourceEditor
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TSourcePageControls.Contains(APageControl: TSourcePageControl): Boolean;
|
||||
begin
|
||||
Result := IndexOf(APageControl) >= 0;
|
||||
end;
|
||||
|
||||
function TSourcePageControls.Contains(ASrcEditor: TSourceEditorInterface): Boolean;
|
||||
begin
|
||||
Result := IndexOf(ASrcEditor) >= 0;
|
||||
end;
|
||||
|
||||
function TSourcePageControls.IndexOf(APageControl: TSourcePageControl): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := -1;
|
||||
for i := 0 to Count - 1 do
|
||||
if Items[i] = APageControl then
|
||||
Exit(i);
|
||||
end;
|
||||
|
||||
function TSourcePageControls.IndexOf(ASrcEditor: TSourceEditorInterface): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := -1;
|
||||
for i := 0 to Count - 1 do
|
||||
if Items[i].SourceEditor = ASrcEditor then
|
||||
Exit(i);
|
||||
end;
|
||||
|
||||
procedure TSourcePageControls.Remove(ASrcEditor: TSourceEditorInterface);
|
||||
var
|
||||
LIndex: Integer;
|
||||
begin
|
||||
LIndex := IndexOf(ASrcEditor);
|
||||
if LIndex < 0 then Exit;
|
||||
Delete(LIndex);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -32,7 +32,7 @@ uses
|
||||
// IDEIntf
|
||||
SrcEditorIntf, LazIDEIntf, FormEditingIntf, ExtendedNotebook,
|
||||
// DockedFormEditor
|
||||
DockedSourceEditorPageControls, DockedDesignForm, DockedModulePageControl,
|
||||
DockedDesignForm, DockedSourcePageControl,
|
||||
DockedOptionsIDE, DockedTools;
|
||||
|
||||
type
|
||||
@ -42,23 +42,23 @@ type
|
||||
TSourceWindow = class
|
||||
private
|
||||
FActiveDesignForm: TDesignForm;
|
||||
FDefaultNotebookPageChanged: TNotifyEvent;
|
||||
FLastActiveSourceEditor: TSourceEditorInterface;
|
||||
FLastTopParent: TControl;
|
||||
FNotebookPageChanged: TNotifyEvent;
|
||||
FPageControlList: TSourceEditorPageControls;
|
||||
FSourceEditorNotebook: TExtendedNotebook;
|
||||
FNotebook: TExtendedNotebook;
|
||||
FPageControlList: TSourcePageControls;
|
||||
FSourceWindowIntf: TSourceEditorWindowInterface;
|
||||
function GetActiveEditor: TSourceEditorInterface;
|
||||
procedure HookIntoOnPageChanged;
|
||||
procedure NoteBookPageChanged(Sender: TObject);
|
||||
procedure SetActiveDesignForm(const AValue: TDesignForm);
|
||||
procedure SourceEditorPageChanged(Sender: TObject);
|
||||
procedure UpdateEditorPageCaption(Sender: TObject);
|
||||
public
|
||||
constructor Create(ASourceWindowIntf: TSourceEditorWindowInterface);
|
||||
destructor Destroy; override;
|
||||
procedure AddPageCtrl(ASourceEditor: TSourceEditorInterface; APageControl: TModulePageControl);
|
||||
procedure AddPageCtrl(APageControl: TSourcePageControl);
|
||||
procedure AdjustPageControl;
|
||||
function FindModulePageControl(ASourceEditor: TSourceEditorInterface): TModulePageControl;
|
||||
function FindPageControl(ASourceEditor: TSourceEditorInterface): TSourcePageControl;
|
||||
procedure RemoveActiveDesignForm;
|
||||
procedure RemovePageCtrl(ASourceEditor: TSourceEditorInterface);
|
||||
public
|
||||
@ -66,7 +66,7 @@ type
|
||||
property ActiveEditor: TSourceEditorInterface read GetActiveEditor;
|
||||
property LastActiveSourceEditor: TSourceEditorInterface read FLastActiveSourceEditor write FLastActiveSourceEditor;
|
||||
property LastTopParent: TControl read FLastTopParent write FLastTopParent;
|
||||
property PageControlList: TSourceEditorPageControls read FPageControlList;
|
||||
property PageControlList: TSourcePageControls read FPageControlList;
|
||||
property SourceWindowIntf: TSourceEditorWindowInterface read FSourceWindowIntf;
|
||||
end;
|
||||
|
||||
@ -75,7 +75,7 @@ type
|
||||
TSourceWindows = class(specialize TFPGList<TSourceWindow>)
|
||||
private
|
||||
FLastActiveSourceWindow: TSourceEditorWindowInterface;
|
||||
function GetLastActiveModulePageControl: TModulePageControl;
|
||||
function GetLastActivePageControl: TSourcePageControl;
|
||||
function GetLastActiveSourceEditor: TSourceEditorInterface;
|
||||
function GetSourceWindowIntf(ASrcEditor: TSourceWindow): TSourceEditorWindowInterface;
|
||||
function GetSourceWindow(ASourceWindowIntf: TSourceEditorWindowInterface): TSourceWindow;
|
||||
@ -86,18 +86,18 @@ type
|
||||
function Contains(ASourceWindowIntf: TSourceEditorWindowInterface): Boolean;
|
||||
function Contains(ASrcEditor: TSourceWindow): Boolean;
|
||||
procedure DeleteItem(Index: Integer);
|
||||
function FindDesignForm(AModulePageCtrl: TModulePageControl): TDesignForm;
|
||||
function FindModulePageControl(ASrcEditor: TSourceEditorInterface): TModulePageControl;
|
||||
function FindDesignForm(APageCtrl: TSourcePageControl): TDesignForm;
|
||||
function FindPageControl(ASrcEditor: TSourceEditorInterface): TSourcePageControl;
|
||||
function IndexOf(ASourceWindowIntf: TSourceEditorWindowInterface): Integer; overload;
|
||||
function LastSourceEditorNotFound: Boolean;
|
||||
procedure RefreshActivePageControls;
|
||||
procedure RefreshAllPageControls;
|
||||
procedure Remove(ASourceWindowIntf: TSourceEditorWindowInterface); overload;
|
||||
procedure ShowCodeTabSkipCurrent(CurrentPageCtrl: TModulePageControl; ADesignForm: TDesignForm);
|
||||
procedure ShowCodeTabSkipCurrent(CurrentPageCtrl: TSourcePageControl; ADesignForm: TDesignForm);
|
||||
public
|
||||
property LastActiveSourceWindow: TSourceEditorWindowInterface read FLastActiveSourceWindow write FLastActiveSourceWindow;
|
||||
property LastActiveSourceEditor: TSourceEditorInterface read GetLastActiveSourceEditor write SetLastActiveSourceEditor;
|
||||
property LastActiveModulePageControl: TModulePageControl read GetLastActiveModulePageControl;
|
||||
property LastActivePageControl: TSourcePageControl read GetLastActivePageControl;
|
||||
property SourceWindowIntf[ASrcEditor: TSourceWindow]: TSourceEditorWindowInterface read GetSourceWindowIntf;
|
||||
property SourceWindow[ASourceWindowIntf: TSourceEditorWindowInterface]: TSourceWindow read GetSourceWindow;
|
||||
end;
|
||||
@ -116,46 +116,21 @@ begin
|
||||
for i := 0 to FSourceWindowIntf.ControlCount - 1 do
|
||||
if FSourceWindowIntf.Controls[i] is TExtendedNotebook then
|
||||
begin
|
||||
FSourceEditorNotebook := TExtendedNotebook(FSourceWindowIntf.Controls[i]);
|
||||
FNotebook := TExtendedNotebook(FSourceWindowIntf.Controls[i]);
|
||||
Break;
|
||||
end;
|
||||
if not Assigned(FSourceEditorNotebook) then Exit;
|
||||
FNotebookPageChanged := FSourceEditorNotebook.OnChange;
|
||||
FSourceEditorNotebook.OnChange := @SourceEditorPageChanged;
|
||||
if not Assigned(FNotebook) then Exit;
|
||||
FDefaultNotebookPageChanged := FNotebook.OnChange;
|
||||
FNotebook.OnChange := @NoteBookPageChanged;
|
||||
end;
|
||||
|
||||
function TSourceWindow.GetActiveEditor: TSourceEditorInterface;
|
||||
begin
|
||||
Result := FSourceWindowIntf.ActiveEditor;
|
||||
end;
|
||||
|
||||
procedure TSourceWindow.SetActiveDesignForm(const AValue: TDesignForm);
|
||||
procedure TSourceWindow.NoteBookPageChanged(Sender: TObject);
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
if FActiveDesignForm = AValue then Exit;
|
||||
if FActiveDesignForm <> nil then
|
||||
// don't hide now if soon form will be hidden (for example on the IDE start)
|
||||
if not FActiveDesignForm.Hiding then
|
||||
FActiveDesignForm.HideWindow;
|
||||
FActiveDesignForm := AValue;
|
||||
|
||||
LPageCtrl := FindModulePageControl(ActiveEditor);
|
||||
// important when we want back to tab where was oppened form
|
||||
if (AValue <> nil) then
|
||||
LazarusIDE.DoShowDesignerFormOfSrc(ActiveEditor);
|
||||
|
||||
if LPageCtrl = nil then Exit;
|
||||
LPageCtrl.DesignForm := AValue;
|
||||
end;
|
||||
|
||||
procedure TSourceWindow.SourceEditorPageChanged(Sender: TObject);
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
begin
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourceWindow.SourceEditorPageChanged SourceEditorWindow[' + FSourceWindowIntf.Caption + ']'); {$ENDIF}
|
||||
FNotebookPageChanged(Sender);
|
||||
LPageCtrl := FindModulePageControl(ActiveEditor);
|
||||
{$IFDEF DEBUGDOCKEDFORMEDITOR} DebugLn('TSourceWindow.NoteBookPageChanged SourceWindow[' + FSourceWindowIntf.Caption + ']'); {$ENDIF}
|
||||
FDefaultNotebookPageChanged(Sender);
|
||||
LPageCtrl := FindPageControl(ActiveEditor);
|
||||
if not Assigned(LPageCtrl) then Exit;
|
||||
if LPageCtrl.DesignerPageActive then
|
||||
begin
|
||||
@ -168,12 +143,37 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSourceWindow.GetActiveEditor: TSourceEditorInterface;
|
||||
begin
|
||||
Result := FSourceWindowIntf.ActiveEditor;
|
||||
end;
|
||||
|
||||
procedure TSourceWindow.SetActiveDesignForm(const AValue: TDesignForm);
|
||||
var
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
if FActiveDesignForm = AValue then Exit;
|
||||
if FActiveDesignForm <> nil then
|
||||
// don't hide now if soon form will be hidden (for example on the IDE start)
|
||||
if not FActiveDesignForm.Hiding then
|
||||
FActiveDesignForm.HideWindow;
|
||||
FActiveDesignForm := AValue;
|
||||
|
||||
LPageCtrl := FindPageControl(ActiveEditor);
|
||||
// important when we want back to tab where was oppened form
|
||||
if (AValue <> nil) then
|
||||
LazarusIDE.DoShowDesignerFormOfSrc(ActiveEditor);
|
||||
|
||||
if LPageCtrl = nil then Exit;
|
||||
LPageCtrl.DesignForm := AValue;
|
||||
end;
|
||||
|
||||
procedure TSourceWindow.UpdateEditorPageCaption(Sender: TObject);
|
||||
var
|
||||
LSourceEditor: TSourceEditorInterface;
|
||||
LSourceWindowIntf: TSourceEditorWindowInterface;
|
||||
begin
|
||||
// if a unit is cloned to undocked empty source editor window, the ModulePageControl
|
||||
// if a unit is cloned to undocked empty source editor window, the SourcePageControl
|
||||
// is not created, the only workaround I found is, to activate the new created
|
||||
// source editor in this window
|
||||
if not (Sender is TSourceEditorInterface) then Exit;
|
||||
@ -193,35 +193,35 @@ constructor TSourceWindow.Create(ASourceWindowIntf: TSourceEditorWindowInterface
|
||||
begin
|
||||
FLastActiveSourceEditor := nil;
|
||||
FSourceWindowIntf := ASourceWindowIntf;
|
||||
FPageControlList := TSourceEditorPageControls.Create;
|
||||
FSourceEditorNotebook := nil;
|
||||
FPageControlList := TSourcePageControls.Create;
|
||||
FNotebook := nil;
|
||||
HookIntoOnPageChanged;
|
||||
FSourceWindowIntf.AddUpdateEditorPageCaptionHandler(@UpdateEditorPageCaption);
|
||||
end;
|
||||
|
||||
destructor TSourceWindow.Destroy;
|
||||
begin
|
||||
if Assigned(FSourceEditorNotebook) then
|
||||
FSourceEditorNotebook.OnChange := FNotebookPageChanged;
|
||||
if Assigned(FNotebook) then
|
||||
FNotebook.OnChange := FDefaultNotebookPageChanged;
|
||||
FPageControlList.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TSourceWindow.AddPageCtrl(ASourceEditor: TSourceEditorInterface; APageControl: TModulePageControl);
|
||||
procedure TSourceWindow.AddPageCtrl(APageControl: TSourcePageControl);
|
||||
begin
|
||||
FPageControlList.Add(ASourceEditor, APageControl);
|
||||
FPageControlList.Add(APageControl);
|
||||
end;
|
||||
|
||||
procedure TSourceWindow.AdjustPageControl;
|
||||
var
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
LPageCtrl := FindModulePageControl(ActiveEditor);
|
||||
LPageCtrl := FindPageControl(ActiveEditor);
|
||||
if LPageCtrl <> nil then
|
||||
LPageCtrl.AdjustPage;
|
||||
end;
|
||||
|
||||
function TSourceWindow.FindModulePageControl(ASourceEditor: TSourceEditorInterface): TModulePageControl;
|
||||
function TSourceWindow.FindPageControl(ASourceEditor: TSourceEditorInterface): TSourcePageControl;
|
||||
var
|
||||
LParent: TWinControl;
|
||||
begin
|
||||
@ -230,8 +230,8 @@ begin
|
||||
LParent := ASourceEditor.EditorControl.Parent;
|
||||
while LParent <> nil do
|
||||
begin
|
||||
if LParent is TModulePageControl then
|
||||
Exit(TModulePageControl(LParent));
|
||||
if LParent is TSourcePageControl then
|
||||
Exit(TSourcePageControl(LParent));
|
||||
LParent := LParent.Parent;
|
||||
end;
|
||||
Result := nil;
|
||||
@ -262,9 +262,9 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TSourceWindows.GetLastActiveModulePageControl: TModulePageControl;
|
||||
function TSourceWindows.GetLastActivePageControl: TSourcePageControl;
|
||||
begin
|
||||
Result := FindModulePageControl(LastActiveSourceEditor);
|
||||
Result := FindPageControl(LastActiveSourceEditor);
|
||||
end;
|
||||
|
||||
function TSourceWindows.GetLastActiveSourceEditor: TSourceEditorInterface;
|
||||
@ -331,16 +331,16 @@ begin
|
||||
Delete(Index);
|
||||
end;
|
||||
|
||||
function TSourceWindows.FindDesignForm(AModulePageCtrl: TModulePageControl): TDesignForm;
|
||||
function TSourceWindows.FindDesignForm(APageCtrl: TSourcePageControl): TDesignForm;
|
||||
var
|
||||
LSourceWindow: TSourceWindow;
|
||||
LSourceEditorInterface: TSourceEditorInterface;
|
||||
begin
|
||||
Result := nil;
|
||||
if AModulePageCtrl = nil then Exit;
|
||||
if APageCtrl = nil then Exit;
|
||||
for LSourceWindow in Self do
|
||||
begin
|
||||
if AModulePageCtrl.Owner = LSourceWindow.SourceWindowIntf then
|
||||
if APageCtrl.Owner = LSourceWindow.SourceWindowIntf then
|
||||
begin
|
||||
LSourceEditorInterface := LSourceWindow.ActiveEditor;
|
||||
if LSourceEditorInterface = nil then Exit;
|
||||
@ -350,7 +350,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSourceWindows.FindModulePageControl(ASrcEditor: TSourceEditorInterface): TModulePageControl;
|
||||
function TSourceWindows.FindPageControl(ASrcEditor: TSourceEditorInterface): TSourcePageControl;
|
||||
var
|
||||
LSourceWindow: TSourceWindow;
|
||||
begin
|
||||
@ -373,18 +373,18 @@ end;
|
||||
function TSourceWindows.LastSourceEditorNotFound: Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
LSourceEditorPageControl: TSourceEditorPageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
LSourceWindow: TSourceWindow;
|
||||
begin
|
||||
if (LastActiveSourceWindow = nil) or (LastActiveSourceEditor = nil) then
|
||||
Exit(False);
|
||||
|
||||
LSourceWindow := SourceWindow[LastActiveSourceWindow];
|
||||
for LSourceEditorPageControl in LSourceWindow.PageControlList do
|
||||
for LPageCtrl in LSourceWindow.PageControlList do
|
||||
begin
|
||||
Result := True;
|
||||
for i := 0 to LastActiveSourceWindow.Count - 1 do
|
||||
if LSourceEditorPageControl.SourceEditor = LastActiveSourceWindow.Items[i] then
|
||||
if LPageCtrl.SourceEditor = LastActiveSourceWindow.Items[i] then
|
||||
begin
|
||||
Result := False;
|
||||
Break;
|
||||
@ -393,7 +393,7 @@ begin
|
||||
begin
|
||||
// after moving code editor into other window, sometimes IDE switch to other tab
|
||||
// this line prevent this.
|
||||
LSourceWindow.LastActiveSourceEditor := LSourceEditorPageControl.SourceEditor;
|
||||
LSourceWindow.LastActiveSourceEditor := LPageCtrl.SourceEditor;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
@ -403,12 +403,12 @@ end;
|
||||
procedure TSourceWindows.RefreshActivePageControls;
|
||||
var
|
||||
LSourceWindow: TSourceWindow;
|
||||
LPageCtrl: TModulePageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
for LSourceWindow in Self do
|
||||
begin
|
||||
LPageCtrl := LSourceWindow.FindModulePageControl(LSourceWindow.ActiveEditor);
|
||||
// for example LPageCtrl is nil when we clone module to new window
|
||||
LPageCtrl := LSourceWindow.FindPageControl(LSourceWindow.ActiveEditor);
|
||||
// for example LPageCtrl is nil when we clone source to new window
|
||||
if (LPageCtrl = nil) or (csDestroying in LSourceWindow.SourceWindowIntf.ComponentState) then
|
||||
Continue;
|
||||
if (LSourceWindow.ActiveEditor = nil)
|
||||
@ -428,13 +428,13 @@ end;
|
||||
procedure TSourceWindows.RefreshAllPageControls;
|
||||
var
|
||||
LSourceWindow: TSourceWindow;
|
||||
LSourceEditorPageControl: TSourceEditorPageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
for LSourceWindow in SourceWindows do
|
||||
for LSourceEditorPageControl in LSourceWindow.PageControlList do
|
||||
for LPageCtrl in LSourceWindow.PageControlList do
|
||||
begin
|
||||
LSourceEditorPageControl.PageControl.TabPosition := DockedOptions.TabPosition;
|
||||
LSourceEditorPageControl.PageControl.RefreshResizer;
|
||||
LPageCtrl.TabPosition := DockedOptions.TabPosition;
|
||||
LPageCtrl.RefreshResizer;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -449,20 +449,20 @@ begin
|
||||
LastActiveSourceWindow := nil;
|
||||
end;
|
||||
|
||||
procedure TSourceWindows.ShowCodeTabSkipCurrent(CurrentPageCtrl: TModulePageControl; ADesignForm: TDesignForm);
|
||||
procedure TSourceWindows.ShowCodeTabSkipCurrent(CurrentPageCtrl: TSourcePageControl; ADesignForm: TDesignForm);
|
||||
var
|
||||
LSourceWindow: TSourceWindow;
|
||||
LSourceEditorPageControl: TSourceEditorPageControl;
|
||||
LPageCtrl: TSourcePageControl;
|
||||
begin
|
||||
for LSourceWindow in Self do
|
||||
for LSourceEditorPageControl in LSourceWindow.PageControlList do
|
||||
if LSourceEditorPageControl.PageControl = CurrentPageCtrl then
|
||||
for LPageCtrl in LSourceWindow.PageControlList do
|
||||
if LPageCtrl = CurrentPageCtrl then
|
||||
begin
|
||||
LSourceEditorPageControl.PageControl.DesignForm := ADesignForm;
|
||||
LSourceEditorPageControl.PageControl.InitPage;
|
||||
LPageCtrl.DesignForm := ADesignForm;
|
||||
LPageCtrl.InitPage;
|
||||
end else
|
||||
if LSourceEditorPageControl.PageControl.DesignForm = ADesignForm then
|
||||
LSourceEditorPageControl.PageControl.ShowCode;
|
||||
if LPageCtrl.DesignForm = ADesignForm then
|
||||
LPageCtrl.ShowCode;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Loading…
Reference in New Issue
Block a user