dockmanager example: moved project into subdirectory

git-svn-id: trunk@19950 -
This commit is contained in:
dodi 2009-05-13 07:27:03 +00:00
parent 3089bd0e3a
commit a4200ebb10
18 changed files with 422 additions and 489 deletions

31
.gitattributes vendored
View File

@ -2167,21 +2167,22 @@ examples/docking/project1.rc svneol=native#text/plain
examples/docking/unit1.lfm svneol=native#text/plain
examples/docking/unit1.lrs svneol=native#text/pascal
examples/docking/unit1.pas svneol=native#text/pascal
examples/dockmanager/README.txt svneol=native#text/plain
examples/dockmanager/easydockhelpers.pas svneol=native#text/plain
examples/dockmanager/easydocking.lpi svneol=native#text/plain
examples/dockmanager/easydocking.lpr svneol=native#text/plain
examples/dockmanager/easydocksite.pas svneol=native#text/plain
examples/dockmanager/fdockable.lfm svneol=native#text/plain
examples/dockmanager/fdockable.lrs svneol=native#text/plain
examples/dockmanager/fdockable.pas svneol=native#text/plain
examples/dockmanager/fmain.lfm svneol=native#text/plain
examples/dockmanager/fmain.lrs svneol=native#text/plain
examples/dockmanager/fmain.pas svneol=native#text/plain
examples/dockmanager/ftree.lfm svneol=native#text/plain
examples/dockmanager/ftree.lrs svneol=native#text/plain
examples/dockmanager/ftree.pas svneol=native#text/plain
examples/dockmanager/lcl_dock_images.lrs svneol=native#text/plain
examples/dockmanager/easytree/BUGS.txt svneol=native#text/plain
examples/dockmanager/easytree/README.txt svneol=native#text/plain
examples/dockmanager/easytree/easydockhelpers.pas svneol=native#text/plain
examples/dockmanager/easytree/easydocking.lpi svneol=native#text/plain
examples/dockmanager/easytree/easydocking.lpr svneol=native#text/plain
examples/dockmanager/easytree/easydocksite.pas svneol=native#text/plain
examples/dockmanager/easytree/fdockable.lfm svneol=native#text/plain
examples/dockmanager/easytree/fdockable.lrs svneol=native#text/plain
examples/dockmanager/easytree/fdockable.pas svneol=native#text/plain
examples/dockmanager/easytree/fmain.lfm svneol=native#text/plain
examples/dockmanager/easytree/fmain.lrs svneol=native#text/plain
examples/dockmanager/easytree/fmain.pas svneol=native#text/plain
examples/dockmanager/easytree/ftree.lfm svneol=native#text/plain
examples/dockmanager/easytree/ftree.lrs svneol=native#text/plain
examples/dockmanager/easytree/ftree.pas svneol=native#text/plain
examples/dockmanager/easytree/lcl_dock_images.lrs svneol=native#text/plain
examples/dragimagelist/project1.lpi svneol=native#text/plain
examples/dragimagelist/project1.lpr svneol=native#text/pascal
examples/dragimagelist/readme.txt svneol=native#text/plain

View File

