dockmanager example: MakeSite starts to work, but deserves more considerations

git-svn-id: trunk@22887 -
This commit is contained in:
dodi 2009-12-01 09:07:17 +00:00
parent 456e38d5f8
commit 69cdb386e1
9 changed files with 2189 additions and 2169 deletions

View File

@ -6,9 +6,8 @@
<General>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="8"/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -33,14 +32,14 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="42">
<Units Count="49">
<Unit0>
<Filename Value="MakeSite.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="MakeSite"/>
<CursorPos X="51" Y="18"/>
<CursorPos X="1" Y="14"/>
<TopLine Value="1"/>
<UsageCount Value="96"/>
<UsageCount Value="101"/>
</Unit0>
<Unit1>
<Filename Value="fmastersite.pas"/>
@ -51,18 +50,18 @@
<CursorPos X="1" Y="52"/>
<TopLine Value="28"/>
<EditorIndex Value="0"/>
<UsageCount Value="96"/>
<UsageCount Value="101"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\package\umakesite.pas"/>
<UnitName Value="uMakeSite"/>
<CursorPos X="39" Y="289"/>
<TopLine Value="207"/>
<EditorIndex Value="3"/>
<UsageCount Value="81"/>
<CursorPos X="1" Y="480"/>
<TopLine Value="457"/>
<EditorIndex Value="4"/>
<UsageCount Value="84"/>
<Bookmarks Count="1">
<Item0 X="1" Y="331" ID="2"/>
<Item0 X="1" Y="342" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit2>
@ -71,8 +70,8 @@
<UnitName Value="Controls"/>
<CursorPos X="15" Y="1790"/>
<TopLine Value="1767"/>
<EditorIndex Value="10"/>
<UsageCount Value="46"/>
<EditorIndex Value="8"/>
<UsageCount Value="49"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -88,17 +87,15 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fElasticSite"/>
<CursorPos X="1" Y="82"/>
<TopLine Value="63"/>
<CursorPos X="5" Y="340"/>
<TopLine Value="295"/>
<UsageCount Value="23"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="15" Y="822"/>
<TopLine Value="798"/>
<EditorIndex Value="6"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<UsageCount Value="21"/>
</Unit6>
<Unit7>
<Filename Value="fclientform.pas"/>
@ -109,7 +106,7 @@
<UnitName Value="fClientForm"/>
<CursorPos X="10" Y="38"/>
<TopLine Value="12"/>
<UsageCount Value="96"/>
<UsageCount Value="101"/>
</Unit7>
<Unit8>
<Filename Value="..\..\..\lcl\include\winapih.inc"/>
@ -132,12 +129,12 @@
<Unit11>
<Filename Value="..\package\easydocksite.pas"/>
<UnitName Value="EasyDockSite"/>
<CursorPos X="1" Y="1011"/>
<TopLine Value="988"/>
<EditorIndex Value="4"/>
<UsageCount Value="45"/>
<CursorPos X="49" Y="1142"/>
<TopLine Value="1112"/>
<EditorIndex Value="5"/>
<UsageCount Value="48"/>
<Bookmarks Count="1">
<Item0 X="1" Y="1051" ID="1"/>
<Item0 X="1" Y="1059" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit11>
@ -146,9 +143,7 @@
<UnitName Value="Forms"/>
<CursorPos X="17" Y="647"/>
<TopLine Value="624"/>
<EditorIndex Value="1"/>
<UsageCount Value="41"/>
<Loaded Value="True"/>
<UsageCount Value="42"/>
</Unit12>
<Unit13>
<Filename Value="..\..\..\lcl\include\customform.inc"/>
@ -187,10 +182,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fFloatingSite"/>
<CursorPos X="1" Y="14"/>
<TopLine Value="1"/>
<EditorIndex Value="2"/>
<UsageCount Value="43"/>
<CursorPos X="33" Y="145"/>
<TopLine Value="140"/>
<EditorIndex Value="3"/>
<UsageCount Value="46"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
@ -199,10 +194,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fDockBook"/>
<CursorPos X="1" Y="145"/>
<TopLine Value="98"/>
<EditorIndex Value="8"/>
<UsageCount Value="41"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="44"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
@ -252,15 +247,19 @@
</Unit25>
<Unit26>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<CursorPos X="3" Y="3876"/>
<TopLine Value="3836"/>
<UsageCount Value="25"/>
<CursorPos X="1" Y="2686"/>
<TopLine Value="2660"/>
<EditorIndex Value="2"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
</Unit26>
<Unit27>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<CursorPos X="3" Y="6514"/>
<TopLine Value="6468"/>
<UsageCount Value="25"/>
<CursorPos X="7" Y="5235"/>
<TopLine Value="5228"/>
<EditorIndex Value="6"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
</Unit27>
<Unit28>
<Filename Value="..\..\..\lcl\include\dragdock.inc"/>
@ -278,9 +277,7 @@
<Filename Value="..\..\..\lcl\include\application.inc"/>
<CursorPos X="1" Y="2076"/>
<TopLine Value="2053"/>
<EditorIndex Value="9"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
<UsageCount Value="27"/>
</Unit30>
<Unit31>
<Filename Value="..\..\..\lcl\include\toolbutton.inc"/>
@ -296,44 +293,34 @@
</Unit32>
<Unit33>
<Filename Value="..\package\zoneheader.inc"/>
<CursorPos X="41" Y="168"/>
<TopLine Value="145"/>
<EditorIndex Value="5"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="19"/>
</Unit33>
<Unit34>
<Filename Value="..\..\..\lcl\lclproc.pas"/>
<UnitName Value="LCLProc"/>
<CursorPos X="1" Y="2109"/>
<TopLine Value="2086"/>
<EditorIndex Value="11"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
<UsageCount Value="17"/>
</Unit34>
<Unit35>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\sysutils\sysstrh.inc"/>
<CursorPos X="29" Y="123"/>
<TopLine Value="123"/>
<EditorIndex Value="12"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
<UsageCount Value="17"/>
</Unit35>
<Unit36>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\sysutils\sysstr.inc"/>
<CursorPos X="11" Y="915"/>
<TopLine Value="914"/>
<EditorIndex Value="13"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
<UsageCount Value="17"/>
</Unit36>
<Unit37>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\sysutils\sysformt.inc"/>
<CursorPos X="12" Y="115"/>
<TopLine Value="97"/>
<EditorIndex Value="14"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
<UsageCount Value="17"/>
</Unit37>
<Unit38>
<Filename Value="..\..\..\lcl\ldockctrl.pas"/>
@ -353,9 +340,7 @@
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\streams.inc"/>
<CursorPos X="3" Y="654"/>
<TopLine Value="621"/>
<EditorIndex Value="7"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="12"/>
</Unit40>
<Unit41>
<Filename Value="..\..\..\lcl\lclmessageglue.pas"/>
@ -364,127 +349,173 @@
<TopLine Value="86"/>
<UsageCount Value="10"/>
</Unit41>
<Unit42>
<Filename Value="..\..\..\lcl\graphtype.pp"/>
<UnitName Value="GraphType"/>
<CursorPos X="1" Y="1611"/>
<TopLine Value="1588"/>
<UsageCount Value="11"/>
</Unit42>
<Unit43>
<Filename Value="MakeSite.lrs"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit43>
<Unit44>
<Filename Value="..\..\..\lcl\interfaces\win32\win32callback.inc"/>
<CursorPos X="1" Y="1223"/>
<TopLine Value="1200"/>
<EditorIndex Value="1"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit44>
<Unit45>
<Filename Value="..\..\..\lcl\include\buttoncontrol.inc"/>
<CursorPos X="1" Y="73"/>
<TopLine Value="49"/>
<UsageCount Value="11"/>
</Unit45>
<Unit46>
<Filename Value="..\..\..\lcl\include\buttons.inc"/>
<CursorPos X="6" Y="158"/>
<TopLine Value="142"/>
<UsageCount Value="10"/>
</Unit46>
<Unit47>
<Filename Value="..\..\..\lcl\include\picture.inc"/>
<CursorPos X="1" Y="652"/>
<TopLine Value="629"/>
<UsageCount Value="11"/>
</Unit47>
<Unit48>
<Filename Value="..\..\..\lcl\graphics.pp"/>
<UnitName Value="Graphics"/>
<CursorPos X="3" Y="877"/>
<TopLine Value="890"/>
<UsageCount Value="10"/>
</Unit48>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="994" Column="1" TopLine="971"/>
<Caret Line="1098" Column="69" TopLine="1074"/>
</Position1>
<Position2>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="997" Column="1" TopLine="974"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="207" Column="1" TopLine="184"/>
</Position2>
<Position3>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="999" Column="1" TopLine="976"/>
<Filename Value="fmastersite.pas"/>
<Caret Line="52" Column="1" TopLine="28"/>
</Position3>
<Position4>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1008" Column="1" TopLine="985"/>
<Caret Line="1021" Column="15" TopLine="1008"/>
</Position4>
<Position5>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1009" Column="1" TopLine="986"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="207" Column="1" TopLine="184"/>
</Position5>
<Position6>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1010" Column="1" TopLine="987"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="155" Column="7" TopLine="132"/>
</Position6>
<Position7>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1011" Column="1" TopLine="988"/>
<Caret Line="155" Column="31" TopLine="132"/>
</Position7>
<Position8>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="296" Column="1" TopLine="273"/>
<Filename Value="fmastersite.pas"/>
<Caret Line="46" Column="17" TopLine="28"/>
</Position8>
<Position9>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="304" Column="1" TopLine="281"/>
<Caret Line="623" Column="48" TopLine="586"/>
</Position9>
<Position10>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="305" Column="1" TopLine="282"/>
<Filename Value="fmastersite.pas"/>
<Caret Line="52" Column="1" TopLine="28"/>
</Position10>
<Position11>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="306" Column="1" TopLine="283"/>
<Filename Value="fmastersite.pas"/>
<Caret Line="41" Column="20" TopLine="28"/>
</Position11>
<Position12>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="289" Column="1" TopLine="266"/>
<Caret Line="227" Column="20" TopLine="211"/>
</Position12>
<Position13>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="290" Column="1" TopLine="267"/>
<Caret Line="614" Column="10" TopLine="597"/>
</Position13>
<Position14>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="291" Column="1" TopLine="268"/>
<Caret Line="836" Column="38" TopLine="802"/>
</Position14>
<Position15>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="292" Column="1" TopLine="269"/>
<Caret Line="838" Column="33" TopLine="805"/>
</Position15>
<Position16>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="293" Column="1" TopLine="270"/>
<Caret Line="227" Column="20" TopLine="211"/>
</Position16>
<Position17>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="294" Column="1" TopLine="271"/>
<Caret Line="479" Column="1" TopLine="457"/>
</Position17>
<Position18>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="295" Column="1" TopLine="272"/>
<Caret Line="841" Column="46" TopLine="805"/>
</Position18>
<Position19>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1006" Column="1" TopLine="983"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="480" Column="16" TopLine="451"/>
</Position19>
<Position20>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1008" Column="1" TopLine="985"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="434" Column="13" TopLine="412"/>
</Position20>
<Position21>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1009" Column="1" TopLine="986"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="475" Column="12" TopLine="465"/>
</Position21>
<Position22>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1010" Column="1" TopLine="987"/>
<Filename Value="fmastersite.pas"/>
<Caret Line="52" Column="1" TopLine="28"/>
</Position22>
<Position23>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1011" Column="1" TopLine="988"/>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="480" Column="1" TopLine="457"/>
</Position23>
<Position24>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="296" Column="1" TopLine="273"/>
<Caret Line="482" Column="1" TopLine="459"/>
</Position24>
<Position25>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="309" Column="1" TopLine="286"/>
<Caret Line="483" Column="1" TopLine="460"/>
</Position25>
<Position26>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="310" Column="1" TopLine="287"/>
<Caret Line="497" Column="1" TopLine="474"/>
</Position26>
<Position27>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="311" Column="1" TopLine="288"/>
<Caret Line="480" Column="1" TopLine="457"/>
</Position27>
<Position28>
<Filename Value="fmastersite.pas"/>
<Caret Line="52" Column="1" TopLine="28"/>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1147" Column="21" TopLine="1112"/>
</Position28>
<Position29>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="274" Column="1" TopLine="251"/>
<Filename Value="..\..\..\lcl\interfaces\win32\win32callback.inc"/>
<Caret Line="1223" Column="1" TopLine="1200"/>
</Position29>
<Position30>
<Filename Value="..\package\fdockbook.pas"/>
<Caret Line="271" Column="1" TopLine="236"/>
<Filename Value="..\package\easydocksite.pas"/>
<Caret Line="1142" Column="49" TopLine="1112"/>
</Position30>
</JumpHistory>
</ProjectOptions>
@ -503,15 +534,11 @@
</Other>
</CompilerOptions>
<Debugging>
<BreakPoints Count="2">
<BreakPoints Count="1">
<Item1>
<Source Value="fmastersite.pas"/>
<Line Value="52"/>
</Item1>
<Item2>
<Source Value="..\package\umakesite.pas"/>
<Line Value="306"/>
</Item2>
</BreakPoints>
<Exceptions Count="3">
<Item1>

