dockmanager example: improved notebook behavior

git-svn-id: trunk@22683 -
This commit is contained in:
dodi 2009-11-19 15:27:33 +00:00
parent ebd7b6e721
commit 6bbef2ef01
7 changed files with 448 additions and 194 deletions

View File

@ -8,7 +8,7 @@
<TargetFileExt Value=".exe"/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="2"/>
<ActiveEditorIndexAtStart Value="5"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -33,16 +33,14 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="19">
<Units Count="32">
<Unit0>
<Filename Value="MakeSite.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="MakeSite"/>
<CursorPos X="51" Y="18"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
<UsageCount Value="65"/>
</Unit0>
<Unit1>
<Filename Value="fmastersite.pas"/>
@ -50,29 +48,29 @@
<ComponentName Value="MasterSite"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fMasterSite"/>
<CursorPos X="24" Y="35"/>
<TopLine Value="9"/>
<CursorPos X="1" Y="43"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="28"/>
<UsageCount Value="65"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\package\umakesite.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uMakeSite"/>
<CursorPos X="34" Y="212"/>
<TopLine Value="196"/>
<CursorPos X="32" Y="225"/>
<TopLine Value="195"/>
<EditorIndex Value="2"/>
<UsageCount Value="28"/>
<UsageCount Value="65"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\..\..\lcl\controls.pp"/>
<UnitName Value="Controls"/>
<CursorPos X="27" Y="1221"/>
<TopLine Value="1198"/>
<EditorIndex Value="12"/>
<UsageCount Value="14"/>
<CursorPos X="15" Y="1773"/>
<TopLine Value="1750"/>
<EditorIndex Value="9"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -80,7 +78,7 @@
<UnitName Value="ExtCtrls"/>
<CursorPos X="24" Y="1109"/>
<TopLine Value="1086"/>
<UsageCount Value="13"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="..\package\felasticsite.pas"/>
@ -90,14 +88,12 @@
<UnitName Value="fElasticSite"/>
<CursorPos X="1" Y="82"/>
<TopLine Value="63"/>
<EditorIndex Value="8"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
<UsageCount Value="24"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="10" Y="1775"/>
<TopLine Value="1752"/>
<CursorPos X="15" Y="1515"/>
<TopLine Value="1492"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
@ -107,86 +103,83 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fClientForm"/>
<CursorPos X="1" Y="57"/>
<TopLine Value="27"/>
<EditorIndex Value="6"/>
<UsageCount Value="28"/>
<CursorPos X="10" Y="38"/>
<TopLine Value="12"/>
<EditorIndex Value="8"/>
<UsageCount Value="65"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\..\..\lcl\include\winapih.inc"/>
<CursorPos X="10" Y="287"/>
<TopLine Value="263"/>
<EditorIndex Value="9"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
<UsageCount Value="16"/>
</Unit8>
<Unit9>
<Filename Value="..\..\..\lcl\include\intfbaselcl.inc"/>
<CursorPos X="3" Y="32"/>
<TopLine Value="29"/>
<EditorIndex Value="10"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
<UsageCount Value="16"/>
</Unit9>
<Unit10>
<Filename Value="..\..\..\lcl\include\lclintfh.inc"/>
<CursorPos X="10" Y="40"/>
<TopLine Value="16"/>
<EditorIndex Value="11"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
<UsageCount Value="16"/>
</Unit10>
<Unit11>
<Filename Value="..\package\easydocksite.pas"/>
<UnitName Value="EasyDockSite"/>
<CursorPos X="1" Y="924"/>
<TopLine Value="920"/>
<CursorPos X="21" Y="288"/>
<TopLine Value="265"/>
<EditorIndex Value="4"/>
<UsageCount Value="13"/>
<UsageCount Value="31"/>
<Bookmarks Count="1">
<Item0 X="1" Y="1537" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="..\..\..\lcl\forms.pp"/>
<UnitName Value="Forms"/>
<CursorPos X="19" Y="692"/>
<TopLine Value="669"/>
<CursorPos X="15" Y="577"/>
<TopLine Value="553"/>
<EditorIndex Value="3"/>
<UsageCount Value="11"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="..\..\..\lcl\include\customform.inc"/>
<CursorPos X="16" Y="1574"/>
<TopLine Value="1559"/>
<UsageCount Value="11"/>
<CursorPos X="16" Y="2424"/>
<TopLine Value="2422"/>
<EditorIndex Value="13"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\inc\objpash.inc"/>
<CursorPos X="23" Y="151"/>
<TopLine Value="128"/>
<UsageCount Value="10"/>
<UsageCount Value="7"/>
</Unit14>
<Unit15>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\cregist.inc"/>
<CursorPos X="3" Y="92"/>
<TopLine Value="88"/>
<UsageCount Value="10"/>
<UsageCount Value="7"/>
</Unit15>
<Unit16>
<Filename Value="..\package\dockhandle.pas"/>
<UnitName Value="DockHandle"/>
<CursorPos X="20" Y="22"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
<UsageCount Value="20"/>
</Unit16>
<Unit17>
<Filename Value="..\..\..\lcl\include\customimage.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="213"/>
<UsageCount Value="11"/>
<UsageCount Value="8"/>
</Unit17>
<Unit18>
<Filename Value="..\package\ffloatingsite.pas"/>
@ -194,130 +187,244 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fFloatingSite"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<CursorPos X="9" Y="24"/>
<TopLine Value="4"/>
<EditorIndex Value="1"/>
<UsageCount Value="11"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
<Filename Value="..\package\fdockbook.pas"/>
<ComponentName Value="EasyDockBook"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fDockBook"/>
<CursorPos X="5" Y="96"/>
<TopLine Value="73"/>
<EditorIndex Value="5"/>
<UsageCount Value="27"/>
<Bookmarks Count="1">
<Item0 X="1" Y="203" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="..\package\easydockmgr.pas"/>
<UnitName Value="EasyDockMgr"/>
<CursorPos X="7" Y="10"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit20>
<Unit21>
<Filename Value="..\package\fpageframe.pas"/>
<ComponentName Value="PageFrame"/>
<ResourceBaseClass Value="Frame"/>
<UnitName Value="fPageFrame"/>
<CursorPos X="1" Y="311"/>
<TopLine Value="271"/>
<UsageCount Value="16"/>
<Bookmarks Count="1">
<Item0 X="1" Y="128" ID="1"/>
</Bookmarks>
</Unit21>
<Unit22>
<Filename Value="..\..\..\lcl\include\customframe.inc"/>
<CursorPos X="3" Y="177"/>
<TopLine Value="135"/>
<UsageCount Value="16"/>
</Unit22>
<Unit23>
<Filename Value="..\..\..\lcl\lcltype.pp"/>
<UnitName Value="LCLType"/>
<CursorPos X="3" Y="118"/>
<TopLine Value="95"/>
<UsageCount Value="10"/>
</Unit23>
<Unit24>
<Filename Value="..\..\..\lcl\lmessages.pp"/>
<UnitName Value="LMessages"/>
<CursorPos X="3" Y="769"/>
<TopLine Value="746"/>
<UsageCount Value="10"/>
</Unit24>
<Unit25>
<Filename Value="..\..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\compon.inc"/>
<CursorPos X="3" Y="538"/>
<TopLine Value="535"/>
<UsageCount Value="10"/>
</Unit25>
<Unit26>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<CursorPos X="48" Y="3878"/>
<TopLine Value="3844"/>
<EditorIndex Value="12"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit26>
<Unit27>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<CursorPos X="3" Y="5101"/>
<TopLine Value="5096"/>
<EditorIndex Value="10"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit27>
<Unit28>
<Filename Value="..\..\..\lcl\include\dragdock.inc"/>
<CursorPos X="10" Y="21"/>
<TopLine Value="1"/>
<EditorIndex Value="15"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit28>
<Unit29>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<CursorPos X="1" Y="730"/>
<TopLine Value="687"/>
<EditorIndex Value="11"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit29>
<Unit30>
<Filename Value="..\..\..\lcl\include\application.inc"/>
<CursorPos X="1" Y="2074"/>
<TopLine Value="2051"/>
<EditorIndex Value="14"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit30>
<Unit31>
<Filename Value="..\..\..\lcl\include\toolbutton.inc"/>
<CursorPos X="1" Y="700"/>
<TopLine Value="677"/>
<EditorIndex Value="6"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit31>
</Units>
<JumpHistory Count="29" HistoryIndex="28">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="135" Column="1" TopLine="112"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="518" Column="1" TopLine="495"/>
</Position1>
<Position2>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="136" Column="1" TopLine="113"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="527" Column="1" TopLine="504"/>
</Position2>
<Position3>
<Filename Value="fmastersite.pas"/>
<Caret Line="36" Column="5" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="528" Column="1" TopLine="505"/>
</Position3>
<Position4>
<Filename Value="fmastersite.pas"/>
<Caret Line="37" Column="1" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="117" Column="1" TopLine="94"/>
</Position4>
<Position5>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="129" Column="1" TopLine="106"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="118" Column="1" TopLine="95"/>
</Position5>
<Position6>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="131" Column="1" TopLine="108"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="119" Column="1" TopLine="96"/>
</Position6>
<Position7>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="132" Column="1" TopLine="109"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="120" Column="1" TopLine="97"/>
</Position7>
<Position8>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="133" Column="1" TopLine="110"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="121" Column="1" TopLine="98"/>
</Position8>
<Position9>
<Filename Value="fmastersite.pas"/>
<Caret Line="36" Column="43" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="531" Column="1" TopLine="508"/>
</Position9>
<Position10>
<Filename Value="fmastersite.pas"/>
<Caret Line="14" Column="16" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="533" Column="1" TopLine="510"/>
</Position10>
<Position11>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="148" Column="11" TopLine="127"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="535" Column="1" TopLine="512"/>
</Position11>
<Position12>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="155" Column="25" TopLine="117"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="536" Column="1" TopLine="513"/>
</Position12>
<Position13>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="140" Column="21" TopLine="117"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="538" Column="1" TopLine="467"/>
</Position13>
<Position14>
<Filename Value="fclientform.pas"/>
<Caret Line="20" Column="3" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="619" Column="1" TopLine="596"/>
</Position14>
<Position15>
<Filename Value="fmastersite.pas"/>
<Caret Line="14" Column="16" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="620" Column="1" TopLine="597"/>
</Position15>
<Position16>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="31" Column="1" TopLine="9"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="623" Column="1" TopLine="600"/>
</Position16>
<Position17>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="33" Column="1" TopLine="12"/>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="730" Column="1" TopLine="687"/>
</Position17>
<Position18>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="134" Column="1" TopLine="134"/>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="3652" Column="1" TopLine="3629"/>
</Position18>
<Position19>
<Filename Value="fmastersite.pas"/>
<Caret Line="32" Column="1" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="667" Column="1" TopLine="644"/>
</Position19>
<Position20>
<Filename Value="..\package\ffloatingsite.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="658" Column="1" TopLine="635"/>
</Position20>
<Position21>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="44" Column="3" TopLine="17"/>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="1644" Column="1" TopLine="1621"/>
</Position21>
<Position22>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="48" Column="71" TopLine="46"/>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<Caret Line="5086" Column="1" TopLine="5063"/>
</Position22>
<Position23>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="66" Column="24" TopLine="43"/>
<Filename Value="..\..\..\lcl\include\customform.inc"/>
<Caret Line="1087" Column="1" TopLine="1064"/>
</Position23>
<Position24>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="156" Column="26" TopLine="131"/>
<Filename Value="..\package\fdockbook.pas"/>
<Caret Line="204" Column="1" TopLine="180"/>
</Position24>
<Position25>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="157" Column="17" TopLine="134"/>
<Filename Value="..\package\fdockbook.pas"/>
<Caret Line="205" Column="9" TopLine="180"/>
</Position25>
<Position26>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="178" Column="15" TopLine="134"/>
<Filename Value="..\..\..\lcl\include\customform.inc"/>
<Caret Line="2424" Column="16" TopLine="2422"/>
</Position26>
<Position27>
<Filename Value="..\package\umakesite.pas"/>
<Caret Line="37" Column="25" TopLine="13"/>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="3879" Column="57" TopLine="3844"/>
</Position27>
<Position28>
<Filename Value="fmastersite.pas"/>
<Caret Line="36" Column="1" TopLine="1"/>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="3878" Column="48" TopLine="3844"/>
</Position28>
<Position29>
<Filename Value="fmastersite.pas"/>
<Caret Line="43" Column="1" TopLine="1"/>
<Filename Value="..\package\fdockbook.pas"/>
<Caret Line="209" Column="1" TopLine="180"/>
</Position29>
<Position30>
<Filename Value="..\package\fdockbook.pas"/>
<Caret Line="208" Column="16" TopLine="184"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -1,3 +1,5 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TEditorSite','FORMDATA',[
'TPF0'#241#11'TEditorSite'#10'EditorSite'#4'Left'#3'b'#1#6'Height'#3','#1#5'W'
+'idth'#3#144#1#7'Caption'#6#10'EditorSite'#12'ClientHeight'#3#25#1#11'Client'