@ -1,356 +0,0 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Title Value="EasyDocking"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="D:\Tests\dockmanager"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="23">
<Unit0>
<Filename Value="easydocking.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="EasyDocking"/>
<CursorPos X="32" Y="3"/>
<TopLine Value="1"/>
<UsageCount Value="307"/>
</Unit0>
<Unit1>
<Filename Value="fdockable.pas"/>
<ComponentName Value="Dockable"/>
<HasResources Value="True"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fDockable"/>
<CursorPos X="5" Y="43"/>
<TopLine Value="6"/>
<EditorIndex Value="11"/>
<UsageCount Value="307"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="fmain.pas"/>
<ComponentName Value="EasyDockMain"/>
<HasResources Value="True"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fMain"/>
<CursorPos X="2" Y="18"/>
<TopLine Value="1"/>
<EditorIndex Value="3"/>
<UsageCount Value="307"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="easydocksite.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="EasyDockSite"/>
<CursorPos X="48" Y="77"/>
<TopLine Value="108"/>
<EditorIndex Value="0"/>
<UsageCount Value="307"/>
<Bookmarks Count="2">
<Item0 X="1" Y="388" ID="1"/>
<Item1 X="24" Y="772" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="fTree.pas"/>
<ComponentName Value="DumpBox"/>
<HasResources Value="True"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fTree"/>
<CursorPos X="46" Y="14"/>
<TopLine Value="1"/>
<UsageCount Value="307"/>
</Unit4>
<Unit5>
<Filename Value="..\..\SourceForge\Lazarus\lcl\controls.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Controls"/>
<CursorPos X="1" Y="477"/>
<TopLine Value="466"/>
<UsageCount Value="240"/>
<Bookmarks Count="3">
<Item0 X="1" Y="2303" ID="1"/>
<Item1 X="1" Y="517" ID="2"/>
<Item2 X="32" Y="2415" ID="3"/>
</Bookmarks>
</Unit5>
<Unit6>
<Filename Value="..\..\SourceForge\Lazarus\lcl\include\wincontrol.inc"/>
<IsPartOfProject Value="True"/>
<CursorPos X="7" Y="5937"/>
<TopLine Value="5916"/>
<UsageCount Value="235"/>
<Bookmarks Count="1">
<Item0 X="1" Y="3467" ID="5"/>
</Bookmarks>
</Unit6>
<Unit7>
<Filename Value="Bugs.txt"/>
<IsPartOfProject Value="True"/>
<CursorPos X="1" Y="71"/>
<TopLine Value="29"/>
<UsageCount Value="203"/>
<SyntaxHighlighter Value="None"/>
</Unit7>
<Unit8>
<Filename Value="fFloatBook.pas"/>
<ComponentName Value="EasyFloatBook"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fFloatBook"/>
<CursorPos X="9" Y="79"/>
<TopLine Value="42"/>
<UsageCount Value="25"/>
</Unit8>
<Unit9>
<Filename Value="..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="69" Y="5"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit9>
<Unit10>
<Filename Value="..\..\..\..\lazarus\fpc\2.2.4\source\rtl\objpas\classes\compon.inc"/>
<CursorPos X="37" Y="4"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit10>
<Unit11>
<Filename Value="easydockhelpers.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="EasyDockHelpers"/>
<CursorPos X="15" Y="45"/>
<TopLine Value="24"/>
<EditorIndex Value="2"/>
<UsageCount Value="43"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="README.txt"/>
<CursorPos X="63" Y="1541"/>
<TopLine Value="1538"/>
<UsageCount Value="8"/>
<SyntaxHighlighter Value="None"/>
</Unit12>
<Unit13>
<Filename Value="fDockable.lrs"/>
<CursorPos X="11" Y="3"/>
<TopLine Value="1"/>
<UsageCount Value="8"/>
</Unit13>
<Unit14>
<Filename Value="..\..\lcl\include\wincontrol.inc"/>
<CursorPos X="1" Y="7161"/>
<TopLine Value="7140"/>
<EditorIndex Value="7"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="..\..\lcl\include\control.inc"/>
<CursorPos X="28" Y="3617"/>
<TopLine Value="3588"/>
<EditorIndex Value="5"/>
<UsageCount Value="21"/>
<Bookmarks Count="2">
<Item0 X="1" Y="3619" ID="8"/>
<Item1 X="43" Y="2506" ID="9"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit15>
<Unit16>
<Filename Value="..\..\lcl\controls.pp"/>
<UnitName Value="Controls"/>
<CursorPos X="68" Y="1341"/>
<TopLine Value="1320"/>
<EditorIndex Value="4"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="..\..\lcl\forms.pp"/>
<UnitName Value="Forms"/>
<CursorPos X="19" Y="731"/>
<TopLine Value="702"/>
<EditorIndex Value="8"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="..\..\lcl\include\customform.inc"/>
<CursorPos X="3" Y="1105"/>
<TopLine Value="1103"/>
<EditorIndex Value="10"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
<Filename Value="..\..\lcl\include\dragmanager.inc"/>
<CursorPos X="3" Y="530"/>
<TopLine Value="488"/>
<EditorIndex Value="6"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="..\..\lcl\lclproc.pas"/>
<UnitName Value="LCLProc"/>
<CursorPos X="50" Y="1618"/>
<TopLine Value="1617"/>
<UsageCount Value="10"/>
</Unit20>
<Unit21>
<Filename Value="..\..\lcl\comctrls.pp"/>
<UnitName Value="ComCtrls"/>
<CursorPos X="3" Y="267"/>
<TopLine Value="258"/>
<EditorIndex Value="1"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit21>
<Unit22>
<Filename Value="..\..\lcl\include\customdockform.inc"/>
<CursorPos X="3" Y="56"/>
<TopLine Value="21"/>
<EditorIndex Value="9"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit22>
</Units>
<JumpHistory Count="23" HistoryIndex="22">
<Position1>
<Filename Value="easydocksite.pas"/>
<Caret Line="160" Column="15" TopLine="139"/>
</Position1>
<Position2>
<Filename Value="easydockhelpers.pas"/>
<Caret Line="398" Column="39" TopLine="381"/>
</Position2>
<Position3>
<Filename Value="easydocksite.pas"/>
<Caret Line="699" Column="7" TopLine="664"/>
</Position3>
<Position4>
<Filename Value="easydocksite.pas"/>
<Caret Line="677" Column="1" TopLine="648"/>
</Position4>
<Position5>
<Filename Value="easydocksite.pas"/>
<Caret Line="1280" Column="26" TopLine="1252"/>
</Position5>
<Position6>
<Filename Value="fmain.pas"/>
<Caret Line="189" Column="27" TopLine="164"/>
</Position6>
<Position7>
<Filename Value="easydocksite.pas"/>
<Caret Line="34" Column="1" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="..\..\lcl\include\control.inc"/>
<Caret Line="2283" Column="33" TopLine="2283"/>
</Position8>
<Position9>
<Filename Value="easydocksite.pas"/>
<Caret Line="388" Column="40" TopLine="364"/>
</Position9>
<Position10>
<Filename Value="easydocksite.pas"/>
<Caret Line="401" Column="9" TopLine="375"/>
</Position10>
<Position11>
<Filename Value="easydocksite.pas"/>
<Caret Line="385" Column="24" TopLine="375"/>
</Position11>
<Position12>
<Filename Value="easydocksite.pas"/>
<Caret Line="157" Column="25" TopLine="136"/>
</Position12>
<Position13>
<Filename Value="easydocksite.pas"/>
<Caret Line="1268" Column="1" TopLine="1226"/>
</Position13>
<Position14>
<Filename Value="easydocksite.pas"/>
<Caret Line="842" Column="1" TopLine="838"/>
</Position14>
<Position15>
<Filename Value="easydocksite.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position15>
<Position16>
<Filename Value="easydocksite.pas"/>
<Caret Line="117" Column="1" TopLine="96"/>
</Position16>
<Position17>
<Filename Value="easydocksite.pas"/>
<Caret Line="141" Column="19" TopLine="125"/>
</Position17>
<Position18>
<Filename Value="easydockhelpers.pas"/>
<Caret Line="58" Column="15" TopLine="35"/>
</Position18>
<Position19>
<Filename Value="easydockhelpers.pas"/>
<Caret Line="174" Column="36" TopLine="153"/>
</Position19>
<Position20>
<Filename Value="easydockhelpers.pas"/>
<Caret Line="184" Column="13" TopLine="153"/>
</Position20>
<Position21>
<Filename Value="easydockhelpers.pas"/>
<Caret Line="365" Column="43" TopLine="344"/>
</Position21>
<Position22>
<Filename Value="easydockhelpers.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position22>
<Position23>
<Filename Value="easydocksite.pas"/>
<Caret Line="121" Column="1" TopLine="97"/>
</Position23>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,98 @@
Please check the following list of possible bugs or inconsistencies,
using the widgets at the top of the EasyDocking application main window
- with various widgetsets and
- various settings of the $defines in fMain.
Forms not dockable with some widgetsets?
========================================
With dragForm defined, a form is created on an click on the colored shapes.
This form is not dockable at least with gtk.
[acknowledged by Paul]
With dragForm undefined, a shape control is created and floated manually.
In this case the shape seems to be dockable (also try docking the label).
Edit control not dockable
=========================
The edit control doesn't honor the DragMode and DragKind?
This behaviour may apply to all windowed controls (see Forms above)
A label control seems to be dockable in DragMode=dmAutomatic.
Inconsistent DockRect
=====================
1. The DockRect should be drawn as an outline, as is on Windows.
Using gtk, a filled rectangle is drawn instead.
[acknowledged by Paul]
2. The DockRect should reflect the possible placement of the dragged control on a
dock site, as is on Windows.
On some platforms or widgetsets the rectangle always covers the entire dock site.
This seems to be related to the wrong setting of the drop alignment.
A docking manager, if used, should have full control over the drop alignment.
[fixed, in EasyDockSite]
3. A floating form or dock site in floating state (no DragTarget) should set
the DragRect to the form extent, not to the client extent.
LCL bug: forms use ClientRect for BoundsRect.
[acknowledged by Paul]
Undocking
=========
1. Undocked controls always should be dockable (DragMode=dmAutomatic).
2. A control never should be undocked on a single click on it.
The default mode (DragImediate=True) is inappropriate.
The following bugs are related to this setting.
[partially fixed]
3. When a floating control is only clicked, it never should change
it's size or position on the screen.
[fixed, in EasyDockSite]
4. When a docked control is only clicked, it never should change
it's size or position in the dock site.
[fixed, in Controls.DragManagerDefault]
5. When the header of a docked control is only clicked, the control never should
change it's size or position in the dock site.
[fixed, in EasyDockSite]
6. Docked controls should be undockable by default.
7. Floating controls should be dockable by default.
8. Docked controls should retain their undocked extent.
Title text
==========
On Windows, the floating forms and dockzones have some text in their title bar.
On gtk no such text is shown.
(Problem with default names for dynamically created controls.
Form title still has to be fixed)
[fixed in Controls]
Resize
======
1. A docksite can be resized by resizing the parent form. The dock manager should
receive an according notification, so that it can resize the docked controls.
[fixed in Controls]
2. Docked controls can be resized with embedded sliders. Some widgetsets seem
not to resize the affected controls, even after an explicit Invalidate.
[fixed in EasyDockSite]
Keyboard
========
1. The DragManager doesn't receive KeyUp and KeyDown notifications.
[fixed]
2. Handle CTRL key, for inhibit dock/drop.
TPageControl
============
Controls can be docked into a notebook (with tabs).
1. A docked TPageControl rejects an initial placement (set BoundsRect).
2. TPageControl does not allow to undock individual pages.