View File

@ -7,12 +7,11 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, fMasterSite, fclientform, EasyDockMgr, LResources;
Forms, fMasterSite, fclientform, EasyDockMgr;
{$IFDEF WINDOWS}{$R MakeSite.rc}{$ENDIF}
begin
{$I MakeSite.lrs}
Application.Initialize;
Application.CreateForm(TMasterSite, MasterSite);
Application.Run;

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@
<Description Value="EasyDocking Manager and Notebook"/>
<License Value="LGPL"/>
<Version Major="1"/>
<Files Count="10">
<Files Count="7">
<Item1>
<Filename Value="easydocksite.pas"/>
<UnitName Value="EasyDockSite"/>
@ -39,26 +39,13 @@
<UnitName Value="fFloatingSite"/>
</Item5>
<Item6>
<Filename Value="felasticsite.lfm"/>
<Type Value="LFM"/>
</Item6>
<Item7>
<Filename Value="felasticsite.lrs"/>
<Type Value="LRS"/>
</Item7>
<Item8>
<Filename Value="felasticsite.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="fElasticSite"/>
</Item8>
<Item9>
<Filename Value="uminirestore.pas"/>
<UnitName Value="uMiniRestore"/>
</Item9>
<Item10>
</Item6>
<Item7>
<Filename Value="umakesite.pas"/>
<UnitName Value="uMakeSite"/>
</Item10>
</Item7>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">