View File

@ -106,6 +106,7 @@ begin
FEdit.Parent := self;
FEdit.Visible := True;
FEdit.DragMode := dmManual; //disallow undocking
FEdit.StayDocked := True;
end;
function TEditorSite.CreateDockable(const cap: string): TWinControl;

View File

@ -58,6 +58,7 @@ LCL TODO:
//depending on widgetset or patched LCL
{.$DEFINE NoDrop} //applied DoDiPatch1?
{.$DEFINE PageFrame} //problem: notebook frame cannot Release itself
interface
@ -166,36 +167,54 @@ type
property Top: integer read GetTop;
end;
(* TEasyDockManager implements some of the abstract methods of TDockManager.
*)
TEasyDockManager = class(TDockManager)
protected
FDockSite: TWinControl;
FUpdateCount: integer;
procedure BeginUpdate; override;
procedure EndUpdate; override;
procedure Update; virtual;
procedure SetReplacingControl(Control: TControl); override; //unused
property DockSite: TWinControl read FDockSite;
public
constructor Create(ADockSite: TWinControl); override;
class function DetectAlign(ZoneRect: TRect; MousePos: TPoint): TAlign;
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
var DockRect: TRect); override;
end;
{ TEasyTree }
TEasyTree = class(TDockManager)
TEasyTree = class(TEasyDockManager)
private
FDockSite: TWinControl;
FReplacingControl: TControl;
FTopZone: TEasyZone;
FSiteRect: TRect; //to detect changed site extent
FUpdateCount: integer;
procedure UpdateTree;
protected
{$IFDEF old}
procedure BeginUpdate; override;
procedure EndUpdate; override;
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
var DockRect: TRect); override;
procedure SetReplacingControl(Control: TControl); override; //unused
{$ELSE}
//in base class
{$ENDIF}
//extended interface
//procedure ControlVisibilityChanged(Control: TControl; Visible: Boolean); override;
function ZoneFromPoint(SitePos: TPoint): TEasyZone;
procedure GetControlBounds(Control: TControl; out CtlBounds: TRect); override;
procedure InsertControl(Control: TControl; InsertAt: TAlign;
DropCtl: TControl); override;
procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
var DockRect: TRect); override;
procedure RemoveControl(Control: TControl); override;
procedure ResetBounds(Force: Boolean); override; //site resized
procedure SetReplacingControl(Control: TControl); override; //unused
procedure LoadFromStream(Stream: TStream); override;
procedure SaveToStream(Stream: TStream); override;
protected //added
procedure PositionDockRect(ADockObject: TDragDockObject); override;
property DockSite: TWinControl read FDockSite;
function FindControlZone(zone: TEasyZone; Control: TControl): TEasyZone;
procedure RemoveZone(Zone: TEasyZone);
//Lazarus extension
@ -215,7 +234,6 @@ type
{$ENDIF}
constructor Create(ADockSite: TWinControl); override;
destructor Destroy; override;
function DetectAlign(ZoneRect: TRect; MousePos: TPoint): TAlign;
procedure PaintSite(DC: HDC); override;
procedure SetStyle(NewStyle: TEasyHeaderStyle);
function GetEffectiveStyle: TEasyHeaderStyle;
@ -248,7 +266,11 @@ implementation
uses
SysUtils, Types,
math,
{$IFDEF PageFrame}
fPageFrame,
{$ELSE}
fDockBook,
{$ENDIF}
Themes, LResources,
LCLproc; //debugging
@ -260,11 +282,15 @@ const
{$ENDIF}
type
{$IFDEF PageFrame}
TEasyBook = TPageFrame;
{$ELSE}
TEasyBook = TEasyDockBook;
{$ENDIF}
function NoteBookCreate(AOwner: TWinControl): TEasyBook; inline;
begin
Result := TEasyDockBook.Create(AOwner);
Result := TEasyBook.Create(AOwner);
end;
procedure NoteBookAdd(ABook: TEasyBook; AItem: TControl); inline;
@ -318,14 +344,7 @@ constructor TEasyTree.Create(ADockSite: TWinControl);
end;
begin
FDockSite := ADockSite;
//reset inappropriate docking defaults - should be fixed in Controls/DragManager!
DragManager.DragImmediate := False;
//workaround: check for already assigned docking manager
//FreeAndNil(DockSite.DockManager); - seems to be fixed
DockSite.DockManager := self;
//init node class - impossible due to visibility restrictions!
inherited Create(DockSite);
inherited Create(ADockSite);
{$IFDEF singleTab}
//test: notebook with 1 tab in root zone
SingleTab := True;
@ -359,6 +378,7 @@ begin
inherited;
end;
{$IFDEF old}
procedure TEasyTree.BeginUpdate;
begin
inc(FUpdateCount);
@ -372,6 +392,8 @@ begin
UpdateTree;
end;
end;
{$ELSE}
{$ENDIF}
function TEasyTree.ZoneFromPoint(SitePos: TPoint): TEasyZone;
var
@ -591,54 +613,6 @@ begin
ResetBounds(True); //splitters may have to be inserted
end;
function TEasyTree.DetectAlign(ZoneRect: TRect; MousePos: TPoint): TAlign;
var
w, h, zphi: integer;
cx, cy: integer;
dx, dy: integer;
phi: double;
izone: integer;
dir: TAlign;
const
k = 5; //matrix dimension
//mapping octants into aligns, assuming k=5
cDir: array[-4..4] of TAlign = (
alLeft, alLeft, alTop, alTop, alRight, alBottom, alBottom, alLeft, alLeft
);
begin
(* Determine alignment from the location of the mouse within ZoneRect.
ZoneRect in screen TLBR coordinates, MousePos in screen coordinates.
*)
//center and extent of dock zone
cx := (ZoneRect.Right + ZoneRect.Left) div 2;
cy := (ZoneRect.Top + ZoneRect.Bottom) div 2;
w := ZoneRect.Right - ZoneRect.Left;
h := ZoneRect.Bottom - ZoneRect.Top;
if (w > 0) and (h > 0) then begin
//mouse position within k*k rectangles (squares)
dx := trunc((MousePos.x - cx) / w * k);
dy := trunc((MousePos.y - cy) / h * k);
izone := max(abs(dx), abs(dy)); //0..k
//map into 0=innermost (custom), 1=inner, 2=outer
if izone = 0 then begin
//zone := zInnermost;
dir := alCustom; //pages
end else begin
{ not yet: outer zones, meaning docking into parent zone
if izone >= k-1 then
zone := zOuter
else //if izone > 0 then
zone := zInner;
}
phi := arctan2(dy, dx);
zphi := trunc(radtodeg(phi)) div 45;
dir := cDir[zphi];
end;
end else
dir := alClient;
Result := dir;
end;
procedure TEasyTree.PositionDockRect(ADockObject: TDragDockObject);
var
zone: TEasyZone;
@ -705,6 +679,7 @@ Signal results:
end;
end;
{$IFDEF old}
procedure TEasyTree.PositionDockRect(Client, DropCtl: TControl;
DropAlign: TAlign; var DockRect: TRect);
var
@ -736,6 +711,8 @@ begin
end;
end;
end;
{$ELSE}
{$ENDIF}
procedure TEasyTree.LoadFromStream(Stream: TStream);
begin
@ -1008,10 +985,13 @@ begin
WriteZone(FTopZone, 0);
end;
{$IFDEF old}
procedure TEasyTree.SetReplacingControl(Control: TControl);
begin
//FReplacingControl := Control;
end;
{$ELSE}
{$ENDIF}
procedure TEasyTree.SetSingleCaption(Value: boolean);
begin
@ -1482,6 +1462,117 @@ begin
end; //else empty root zone?
end;
{ TEasyDockManager }
procedure TEasyDockManager.BeginUpdate;
begin
//inherited BeginUpdate;
inc(FUpdateCount);
end;
constructor TEasyDockManager.Create(ADockSite: TWinControl);
begin
(* Init DockSite and DragManager.
*)
FDockSite := ADockSite;
ADockSite.DockManager := self;
//reset inappropriate docking defaults - should be fixed in Controls/DragManager!
DragManager.DragImmediate := False;
inherited Create(ADockSite);
end;
class function TEasyDockManager.DetectAlign(ZoneRect: TRect;
MousePos: TPoint): TAlign;
var
w, h, zphi: integer;
cx, cy: integer;
dx, dy: integer;
phi: double;
izone: integer;
dir: TAlign;
const
k = 5; //matrix dimension
//mapping octants into aligns, assuming k=5
cDir: array[-4..4] of TAlign = (
alLeft, alLeft, alTop, alTop, alRight, alBottom, alBottom, alLeft, alLeft
);
begin
(* Determine alignment from the location of the mouse within ZoneRect.
ZoneRect in screen TLBR coordinates, MousePos in screen coordinates.
*)
//center and extent of dock zone
cx := (ZoneRect.Right + ZoneRect.Left) div 2;
cy := (ZoneRect.Top + ZoneRect.Bottom) div 2;
w := ZoneRect.Right - ZoneRect.Left;
h := ZoneRect.Bottom - ZoneRect.Top;
if (w > 0) and (h > 0) then begin
//mouse position within k*k rectangles (squares)
dx := trunc((MousePos.x - cx) / w * k);
dy := trunc((MousePos.y - cy) / h * k);
izone := max(abs(dx), abs(dy)); //0..k
//map into 0=innermost (custom), 1=inner, 2=outer
if izone = 0 then begin
//zone := zInnermost;
dir := alCustom; //pages
end else begin
phi := arctan2(dy, dx);
zphi := trunc(radtodeg(phi)) div 45;
dir := cDir[zphi];
end;
end else
dir := alClient;
Result := dir;
end;
procedure TEasyDockManager.EndUpdate;
begin
//inherited EndUpdate;
dec(FUpdateCount);
if FUpdateCount = 0 then
Update;
end;
procedure TEasyDockManager.PositionDockRect(Client, DropCtl: TControl;
DropAlign: TAlign; var DockRect: TRect);
var
wh: integer;
begin
(* DockRect is initialized to the screen rect of the dock site by TControl,
or to the zone rect by TEasyTree.
*)
if (DropCtl = nil) {$IFDEF singleTab} and not SingleTab {$ENDIF} then
//if (DropCtl = nil) then
exit; //entire dock site
case DropAlign of
//alClient: as is
alTop: DockRect.Bottom := (DockRect.Top + DockRect.Bottom) div 2;
alBottom: DockRect.Top := (DockRect.Top + DockRect.Bottom) div 2;
alLeft: DockRect.Right := (DockRect.Left + DockRect.Right) div 2;
alRight: DockRect.Left := (DockRect.Left + DockRect.Right) div 2;
alCustom: //pages
begin
wh := (DockRect.Right - DockRect.Left) div 3;
inc(DockRect.Left, wh);
dec(DockRect.Right, wh);
wh := (DockRect.Bottom - DockRect.Top) div 3;
inc(DockRect.Top, wh);
dec(DockRect.Bottom, wh);
end;
end;
end;
procedure TEasyDockManager.SetReplacingControl(Control: TControl);
begin
//nop
//inherited SetReplacingControl(Control);
end;
procedure TEasyDockManager.Update;
begin
//nop
end;
initialization
{$I easy_dock_images.lrs}
CreateDockHeaderImages;