View File

@ -15,6 +15,20 @@ http://wiki.lazarus.freepascal.org/LCL_Drag_Drop
See also:
http://wiki.lazarus.freepascal.org/Anchor_Docking
Configuration Options
---------------------
Various test scenarios can be selected by $defines.
In fMain:
- docker: use panel or entire form as docksite
- easy: use default or EasyTree dockmanager
- dragform: dragging controls or forms (forms not on all platforms)
In EasyDockSite:
- NoDrop: required patch applied to the dragmanager?
- splitter_color: use special color for splitter (debug splitters)
In EasyDockHelpers:
- restore: show restore button (purpose?)
ToDos:
At the time of writing this README the following does not yet work:

View File

@ -0,0 +1,104 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Title Value="EasyDocking"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="D:\Tests\dockmanager"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="8">
<Unit0>
<Filename Value="easydocking.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="EasyDocking"/>
</Unit0>
<Unit1>
<Filename Value="fdockable.pas"/>
<ComponentName Value="Dockable"/>
<HasResources Value="True"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fDockable"/>
</Unit1>
<Unit2>
<Filename Value="fmain.pas"/>
<ComponentName Value="EasyDockMain"/>
<HasResources Value="True"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fMain"/>
</Unit2>
<Unit3>
<Filename Value="easydocksite.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="EasyDockSite"/>
</Unit3>
<Unit4>
<Filename Value="fTree.pas"/>
<ComponentName Value="DumpBox"/>
<HasResources Value="True"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fTree"/>
</Unit4>
<Unit5>
<Filename Value="BUGS.txt"/>
<IsPartOfProject Value="True"/>
</Unit5>
<Unit6>
<Filename Value="easydockhelpers.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="EasyDockHelpers"/>
</Unit6>
<Unit7>
<Filename Value="..\..\..\lcl\ldocktree.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="LDockTree"/>
</Unit7>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="..\..\..\lcl\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<Other>
<Verbosity>
<ShowAll Value="True"/>
</Verbosity>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -6,7 +6,7 @@ program EasyDocking;
uses
Interfaces,
Forms, Controls,
Forms, LDockTree,
fMain in 'fMain.pas' {EasyDockMain},
fDockable in 'fDockable.pas' {Dockable},
EasyDockSite in 'EasyDockSite.pas',
@ -15,6 +15,7 @@ uses
{.$R *.res}
begin
Application.Title:='EasyDocking';
Application.Initialize;
Application.CreateForm(TEasyDockMain, EasyDockMain);
Application.CreateForm(TDumpBox, DumpBox);