View File

@ -7,14 +7,13 @@ unit EasyDockMgr;
interface
uses
EasyDockSite, fDockBook, fFloatingSite, fElasticSite, uMiniRestore,
uMakeSite, LazarusPackageIntf;
EasyDockSite, fDockBook, fFloatingSite, uMiniRestore, uMakeSite,
LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('fElasticSite', @fElasticSite.Register);
end;
initialization

View File

@ -202,7 +202,10 @@ type
TEasyTree = class(TEasyDockManager)
private
FReplaceZone,
{$IFDEF replace}
FReplaceZone: TEasyZone;
{$ELSE}
{$ENDIF}
FTopZone: TEasyZone;
FSiteRect: TRect; //to detect changed site extent
procedure UpdateTree;
@ -212,11 +215,10 @@ type
procedure EndUpdate; override;
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
var DockRect: TRect); override;
procedure SetReplacingControl(Control: TControl); override; //unused
{$ELSE}
//in base class
procedure SetReplacingControl(Control: TControl); override;
{$ENDIF}
procedure SetReplacingControl(Control: TControl); override;
//extended interface
//procedure ControlVisibilityChanged(Control: TControl; Visible: Boolean); override;
function ZoneFromPoint(SitePos: TPoint): TEasyZone;
@ -225,6 +227,7 @@ type
DropCtl: TControl); override;
procedure RemoveControl(Control: TControl); override;
procedure ResetBounds(Force: Boolean); override; //site resized
function ReloadDockedControl(const AName: string): TControl; virtual;
procedure LoadFromStream(Stream: TStream); override;
procedure SaveToStream(Stream: TStream); override;
protected //added
@ -1010,6 +1013,11 @@ begin
Stream.Write(ZoneRec, sizeof(ZoneRec));
end;
function TEasyTree.ReloadDockedControl(const AName: string): TControl;
begin
TWinControlAccess(DockSite).ReloadDockedControl(ZoneName, Result);
end;
procedure TEasyTree.LoadFromStream(Stream: TStream);
function GetRec: integer;
@ -1018,11 +1026,15 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
begin
Stream.Read(ZoneRec, SizeOf(ZoneRec));
NameLen := ZoneRec.NameLen;
if NameLen > 0 then begin
SetLength(ZoneName, NameLen);
if NameLen > 0 then
Stream.Read(ZoneName[1], NameLen);
end;
Result := ZoneRec.Level;
//debug
if Result > 0 then
DebugLn('reload %s @%d [%d,%d]', [ZoneName, Result, ZoneRec.BottomRight.x, ZoneRec.BottomRight.y])
else
DebugLn('reload done');
end;
procedure MakeZone(InZone: TEasyZone; Level: byte);
@ -1038,6 +1050,7 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
if ZoneRec.Level = Level then begin
//create zone at Level in InZone
if ZoneRec.NameLen > 0 then begin
//we can NOT expect that Reload... is overridden!?
TWinControlAccess(DockSite).ReloadDockedControl(ZoneName, NewCtl);
fSkip := NewCtl = nil;
end else
@ -1049,6 +1062,7 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
NewZone.BR := ZoneRec.BottomRight;
NewZone.ChildControl := NewCtl;
InZone.InsertAfter(PrevZone, NewZone);
NewCtl.Visible := True;
PrevZone := NewZone;
end;
//else skip zone without control - at Level!?
@ -1060,13 +1074,78 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
end; //until GetRec < Level;
end;
procedure MakeZones;
var
PrevZone, NewZone: TEasyZone;
PrevLvl, NewLvl: byte;
NewCtl: TControl;
begin
PrevZone := FTopZone;
PrevLvl := 1;
while GetRec > 0 do begin
NewLvl := ZoneRec.Level;
NewZone := TEasyZone.Create(self);
NewZone.Orientation := ZoneRec.Orientation;
NewZone.BR := ZoneRec.BottomRight;
if ZoneRec.NameLen > 0 then begin
//we can NOT expect that Reload... is overridden!?
NewCtl := ReloadDockedControl(ZoneName);
//do we need a control in any case?
if NewCtl = nil then begin
NewCtl := TPanel.Create(DockSite);
end;
try
DebugLn('try rename %s into %s', [NewCtl.Name, ZoneName]);
NewCtl.Name := ZoneName;
except
DebugLn('error rename');
end;
NewCtl.Caption := ZoneName;
if NewCtl <> nil then begin
{$IFDEF old}
NewCtl.Align := alNone;
NewCtl.Visible := True;
NewCtl.Parent := DockSite;
NewCtl.Width := ZoneRec.BottomRight.x;
NewCtl.Height := ZoneRec.BottomRight.y;
NewZone.ChildControl := NewCtl;
{$ELSE}
NewCtl.Visible := True;
NewZone.ChildControl := NewCtl;
SetReplacingControl(NewCtl);
NewCtl.ManualDock(DockSite);
NewCtl.Width := ZoneRec.BottomRight.x;
NewCtl.Height := ZoneRec.BottomRight.y;
{$ENDIF}
end;
end;
while NewLvl < PrevLvl do begin
PrevZone := PrevZone.Parent;
dec(PrevLvl);
end;
if NewLvl = PrevLvl then //add sibling
//PrevZone.AddSibling(NewZone, alRight)
PrevZone.Parent.InsertAfter(PrevZone, NewZone)
else begin //NewLvl > PrevLvl - make child
//InZone.InsertAfter(PrevZone, NewZone);
PrevZone.InsertAfter(nil, NewZone);
PrevLvl := NewLvl;
end;
PrevZone := NewZone;
end;
end;
begin
//read record
if GetRec > 0 then begin
FTopZone.BR := ZoneRec.BottomRight;
MakeZone(FTopZone, 1);
FTopZone.Orientation := ZoneRec.Orientation;
//if GetRec = 2 then MakeZone(FTopZone, 1);
MakeZones;
end;
//finish?
//remove all leafs without a child control?
ResetBounds(True);
end;
procedure TEasyTree.DumpToStream(Stream: TStream);
@ -1136,21 +1215,16 @@ begin
WriteZone(FTopZone, 0);
end;
{$IFDEF old}
procedure TEasyTree.SetReplacingControl(Control: TControl);
begin
//FReplacingControl := Control;
end;
{$ELSE}
procedure TEasyTree.SetReplacingControl(Control: TControl);
begin
(* The Control may have been undocked, until the replace request is handled.
*)
inherited SetReplacingControl(Control);
{$IFDEF replace}
FReplaceZone := FindControlZone(FTopZone, Control);
end;
{$ELSE}
{$ENDIF}
end;
procedure TEasyTree.SetSingleCaption(Value: boolean);
begin
@ -1735,6 +1809,7 @@ end;
initialization
{$I easy_dock_images.lrs}
//DefaultDockManagerClass := TEasyTree;
CreateDockHeaderImages;
finalization
DestroyDockHeaderImages;