View File

@ -32,6 +32,26 @@ Problem:
Disallow undocking/floating of a NOT docked dockbook.
*)
(* Applications
Stand alone form (not recommended)
Parent=Nil, HostDockSite=Nil
Not-docked part of a form (Editor)
The form should never close itself.
Parent<>Nil, HostDockSite=Nil
Part of an dock tree
The form is automatically created and docked by the EasyTree.
It must notify the tree (HostDockSite) when it has 1 client left,
for replacement by that client.
It also should notify the HostDockSite of any un/dock, to update the caption.
Parent=HostDockSite (<>Nil)
Suggested methods:
HostDockSite.ReplaceDockedControl (self by last client)
HostDockSite.UpdateDockCaption (provide composed dock caption)
*)
{$mode objfpc}{$H+}
interface
@ -75,6 +95,8 @@ type
protected
function GetDefaultDockCaption: string; override;
function GetControlTab(AControl: TControl): TTabButton;
public
StayDocked: boolean;
end;
//procedure Register;
@ -82,6 +104,8 @@ type
implementation
uses
fFloatingSite,
Windows, //PostMessage
LCLProc; //debug only
procedure Register;
@ -108,6 +132,7 @@ begin
btn := TTabButton.Create(Tabs);
btn.Control := Source.Control;
btn.Control.Align := alClient;
btn.Control.DockOrientation := doPages;
btn.Caption := GetDockCaption(btn.Control);
btn.OnClick := @ToolButton1Click;
btn.Down := True;
@ -172,15 +197,19 @@ begin
CurTab.Down := True;
CurTab.Click;
end;
end else begin
//last tab removed - close ONLY if we are docked
//if (HostDockSite <> nil) or Floating then begin - Floating doesn't work
if Parent = nil then begin //seems to be a good indicator for floating state
if (HostDockSite <> nil) then //may be cleared already???
ManualDock(nil); //undock before closing
Release; //Close;
Caption := GetDefaultDockCaption;
end else if not StayDocked then begin
//last tab removed - close ONLY if we are docked or floating
if (HostDockSite <> nil) then begin //may be cleared already???
ManualDock(nil); //undock before closing
//DoUnDock(nil, nil);
//Dock(nil);
end;
//Release; //Close;
PostMessage(Self.Handle, WM_CLOSE, 0, 0);
end;
if (HostDockSite is TFloatingSite) then
TFloatingSite(HostDockSite).UpdateCaption(nil);
end;
function TEasyDockBook.GetControlTab(AControl: TControl): TTabButton;

