dockmanager example: added elasticsite demo.

git-svn-id: trunk@20795 -
This commit is contained in:
dodi 2009-07-05 07:47:09 +00:00
parent a4eda524c0
commit 4574f1311b
11 changed files with 5901 additions and 0 deletions

10
.gitattributes vendored
View File

@ -2326,6 +2326,7 @@ 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/easyedit/easyeditor.lpi svneol=native#text/plain
examples/dockmanager/easyedit/easyeditor.lpr svneol=native#text/plain
examples/dockmanager/easyedit/easyeditor.lrs svneol=native#text/plain
@ -2351,6 +2352,15 @@ 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/pascal
examples/dockmanager/easytree/ftree.pas svneol=native#text/plain
examples/dockmanager/elasticsite/fdockclient.lfm svneol=native#text/plain
examples/dockmanager/elasticsite/fdockclient.lrs svneol=native#text/plain
examples/dockmanager/elasticsite/fdockclient.pas svneol=native#text/pascal
examples/dockmanager/elasticsite/felastic.lfm svneol=native#text/plain
examples/dockmanager/elasticsite/felastic.lrs svneol=native#text/plain
examples/dockmanager/elasticsite/felastic.pas svneol=native#text/pascal
examples/dockmanager/elasticsite/project1.lpi svneol=native#text/plain
examples/dockmanager/elasticsite/project1.lpr svneol=native#text/plain
examples/dockmanager/elasticsite/project1.lrs svneol=native#text/plain
examples/dockmanager/package/easy_dock_images.lrs svneol=native#text/pascal
examples/dockmanager/package/easydocking.pas svneol=native#text/pascal
examples/dockmanager/package/easydockmgr.lpk svneol=native#text/plain

View File

@ -0,0 +1,40 @@
The examples/dockmanager directory contains several projects,
provided by DoDi <DrDiettrich1@aol.com>
patches/
========
contains some patches, which may not yet have found their way into the LCL.
package/easydocking
===================
contains an tree docking manager, with notebook docking capabilities.
This package is used by the other projects.
easytree/easydocking
====================
demonstrates the EasyDockSite manager features.
easyedit/easyeditor
===================
demonstrates an multi-window editor with dockable pages (files).
elasticsite/project1
====================
demonstrates elastic dock sites, which become visible only after a control
has been docked into them.
toolbar/test1
=============
mainly demonstrates TToolBar/TToolButton related problems.
(see provided patches)
-------
In prepraration:
ide_demo
========
A Lazarus-like IDE, with dockable windows.
Shall demonstrate the use of dockable windows, multi-page editor,
elastic dock sites, flexible component palette (old/new Delphi style).
Also shall allow to store/reload a layout.

View File

@ -0,0 +1,12 @@
object DockingClient: TDockingClient
Left = 425
Height = 159
Top = 369
Width = 232
Caption = 'Dock Client'
Color = clLime
DragKind = dkDock
DragMode = dmAutomatic
LCLVersion = '0.9.27'
Visible = True
end

View File

@ -0,0 +1,8 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TDockingClient','FORMDATA',[
'TPF0'#14'TDockingClient'#13'DockingClient'#4'Left'#3#169#1#6'Height'#3#159#0
+#3'Top'#3'q'#1#5'Width'#3#232#0#7'Caption'#6#11'Dock Client'#5'Color'#7#6'cl'
+'Lime'#8'DragKind'#7#6'dkDock'#8'DragMode'#7#11'dmAutomatic'#10'LCLVersion'#6
+#6'0.9.27'#7'Visible'#9#0#0
]);

View File

@ -0,0 +1,27 @@
unit fDockClient;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs;
type
TDockingClient = class(TForm)
private
{ private declarations }
public
{ public declarations }
end;
var
DockingClient: TDockingClient;
implementation
initialization
{$I fdockclient.lrs}
end.

View File