View File

@ -1,7 +1,7 @@
unit EasyDockSite;
(* A tree docking manager by DoDi <DrDiettrich1@aol.com>.
This project can be used instead of the LDock manager.
This project can be used instead of the LDockTree manager.
To be added or ported:
- field and method argument names
@ -30,7 +30,9 @@ done? (unclear whether this is really fixed in the trunk)
*)
{$H+}
{$DEFINE splitter_color} //use colored splitter, for debugging?
{.$DEFINE NoDrop} //patched dragobject?
interface
@ -164,8 +166,14 @@ type
constructor Create(TheOwner: TComponent); override;
end;
const
AlignNames: array[TAlign] of string = (
'alNone', 'alTop', 'alBottom', 'alLeft', 'alRight', 'alClient', 'alCustom'
);
var //debug only
DropOn: TControl;
DockObj: TDragDockObject;
implementation
@ -472,99 +480,6 @@ begin
FDockSite.Invalidate;
end;
procedure TEasyTree.PositionDockRect(ADockObject: TDragDockObject);
var
i: integer;
zone: TEasyZone;
function DetectAlign(ZoneSize, MousePos: TPoint): TAlign;
var
w, h, zphi: integer;
dx, dy: integer;
phi: double;
izone: integer;
//zone: eZone;
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
//center of dock zone
w := ZoneSize.x div 2;
h := ZoneSize.y div 2;
//mouse position within k*k rectangles (squares)
dx := trunc((MousePos.x - w) / w * k);
dy := trunc((MousePos.y - h) / 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; //alClient?
end else begin
{
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;
Result := dir;
end;
var
ZoneExtent: TPoint;
Acceptable: boolean;
ADockRect: TRect;
begin
(* New DockManager interface, called instead of the old version.
Determine exact target (zone) and DropAlign.
Prevent docking into itself.
*)
//determine the zone containing the DragTargetPos
with ADockObject do begin
//mouse position within dock site
DragTargetPos := DragTarget.ScreenToClient(DragPos);
//find zone
zone := ZoneFromPoint(DragTargetPos);
if zone = nil then begin
DropAlign := alNone; //signal reject
Acceptable := False;
end else if Control = zone.ChildControl then begin
//drag control over itself
DropOnControl := Control; //signal drop on itself
//DragTarget := nil; //this means: become floating!
DropAlign := alNone;
Acceptable := False;
end else begin
DropOnControl := zone.ChildControl;
if DropOnControl = nil then
DropAlign := alClient //first element in entire site
else begin
//The alignment should be determined from the zone (later).
//We just use the control instead.
DragTargetPos := DropOnControl.ScreenToClient(DragPos);
ZoneExtent.X := DropOnControl.Width;
ZoneExtent.Y := DropOnControl.Height;
DropAlign := DetectAlign(ZoneExtent, DragTargetPos);
//todo: map alCustom into page, in InsertControl
end;
end;
//position DockRect
if Acceptable then
begin
PositionDockRect(Control, DropOnControl, DropAlign, ADockRect);
DockRect := ADockRect;
end;
end;
end;
procedure TEasyTree.LoadFromStream(Stream: TStream);
begin
//todo
@ -704,30 +619,131 @@ begin
exit; //no zones - nothing to paint
ACanvas := TCanvas.Create;
ACanvas.Handle := DC;
//ACanvas.Brush.Color := clGreen; //test for missing text
GetCursorPos(MousePos);
MousePos := DockSite.ScreenToClient(MousePos);
PaintZone(FTopZone);
end;
procedure TEasyTree.PositionDockRect(ADockObject: TDragDockObject);
var
i: integer;
zone: TEasyZone;
function DetectAlign(ZoneSize, MousePos: TPoint): TAlign;
var
w, h, zphi: integer;
dx, dy: integer;
phi: double;
izone: integer;
//zone: eZone;
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
//center of dock zone
w := ZoneSize.x div 2;
h := ZoneSize.y div 2;
//mouse position within k*k rectangles (squares)
dx := trunc((MousePos.x - w) / w * k);
dy := trunc((MousePos.y - h) / 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; //alClient?
end else begin
{
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;
Result := dir;
end;
var
ZoneExtent: TPoint;
begin
(* New DockManager interface, called instead of the old version.
Determine exact target (zone) and DropAlign.
Signal results:
Prevent docking by setting DropOnControl=Control (prevent changes when dropped).
DragTarget=nil means: become floating.
Unfortunately there exists no way to signal invalid docking attempts :-(
*)
//determine the zone containing the DragTargetPos
DockObj := ADockObject;
with ADockObject do begin
//mouse position within dock site
DragTargetPos := DragTarget.ScreenToClient(DragPos);
//find zone
zone := ZoneFromPoint(DragTargetPos);
if (zone = nil) or (Control = zone.ChildControl) then begin
DropAlign := alNone; //prevent drop (below)
end else begin
DropOnControl := zone.ChildControl;
if DropOnControl = nil then begin
DropAlign := alClient; //first element in entire site
end else begin
//determined the alignment within the zone.
DockRect := zone.GetBounds; //include header
DropAlign := DetectAlign(zone.BR, DragTargetPos);
//to screen coords
DockRect.TopLeft := FDockSite.ClientToScreen(DockRect.TopLeft);
DockRect.BottomRight := FDockSite.ClientToScreen(DockRect.BottomRight);
end;
end;
//position DockRect
if DropAlign = alNone then begin
DropOnControl := Control; //prevent drop - signal drop onto self
{$IFDEF NoDrop}
NoDrop := True;
{$ELSE}
//DragTarget := FDockSite; //prevent floating - doesn't work :-(
//DockRect := Rect(MaxInt, MaxInt, 0, 0); //LTRB - very strange effect!
//DockRect := Rect(MaxInt, 0, MaxInt, 0); //LTRB
{$ENDIF}
end else begin
PositionDockRect(Control, DropOnControl, DropAlign, DockRect);
end;
end;
end;
procedure TEasyTree.PositionDockRect(Client, DropCtl: TControl;
DropAlign: TAlign; var DockRect: TRect);
var
wh: integer;
begin
(* DockRect is initialized to the client rect of the dock site.
(* DockRect is initialized to the screen rect of the dock site by TControl,
or to the zone rect by TEasyTree!
We assume call by TEasyTree...
*)
//debug!
DropOn := DropCtl;
if (DropCtl = nil) {or (DropCtl = FTopZone.ChildControl)} then
if (DropCtl = nil) then begin
//DebugLn('no DropCtl');
exit; //empty dock site
DockRect := DropCtl.BoundsRect;
DockRect.TopLeft := FDockSite.ClientToScreen(DockRect.TopLeft);
DockRect.BottomRight := FDockSite.ClientToScreen(DockRect.BottomRight);
end;
{
with DockRect do
DebugLn('drop onto %s[%d,%d - %d,%d] %s', [
DropCtl.Name, Top, Left, Bottom, Right, AlignNames[DropAlign]
]);
}
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;

View File

@ -88,7 +88,7 @@ object EasyDockMain: TEasyDockMain
Text = 'Drag Me!'
end
end
object Docker: TPanel
object pnlDocker: TPanel
Left = 0
Height = 236
Top = 29
@ -97,5 +97,6 @@ object EasyDockMain: TEasyDockMain
Caption = 'Dock here!'
TabOrder = 2
UseDockManager = False
OnDockOver = DockerDockOver
end
end

View File

@ -22,7 +22,7 @@ LazarusResources.Add('TEasyDockMain','FORMDATA',[
+'Top'#2#2#5'Width'#2':'#7'Caption'#6#4'Dump'#7'OnClick'#7#11'buDumpClick'#8
+'TabOrder'#2#0#0#0#5'TEdit'#6'edDock'#4'Left'#3#249#0#6'Height'#2#22#3'Top'#2
+#2#5'Width'#2'P'#8'DragKind'#7#6'dkDock'#8'TabOrder'#2#1#4'Text'#6#8'Drag Me'
+'!'#0#0#0#6'TPanel'#6'Docker'#4'Left'#2#0#6'Height'#3#236#0#3'Top'#2#29#5'Wi'
+'dth'#3#205#1#5'Align'#7#8'alClient'#7'Caption'#6#10'Dock here!'#8'TabOrder'
+#2#2#14'UseDockManager'#8#0#0#0
+'!'#0#0#0#6'TPanel'#9'pnlDocker'#4'Left'#2#0#6'Height'#3#236#0#3'Top'#2#29#5
+'Width'#3#205#1#5'Align'#7#8'alClient'#7'Caption'#6#10'Dock here!'#8'TabOrde'
+'r'#2#2#14'UseDockManager'#8#10'OnDockOver'#7#14'DockerDockOver'#0#0#0
]);

View File

@ -13,9 +13,9 @@ unit fMain;
*)
//some defines, to demonstrate LCL flaws
{$DEFINE docker} //using control (undef: entire form) as dock site
{$DEFINE easy} //using EasyDockSite (undef: default LDockTree)
{$DEFINE dragForm} //create a form from the draggable images (or drag images)
{$DEFINE Docker} //using control (undef: entire form) as dock site
{.$DEFINE easy} //using EasyDockSite (undef: default LDockTree)
{.$DEFINE dragForm} //create a form from the draggable images (or drag images)
//dragging forms is not supported on all platforms!
@ -24,6 +24,11 @@ interface
uses
LCLIntf,
SysUtils, Classes, Graphics, Controls, Forms,
{$IFDEF easy}
//use EasyDockSite
{$ELSE}
LDockTree,
{$ENDIF}
Dialogs, StdCtrls, ComCtrls, Menus, ExtCtrls, LResources;
type
@ -31,7 +36,7 @@ type
{ TEasyDockMain }
TEasyDockMain = class(TForm)
Docker: TPanel;
pnlDocker: TPanel;
edDock: TEdit;
lbDock: TLabel;
sb: TStatusBar;
@ -41,6 +46,8 @@ type
Shape3: TShape;
Shape4: TShape;
buDump: TButton;
procedure DockerUnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
procedure Shape1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
@ -53,9 +60,11 @@ type
procedure buDumpClick(Sender: TObject);
private
{$IFDEF docker}
//Docker: TPanel;
{$ELSE}
Docker: TForm;
//Docker: TForm;
{$ENDIF}
Docker: TWinControl;
ShapeCount: integer;
public
{ Public declarations }
@ -72,6 +81,7 @@ uses
EasyDockSite,
{$ELSE}
{$ENDIF}
LCLProc,
Interfacebase,
fTree;
@ -129,16 +139,22 @@ end;
procedure TEasyDockMain.FormCreate(Sender: TObject);
begin
{$IFDEF docker}
pnlDocker.Visible := True;
Docker := pnlDocker;
{$ELSE}
pnlDocker.Visible := False;
Docker := self;
{$ENDIF}
{$IFDEF easy}
Docker.DockManager := TEasyTree.Create(Docker);
{$ELSE}
//use default dockmanager
{$ENDIF}
Docker.DockSite := True;
Docker.UseDockManager := True;
Mouse.DragImmediate := False;
Docker.OnDockOver:=@self.DockerDockOver;
Docker.OnDockDrop := @self.DockerDockDrop;
Mouse.DragImmediate := False; //appropriate at least for docking
end;
procedure TEasyDockMain.DockerDockDrop(Sender: TObject;
@ -154,22 +170,62 @@ begin
//Docker.DockManager.
end;
procedure TEasyDockMain.DockerUnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
var
s, n: string;
r: TRect;
begin
(* problem: DockObj seems to be invalid - here? how?
*)
{ debug only - problem with exception handling!
DebugLn('--- UnDock ---');
try
if DockObj <> nil then begin
r := DockObj.DockRect;
if DockObj.DropOnControl = nil then
n := '<none>'
else
n := '...'; // DockObj.DropOnControl.Name;
s := Format('drop onto %s[%d,%d - %d,%d] %s', [
n, r.Top, r.Left, r.Bottom, r.Right, AlignNames[DockObj.DropAlign]]);
sb.SimpleText := s;
if DockObj.DropOnControl = DockObj.Control then begin
sb.SimpleText := 'NO undock to self';
Allow := False;
end;
end;
except
sb.SimpleText := '<invalid undock obj>';
end;
}
end;
procedure TEasyDockMain.DockerDockOver(Sender: TObject;
Source: TDragDockObject; X, Y: Integer; State: TDragState;
var Accept: Boolean);
var
s: string;
DropOn: TControl;
r: TRect;
begin
{$IFDEF easy}
if DropOn = nil then
//if DropOn = nil then
if Source.DragTarget = nil then
sb.SimpleText := '<drop nowhere>'
else begin
s := Format('drop onto %s[%d,%d - %d,%d]', [
DropOn.Name, DropOn.Top, DropOn.Left, DropOn.Width, DropOn.Height]);
DropOn := Source.DragTarget;
r := Source.DockRect;
s := Format('drop onto %s[%d,%d - %d,%d] %s', [
DropOn.Name, r.Top, r.Left, r.Bottom, r.Right, AlignNames[Source.DropAlign]]);
sb.SimpleText := s;
end;
{$ELSE}
{$ENDIF}
{ we cannot prevent undocking right now :-(
if Source.DropOnControl = Source.Control then
Accept := False;
}
end;
procedure TEasyDockMain.buDumpClick(Sender: TObject);

View File

@ -1,5 +1,3 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TDumpBox','FORMDATA',[
'TPF0'#8'TDumpBox'#7'DumpBox'#4'Left'#3#180#1#6'Height'#3#184#1#3'Top'#3'2'#2
+#5'Width'#3'{'#2#13'ActiveControl'#7#5'Memo1'#7'Caption'#6#7'DumpBox'#12'Cli'