View File

@ -25,13 +25,11 @@ type
X, Y: Integer);
procedure FormUnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
private
procedure AdjustCaption(without: TControl);
protected
procedure Loaded; override;
public
{ public declarations }
end;
procedure UpdateCaption(without: TControl);
end;
var
FloatingSite: TFloatingSite;
@ -44,7 +42,7 @@ uses
{ TFloatingSite }
procedure TFloatingSite.AdjustCaption(without: TControl);
procedure TFloatingSite.UpdateCaption(without: TControl);
var
i: integer;
s: string;
@ -68,7 +66,7 @@ procedure TFloatingSite.FormDockDrop(Sender: TObject; Source: TDragDockObject;
begin
(* Update the caption.
*)
AdjustCaption(nil);
UpdateCaption(nil);
end;
procedure TFloatingSite.FormUnDock(Sender: TObject; Client: TControl;
@ -90,9 +88,9 @@ Fix: disallow TControls to become floating.
exit; //all done
if DockClientCount <= 1 then begin
Release; //destroy empty site
Release; //destroy empty site
end else begin
AdjustCaption(Client); //update caption, excluding removed client
UpdateCaption(Client); //update caption, excluding removed client
DockManager.ResetBounds(True); //required with gtk2!?
end;
end;

View File

@ -199,18 +199,44 @@ var
Site: TWinControl;
ctl: TControl;
cmp: TComponent;
n, s: string;
const
OrientString: array[TDockOrientation] of char = (
'N','H','V' {$IFDEF FPC} ,'P' {$ENDIF}
);
AlignString: array[TAlign] of char = (
//(alNone, alTop, alBottom, alLeft, alRight, alClient, alCustom);
'n', 't', 'B', 'L', 'R', 'C', 'c'
);
begin
(* Dump registered docking sites.
Elastic panels have no name.
Dump of docked clients by DockManager (structural info!)
Notebooks are docked, i.e. HostDockSite<>nil.
Pages are DockSites???
EditPages contain Files -> include (full?) filename
--> dump-levels
dock sites[] and clients[]
contents[]
*)
for i := 0 to ComponentCount - 1 do begin
cmp := Components[i];
if cmp is TWinControl then begin
Site := TWinControl(cmp);
DebugLn('Site=%s (%d,%d)[%d,%d]', [Site.Name,
site.Top, site.Left, site.Width, site.Height]);
if Site.Parent <> nil then begin
s := Site.Parent.Name;
if s = '' then
s := Site.Parent.ClassName;
s := ' in ' + s + '@';
s := s + AlignString[Site.Align];
end else
s := '';
DebugLn('Site=%s (%d,%d)[%d,%d] %s', [Site.Name,
site.Top, site.Left, site.Width, site.Height, s]);
for j := 0 to site.DockClientCount - 1 do begin
ctl := site.DockClients[j];
DebugLn(' Client=%s (%d,%d)[%d,%d]', [ctl.Name,
s := OrientString[ctl.DockOrientation];
DebugLn(' Client=%s@%s (%d,%d)[%d,%d]', [ctl.Name, s,
ctl.Top, ctl.Left, ctl.Width, ctl.Height]);
end;
end;