View File

@ -337,6 +337,6 @@ end;
initialization
{$I felasticsite.lrs}
DefaultDockManagerClass := TEasyTree;
//DefaultDockManagerClass := TEasyTree;
end.

View File

@ -16,6 +16,8 @@ As with DockBook, closing docked forms results in Exceptions :-(
{$mode objfpc}{$H+}
{$DEFINE appdock}
interface
uses
@ -32,18 +34,32 @@ type
NewTarget: TWinControl; var Allow: Boolean);
protected
procedure Loaded; override;
{$IFDEF appdock}
{$ELSE}
procedure ReloadDockedControl(const AControlName: string;
var AControl: TControl); override;
{$ENDIF}
public
procedure UpdateCaption(without: TControl);
end;
var
FloatingSite: TFloatingSite;
//FloatingSite: TFloatingSite;
DockGrip: TPicture;
implementation
uses
LCLproc, //debugging only
EasyDockSite; //our DockManager
EasyDockSite, //our DockManager
uMakeSite;
type
{$IFDEF appdock}
TOurDockManager = TAppDockManager;
{$ELSE}
TOurDockManager = TEasyTree;
{$ENDIF}
{ TFloatingSite }
@ -143,8 +159,12 @@ begin
(* select and configure the docking manager.
*)
inherited Loaded;
if DockGrip = nil then begin
DockGrip := TPicture.Create; //(Application);
DockGrip.Assign(self.Image1.Picture);
end;
if DockManager = nil then
DockManager := TEasyTree.Create(self);
DockManager := TOurDockManager.Create(self);
if DockManager is TEasyTree then begin
//adjust as desired (order required!?)
TEasyTree(DockManager).HideSingleCaption := True; //only show headers for multiple clients
@ -152,6 +172,20 @@ begin
end;
end;
{$IFDEF appdock}
{$ELSE}
procedure TFloatingSite.ReloadDockedControl(const AControlName: string;
var AControl: TControl);
begin
inherited ReloadDockedControl(AControlName, AControl);
if AControl = nil then begin
AControl := TForm.Create(Application);
//make dock client
//if uMakeSite...
end;
end;
{$ENDIF}
initialization
{$I ffloatingsite.lrs}