@ -0,0 +1,98 @@
object DockingSite: TDockingSite
Left = 384
Height = 163
Top = 157
Width = 255
Caption = 'Dock Site'
ClientHeight = 163
ClientWidth = 255
LCLVersion = '0.9.27'
Visible = True
object pnlLeft: TPanel
Left = 0
Height = 139
Top = 0
Width = 0
Align = alLeft
Caption = 'pnlLeft'
Color = clWhite
DockSite = True
ParentColor = False
TabOrder = 0
UseDockManager = False
OnDockDrop = pnlLeftDockDrop
OnDockOver = pnlLeftDockOver
OnGetSiteInfo = pnlLeftGetSiteInfo
OnUnDock = pnlLeftUnDock
end
object splitLeft: TSplitter
Left = 0
Height = 139
Top = 0
Width = 4
end
object buNewForm: TButton
Left = 96
Height = 20
Top = 16
Width = 62
Caption = 'New Form'
OnClick = buNewFormClick
TabOrder = 2
end
object pnlRight: TPanel
Left = 255
Height = 139
Top = 0
Width = 0
Align = alRight
Caption = 'pnlRight'
Color = clAqua
DockSite = True
ParentColor = False
TabOrder = 3
UseDockManager = False
OnDockDrop = pnlLeftDockDrop
OnDockOver = pnlLeftDockOver
OnGetSiteInfo = pnlLeftGetSiteInfo
end
object pnlBottom: TPanel
Left = 0
Height = 0
Top = 143
Width = 255
Align = alBottom
Caption = 'pnlBottom'
DockSite = True
TabOrder = 4
UseDockManager = False
OnDockDrop = pnlLeftDockDrop
OnDockOver = pnlLeftDockOver
OnGetSiteInfo = pnlLeftGetSiteInfo
OnUnDock = pnlLeftUnDock
end
object splitBottom: TSplitter
Cursor = crVSplit
Left = 0
Height = 4
Top = 139
Width = 255
Align = alBottom
ResizeAnchor = akBottom
end
object splitRight: TSplitter
Left = 251
Height = 139
Top = 0
Width = 4
Align = alRight
ResizeAnchor = akRight
end
object StatusBar1: TStatusBar
Left = 0
Height = 20
Top = 143
Width = 255
Panels = <>
end
end

View File