View File

@ -50,6 +50,11 @@ type
public
end;
TAppDockManager = class(TEasyTree)
protected
function ReloadDockedControl(const AName: string): TControl; override;
end;
(* The owner of all docksites (if ownSites is defined),
and of all dockable window grips (if ownGrips is defined)
*)
@ -59,36 +64,87 @@ type
X, Y: Integer);
procedure FormEndDock(Sender, Target: TObject; X, Y: Integer);
protected //utilities
function ReloadForm(const AName: string): TCustomForm; virtual;
function ReloadForm(const AName: string): TWinControl; virtual;
function WrapDockable(Client: TControl): TFloatingSite;
private
LastSite: TFloatingSite;
//LastSite: TFloatingSite; //last floating site created
LastPanel: TPanel; //last elastic panel created
public
Factory: TWinControl; //generic owner
constructor Create(AOwner: TComponent); override;
procedure AddElasticSites(AForm: TCustomForm; Sides: sDockSides);
function CreateDockable(const AName: string; fMultiInst: boolean; fWrap: boolean = True): TCustomForm;
function CreateDockable(const AName: string; fMultiInst: boolean; fWrap: boolean = True): TWinControl;
procedure DumpSites;
//persistence
procedure LoadFromStream(Stream: TStream);
procedure SaveToStream(Stream: TStream);
end;
function ReloadDockedControl(const ControlName: string; Site: TWinControl): TControl;
function ReloadDockSite(const SiteName, ParentName: string; Aligned: TAlign): TWinControl;
var
DockMaster: TDockMaster; //for access by docksites on Reload...
implementation
uses
LCLIntf, LCLProc;
//fMasterSite,
type
TWinControlAccess = class(TWinControl)
end;
TControlAccess = class(TControl)
end;
const
const //what characters are acceptable, for unique names?
PanelNames: array[TAlign] of string = (
'', '', //alNone, alTop,
'pnlBottom', 'pnlLeft', 'pnlRight',
'_Elastic_Bottom_', '_Elastic_Left_', '_Elastic_Right_',
'', '' //alClient, alCustom
);
function ReloadDockedControl(const ControlName: string; Site: TWinControl): TControl;
var
wc: TWinControlAccess absolute Result;
ctl: TControlAccess absolute Result;
begin
(* Reload a previously docked control for Site and make it dockable.
Notebooks are assumed to be owned by the Site.
Forms are assumed to be owned by Application???
Others are assumed to be owned by ???
*)
Result := nil;
if (DockMaster <> nil) and (DockMaster.Factory <> nil) then begin
TWinControlAccess(DockMaster.Factory).ReLoadDockedControl(ControlName, Result);
//if Result <> nil then exit; //done
end;
if Result = nil then begin
//create something
end;
if ctl.DragKind <> dkDock then begin
//make it dockable
{$IFDEF new}
if Result is TCustomForm then
MakeDockable(Result)
else
{$ELSE}
{$ENDIF}
begin
ctl.DragKind := dkDock;
ctl.DragMode := dmAutomatic;
end;
end;
end;
function ReloadDockSite(const SiteName, ParentName: string; Aligned: TAlign): TWinControl;
begin
(* Create a DockSite.
When ParentName='' then creste a TFloatingSite,
else create an elastic panel within the given parent.
*)
end;
{ TDockMaster }
procedure TDockMaster.AddElasticSites(AForm: TCustomForm; Sides: sDockSides);
@ -111,12 +167,13 @@ begin
{$ELSE}
pnl := TDockPanel.Create(AForm); //owned by?
{$ENDIF}
LastPanel := pnl; //for reload layout
pnl.Name := PanelNames[side];
pnl.Parent := AForm;
pnl.Align := side;
pnl.BorderWidth := 1;
//pnl.BorderStyle := bsSingle; // does not properly handle the size
dm := TEasyTree.Create(pnl);
dm := TAppDockManager.Create(pnl);
dm.SetStyle(hsForm);
pnl.DockSite := True;
pnl.UseDockManager := True;
@ -142,8 +199,17 @@ begin
end;
end;
constructor TDockMaster.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
DebugLn('dockmgr=%s', [DefaultDockManagerClass.ClassName]);
DefaultDockManagerClass := TAppDockManager;
if DockMaster = nil then
DockMaster := self;
end;
function TDockMaster.CreateDockable(const AName: string;
fMultiInst: boolean; fWrap: boolean): TCustomForm;
fMultiInst: boolean; fWrap: boolean): TWinControl;
var
img: TImage;
r: TRect;
@ -154,7 +220,7 @@ begin
Used also to restore a layout.
Options (to come or to be removed)
fMultiInst allows to auto-create new versions (if True),
fMultiInst allows to auto-create new instances (if True),
otherwise an already existing instance is returned. (really returned?)
*)
//get the form
@ -173,7 +239,6 @@ Options (to come or to be removed)
Site := WrapDockable(Result);
end;
//create a docking handle - should become a component?
if LastSite <> nil then begin //problem: find grabber picture!?
img := TImage.Create(Result); //we could own the img, and be notified when its parent becomes nil
img.Parent := Result;
img.Align := alNone;
@ -182,10 +247,16 @@ Options (to come or to be removed)
r.bottom := 16;
r.Left := r.Right - 16;
img.BoundsRect := r;
img.Picture := LastSite.Image1.Picture;
if DockGrip <> nil then //problem: find grabber picture!?
try
img.Picture := DockGrip;
except
DebugLn('exception loading picture');
end;
//else???
img.OnMouseMove := @DockHandleMouseMove;
img.Visible := True;
end;
//make visible, so that it can be docked without problems
Result.Visible := True;
end;
@ -211,6 +282,7 @@ end;
type
RSiteRec = packed record
Bounds: TRect;
Align: TAlign;
NameLen: byte; //+name
end;
var
@ -220,8 +292,12 @@ var
procedure TDockMaster.LoadFromStream(Stream: TStream);
var
ctl, pre: TControl;
site: TFloatingSite;
site: TWinControl;
host: TForm;
hcomp: TComponent absolute host;
nb: TEasyBook;
hostname: string;
i: integer;
procedure MakeForm;
begin
@ -236,6 +312,10 @@ var
SetLength(SiteName, SiteRec.NameLen);
if Result and (SiteRec.NameLen > 0) then
Stream.Read(SiteName[1], SiteRec.NameLen);
if Result then
DebugLn('reload site %s', [SiteName])
else
DebugLn('reload site done');
end;
begin
@ -269,28 +349,44 @@ Notebooks?
end;
{$ELSE}
{$ENDIF}
//restore all DockSites
//all floating sites
Stream.Position := 0; //rewind!
//restore all floating sites
while ReadSite do begin
if SiteRec.NameLen = 0 then begin
//floating site
site := TFloatingSite.Create(self);
site.Name := SiteName;
end else begin
//hosted panel - find parent form
if Factory = nil then
hcomp := Application.FindComponent(SiteName)
else begin
hcomp := Factory.FindComponent(SiteName);
//hcomp := Factory.ReloadDockedControl(SiteName); - reload form!?
end;
if (hcomp = nil) or not (hcomp is TWinControl) then
host := TForm.Create(Application);
AddElasticSites(host, [SiteRec.Align]);
site := LastPanel;
end;
site.BoundsRect := SiteRec.Bounds;
if site.DockManager = nil then
TAppDockManager.Create(site);
site.DockManager.LoadFromStream(Stream);
end;
//all ElasticSites - to come
end;
procedure TDockMaster.SaveToStream(Stream: TStream);
procedure SaveSite(Site: TWinControl);
procedure SaveSite(Site: TWinControl; const AName: string);
begin
(* what if a site doesn't have an DockManager?
*)
SiteRec.Bounds := Site.BoundsRect;
SiteName := Site.Name;
SiteName := AName;
SiteRec.Align := Site.Align;
SiteRec.NameLen := Length(SiteName);
Stream.Write(SiteRec, sizeof(SiteRec));
if SiteName <> '' then
if AName <> '' then
Stream.Write(SiteName[1], Length(SiteName));
Site.DockManager.SaveToStream(Stream);
end;
@ -302,8 +398,14 @@ var
begin
for i := 0 to ComponentCount - 1 do begin
cmp := Components[i];
if (cmp is TWinControl) and wc.DockSite then
SaveSite(wc);
if (cmp is TWinControl) and wc.DockSite then begin
if wc.Parent = nil then
SaveSite(wc, '') //save top level sites
else begin
//elastic site - not yet
//SaveSite(wc, {wc.Name + '@' +} wc.Parent.Name); //elastic site
end;
end;
end;
//end marker
SiteRec.Bounds.Right := -1;
@ -311,20 +413,47 @@ begin
Stream.Write(SiteRec, sizeof(SiteRec));
end;
function TDockMaster.ReloadForm(const AName: string): TCustomForm;
function TDockMaster.ReloadForm(const AName: string): TWinControl;
var
basename, instname: string;
i, l, instno: integer;
fc: TFormClass;
fc: TWinControlClass;
fo: TComponent; //form owner
ctl: TControl;
cmp: TComponent absolute Result;
const
digits = ['0'..'9'];
procedure SplitName;
var
i, l, instno: integer;
begin
//find the instance number, if present
instno := 0;
l := Length(AName);
i := l;
while AName[i] in digits do
dec(i);
//i now is the position of the last non-digit in the name
//extract the instance number
basename := Copy(AName, 1, i);
while i < l do begin
inc(i);
instno := instno * 10 + ord(AName[i])-ord('0');
end;
//single/multi instance?
if instno = 0 then
instno := 1; //default instance number for forms
//lookup existing instance
instname := basename + IntToStr(instno);
end;
begin
(* Get a form from the Factory, or search/create it.
The name is split into basename and instance number.
A component of T<basename> is created (and named AName - automatic!).
Result type? (a TWinControl is sufficient as a DockSite)
*)
Result := nil;
//check if Factory can provide the form
@ -343,34 +472,24 @@ begin
fo := Self; //we own the forms
{$ENDIF}
if AName = '' then begin
//if True then begin
//test!
//Result := TFloatingSite.Create(fo); //named Form1, Form2...
Result := TForm.Create(fo); //named Form1, Form2...
end else begin
//find the instance number, if present
instno := 0;
l := Length(AName);
i := l;
while AName[i] in digits do begin
dec(i);
end;
//i now is the position of the last non-digit in the name
//extract the instance number
basename := Copy(AName, 1, i);
while i < l do begin
inc(i);
instno := instno * 10 + ord(AName[i])-ord('0');
end;
if instno = 0 then
instno := 1; //default instance number for forms
//lookup existing instance
instname := basename + IntToStr(instno);
if fo.FindComponent(instname) <> nil then
cmp := fo.FindComponent(AName); //(instname);
//if Result <> nil then
if assigned(cmp) then begin
if cmp is TWinControl then
exit;
cmp.Free; //we NEED at least a TWinControl, of exactly the given name
end;
//create new instance
SplitName;
basename := 'T' + basename;
fc := TFormClass(GetClass(basename)); //must be registered class name!
if not assigned(fc) then
exit;
fc := nil;
fc := TWinControlClass(GetClass(basename)); //must be registered class name!
assert(assigned(fc), 'class not registered');
Result := fc.Create(fo);
if Result.Name <> AName then
Result.Name := AName; //???
@ -386,7 +505,7 @@ begin
{$ELSE}
Site := TFloatingSite.Create(Application); //the new site
{$ENDIF}
LastSite := Site;
//LastSite := Site;
Site.BoundsRect := Client.BoundsRect; //the new position and extension
Client.Align := alClient;
Client.Visible := True; //otherwise docking may be rejected
@ -461,7 +580,7 @@ const
for j := 0 to Site.DockClientCount - 1 do begin
ctl := site.DockClients[j];
s := OrientString[ctl.DockOrientation];
DebugLn(' %s.Client=%s@%s (%d,%d)[%d,%d]', [SiteName(ASite), SiteName(ctl), s,
DebugLn(' %s.Client=%s.%s@%s (%d,%d)[%d,%d]', [SiteName(ASite), ctl.Owner.Name, SiteName(ctl), s,
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
//if ctl is TFloatingSite then
if (ctl is TWinControl) and wc.DockSite then
@ -491,55 +610,17 @@ begin
DebugLn('--- dump sites ---');
for i := 0 to ComponentCount - 1 do begin
cmp := Components[i];
{$IFnDEF old}
if (cmp is TWinControl) and wc.DockSite then
DumpSite(wc)
else if ctl is TControl then begin
DebugLn('Client=%s in %s (%d,%d)[%d,%d]', [SiteName(ctl), SiteName(ctl.HostDockSite),
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
end;
{$ELSE}
if cmp is TWinControl then begin
//path
Site := TWinControl(cmp);
if Site.DockSite then begin
//reached only when ownSites is defined!
ctl := Site;
s := Format('Site=%s (%d,%d)[%d,%d]', [SiteName(ctl),
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
while ctl <> nil do begin
hds := ctl.HostDockSite <> nil;
if hds then begin
Site := ctl.HostDockSite;
if Site <> nil then
n := ' in ' + SiteName(Site) + '@' + OrientString[ctl.DockOrientation];
end else begin
Site := ctl.Parent;
if Site <> nil then
n := ' at ' + SiteName(Site) + '@' + AlignString[ctl.Align];
end;
if Site = nil then
break;
s := s + n;
ctl := Site;
end;
DebugLn(s);
//clients
Site := TWinControl(cmp);
for j := 0 to site.DockClientCount - 1 do begin
ctl := site.DockClients[j];
s := OrientString[ctl.DockOrientation];
DebugLn(' Client=%s@%s (%d,%d)[%d,%d]', [SiteName(ctl), s,
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
//if ctl is TFloatingSite then
end;
end else begin
ctl := Site;
DebugLn('Client=%s in %s (%d,%d)[%d,%d]', [SiteName(ctl), SiteName(ctl.HostDockSite),
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
end;
end;
{$ENDIF}
DebugLn('--- dump forms ---');
for i := 0 to Application.ComponentCount - 1 do begin
cmp := Application.Components[i];
DebugLn('%s: %s', [cmp.Name, cmp.ClassName]);
end;
DebugLn('--- end dump ---');
end;
@ -747,5 +828,24 @@ begin
end;
end;
{ TAppDockManager }
function TAppDockManager.ReloadDockedControl(const AName: string): TControl;
begin
if False then
Result:=inherited ReloadDockedControl(AName); //asking DockSite (very bad idea)
if assigned(DockMaster) then begin
Result := DockMaster.CreateDockable(AName, True, False);
end else begin
//Owner.FindComponent(AControlName) as TControl;
Result := Application.FindComponent(AName) as TControl;
end;
if Result <> nil then
DebugLn('Reloaded %s.%s', [Result.Owner.Name, Result.Name]);
end;
initialization
RegisterClass(TFloatingSite);
DefaultDockManagerClass := TAppDockManager;
end.