@ -0,0 +1,30 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TDockingSite','FORMDATA',[
'TPF0'#12'TDockingSite'#11'DockingSite'#4'Left'#3#128#1#6'Height'#3#163#0#3'T'
+'op'#3#157#0#5'Width'#3#255#0#7'Caption'#6#9'Dock Site'#12'ClientHeight'#3
+#163#0#11'ClientWidth'#3#255#0#10'LCLVersion'#6#6'0.9.27'#7'Visible'#9#0#6'T'
+'Panel'#7'pnlLeft'#4'Left'#2#0#6'Height'#3#139#0#3'Top'#2#0#5'Width'#2#0#5'A'
+'lign'#7#6'alLeft'#7'Caption'#6#7'pnlLeft'#5'Color'#7#7'clWhite'#8'DockSite'
+#9#11'ParentColor'#8#8'TabOrder'#2#0#14'UseDockManager'#8#10'OnDockDrop'#7#15
+'pnlLeftDockDrop'#10'OnDockOver'#7#15'pnlLeftDockOver'#13'OnGetSiteInfo'#7#18
+'pnlLeftGetSiteInfo'#8'OnUnDock'#7#13'pnlLeftUnDock'#0#0#9'TSplitter'#9'spli'
+'tLeft'#4'Left'#2#0#6'Height'#3#139#0#3'Top'#2#0#5'Width'#2#4#0#0#7'TButton'
+#9'buNewForm'#4'Left'#2'`'#6'Height'#2#20#3'Top'#2#16#5'Width'#2'>'#7'Captio'
+'n'#6#8'New Form'#7'OnClick'#7#14'buNewFormClick'#8'TabOrder'#2#2#0#0#6'TPan'
+'el'#8'pnlRight'#4'Left'#3#255#0#6'Height'#3#139#0#3'Top'#2#0#5'Width'#2#0#5
+'Align'#7#7'alRight'#7'Caption'#6#8'pnlRight'#5'Color'#7#6'clAqua'#8'DockSit'
+'e'#9#11'ParentColor'#8#8'TabOrder'#2#3#14'UseDockManager'#8#10'OnDockDrop'#7
+#15'pnlLeftDockDrop'#10'OnDockOver'#7#15'pnlLeftDockOver'#13'OnGetSiteInfo'#7
+#18'pnlLeftGetSiteInfo'#0#0#6'TPanel'#9'pnlBottom'#4'Left'#2#0#6'Height'#2#0
+#3'Top'#3#143#0#5'Width'#3#255#0#5'Align'#7#8'alBottom'#7'Caption'#6#9'pnlBo'
+'ttom'#8'DockSite'#9#8'TabOrder'#2#4#14'UseDockManager'#8#10'OnDockDrop'#7#15
+'pnlLeftDockDrop'#10'OnDockOver'#7#15'pnlLeftDockOver'#13'OnGetSiteInfo'#7#18
+'pnlLeftGetSiteInfo'#8'OnUnDock'#7#13'pnlLeftUnDock'#0#0#9'TSplitter'#11'spl'
+'itBottom'#6'Cursor'#7#8'crVSplit'#4'Left'#2#0#6'Height'#2#4#3'Top'#3#139#0#5
+'Width'#3#255#0#5'Align'#7#8'alBottom'#12'ResizeAnchor'#7#8'akBottom'#0#0#9
+'TSplitter'#10'splitRight'#4'Left'#3#251#0#6'Height'#3#139#0#3'Top'#2#0#5'Wi'
+'dth'#2#4#5'Align'#7#7'alRight'#12'ResizeAnchor'#7#7'akRight'#0#0#10'TStatus'
+'Bar'#10'StatusBar1'#4'Left'#2#0#6'Height'#2#20#3'Top'#3#143#0#5'Width'#3#255
+#0#6'Panels'#14#0#0#0#0
]);

View File

@ -0,0 +1,181 @@
unit fElastic;
(* Demonstrate elastic dock sites.
This form has dock sites (panels) on its left, right and bottom.
Empty panels should be invisible, what's a bit tricky. They cannot have
Visible=False, because this would disallow to dock anything into them.
So the width/height of the panels is set to zero instead.
When a control is docked, the dock site is enlarged. Fine adjustment can be
made with the splitters beneath the controls.
When a control is undocked, the dock site is shrinked again.
Planned extensions:
- allow to enlarge the form together with the dock sites, so that the form's
client area is unchanged.
- using an DockManager, so that more than only one control can be docked
into every panel.
*)
(* Observed problems:
The right panel does not shrink.
Object Inspector says: the bottom panel's OnGetSiteInfo method is incompatible
with other OnGetSiteInfo methods.
*)
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, ComCtrls;
type
TDockingSite = class(TForm)
buNewForm: TButton;
pnlBottom: TPanel;
pnlLeft: TPanel;
pnlRight: TPanel;
splitLeft: TSplitter;
splitBottom: TSplitter;
splitRight: TSplitter;
StatusBar1: TStatusBar;
procedure buNewFormClick(Sender: TObject);
procedure pnlLeftDockDrop(Sender: TObject; Source: TDragDockObject;
X, Y: Integer);
procedure pnlLeftDockOver(Sender: TObject; Source: TDragDockObject;
X, Y: Integer; State: TDragState; var Accept: Boolean);
procedure pnlLeftGetSiteInfo(Sender: TObject; DockClient: TControl;
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
procedure pnlLeftUnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
private
{ private declarations }
public
{ public declarations }
end;
var
DockingSite: TDockingSite;
implementation
uses
fDockClient;
{ TDockingSite }
procedure TDockingSite.buNewFormClick(Sender: TObject);
begin
TDockingClient.Create(self);
end;
procedure TDockingSite.pnlLeftDockDrop(Sender: TObject;
Source: TDragDockObject; X, Y: Integer);
var
w: integer;
begin
(* Adjust docksite extent, if required.
H/V depending on align LR/TB.
Take 1/3 of the form's extent for the dock site.
When changed, ensure that the form layout is updated.
To come: enlarge the form as well, when docked outside.
*)
with Source do begin
if DragTarget.Align in [alLeft, alRight] then begin
w := self.Width div 3;
if DragTarget.Width < w then begin
DisableAlign; //form(?)
DragTarget.Width := w;
if DragTarget.Align = alRight then
dec(DragTarget.Left, w);
EnableAlign;
end;
end else begin
w := self.Height div 3;
if DragTarget.Height < w then begin
DisableAlign; //form(?)
DragTarget.Height := w;
if DragTarget.Align = alBottom then
dec(DragTarget.Top, w);
EnableAlign;
end;
end;
Control.Align := alClient;
end;
end;
procedure TDockingSite.pnlLeftDockOver(Sender: TObject;
Source: TDragDockObject; X, Y: Integer; State: TDragState;
var Accept: Boolean);
begin
if State = dsDragMove then begin
Accept := True;
//make DockRect reflect the docking area
with Source do begin
StatusBar1.SimpleText := AlignNames[DropAlign];
DockRect := DragTarget.ClientRect;
if DragTarget.Width <= 0 then begin
dec(DockRect.Left, 10);
inc(DockRect.Right, 20);
end else if DragTarget.Height <= 0 then begin
dec(DockRect.Top, 10);
inc(DockRect.Bottom, 20);
end;
DockRect.TopLeft := TWinControl(DragTarget).ClientToScreen(DockRect.TopLeft);
inc(DockRect.Bottom, DockRect.Top);
inc(DockRect.Right, DockRect.Left);
end;
end;
end;
procedure TDockingSite.pnlLeftGetSiteInfo(Sender: TObject;
DockClient: TControl; var InfluenceRect: TRect; MousePos: TPoint;
var CanDock: Boolean);
begin
CanDock := True;
end;
procedure TDockingSite.pnlLeftUnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
var
Site: TWinControl absolute Sender;
begin
(* When the last client is undocked, shrink the dock site to zero extent.
Called *before* the dock client is removed.
*)
if Site.DockClientCount <= 1 then begin
//hide the dock site
DisableAlign;
case Site.Align of
alLeft:
begin
Site.Width := 0; //behaves as expected
end;
alRight:
begin //problem: does NOT resize?
inc(Site.Left, Site.Width);
Site.Width := 0;
//moving the splitter too, seems to be required? Doesn't help :-(
splitRight.Left := Site.Left - splitRight.Width;
end;
alBottom:
begin
inc(Site.Top, Site.Height);
Site.Height := 0;
end;
end;
EnableAlign;
end;
end;
initialization
{$I felastic.lrs}
end.

View File

@ -0,0 +1,251 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="7"/>
<General>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<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="2">
<Item1>
<PackageName Value="EasyDockMgr"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="6">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<CursorPos X="56" Y="10"/>
<TopLine Value="1"/>
<EditorIndex Value="4"/>
<UsageCount Value="25"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="felastic.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="DockingSite"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fElastic"/>
<CursorPos X="1" Y="121"/>
<TopLine Value="105"/>
<EditorIndex Value="0"/>
<UsageCount Value="25"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="fdockclient.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="DockingClient"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="fDockClient"/>
<CursorPos X="22" Y="24"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="25"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<CursorPos X="1" Y="4956"/>
<TopLine Value="4932"/>
<EditorIndex Value="1"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<CursorPos X="1" Y="439"/>
<TopLine Value="415"/>
<EditorIndex Value="3"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<CursorPos X="1" Y="1125"/>
<TopLine Value="1101"/>
<EditorIndex Value="2"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit5>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="felastic.pas"/>
<Caret Line="24" Column="19" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="felastic.pas"/>
<Caret Line="13" Column="12" TopLine="1"/>
</Position2>
<Position3>
<Filename Value="felastic.pas"/>
<Caret Line="17" Column="73" TopLine="1"/>
</Position3>
<Position4>
<Filename Value="felastic.pas"/>
<Caret Line="35" Column="1" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="felastic.pas"/>
<Caret Line="36" Column="1" TopLine="1"/>
</Position5>
<Position6>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<Caret Line="5033" Column="1" TopLine="5009"/>
</Position6>
<Position7>
<Filename Value="felastic.pas"/>
<Caret Line="18" Column="5" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="felastic.pas"/>
<Caret Line="37" Column="18" TopLine="3"/>
</Position8>
<Position9>
<Filename Value="felastic.pas"/>
<Caret Line="44" Column="1" TopLine="3"/>
</Position9>
<Position10>
<Filename Value="felastic.pas"/>
<Caret Line="37" Column="1" TopLine="3"/>
</Position10>
<Position11>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<Caret Line="3586" Column="1" TopLine="3553"/>
</Position11>
<Position12>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="120" Column="1" TopLine="96"/>
</Position12>
<Position13>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="128" Column="1" TopLine="104"/>
</Position13>
<Position14>
<Filename Value="..\..\..\lcl\include\dragmanager.inc"/>
<Caret Line="439" Column="1" TopLine="415"/>
</Position14>
<Position15>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<Caret Line="3586" Column="1" TopLine="3562"/>
</Position15>
<Position16>
<Filename Value="..\..\..\lcl\include\control.inc"/>
<Caret Line="1125" Column="1" TopLine="1101"/>
</Position16>
<Position17>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<Caret Line="4945" Column="1" TopLine="4921"/>
</Position17>
<Position18>
<Filename Value="..\..\..\lcl\include\wincontrol.inc"/>
<Caret Line="4956" Column="1" TopLine="4932"/>
</Position18>
<Position19>
<Filename Value="felastic.pas"/>
<Caret Line="46" Column="1" TopLine="3"/>
</Position19>
<Position20>
<Filename Value="felastic.pas"/>
<Caret Line="18" Column="5" TopLine="12"/>
</Position20>
<Position21>
<Filename Value="felastic.pas"/>
<Caret Line="46" Column="34" TopLine="26"/>
</Position21>
<Position22>
<Filename Value="felastic.pas"/>
<Caret Line="15" Column="22" TopLine="15"/>
</Position22>
<Position23>
<Filename Value="felastic.pas"/>
<Caret Line="25" Column="53" TopLine="1"/>
</Position23>
<Position24>
<Filename Value="felastic.pas"/>
<Caret Line="90" Column="1" TopLine="90"/>
</Position24>
<Position25>
<Filename Value="felastic.pas"/>
<Caret Line="14" Column="14" TopLine="14"/>
</Position25>
<Position26>
<Filename Value="felastic.pas"/>
<Caret Line="22" Column="5" TopLine="14"/>
</Position26>
<Position27>
<Filename Value="felastic.pas"/>
<Caret Line="10" Column="48" TopLine="1"/>
</Position27>
<Position28>
<Filename Value="felastic.pas"/>
<Caret Line="27" Column="26" TopLine="1"/>
</Position28>
<Position29>
<Filename Value="felastic.pas"/>
<Caret Line="18" Column="20" TopLine="1"/>
</Position29>
<Position30>
<Filename Value="felastic.pas"/>
<Caret Line="48" Column="5" TopLine="1"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)\"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,22 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, fElastic, EasyDockMgr, LResources, fDockClient
{ you can add units after this };
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
begin
{$I project1.lrs}
Application.Initialize;
Application.CreateForm(TDockingSite, DockingSite);
Application.CreateForm(TDockingClient, DockingClient);
Application.Run;
end.

File diff suppressed because it is too large Load Diff