Difference between revisions of "Anchor Docking"

From Lazarus wiki
Jump to navigationJump to search
(New page: ==Overview=== Docking allows to combine several windows (forms) into one window and to split them. The central instance to control how a form is docked to another is the '''docking manager...)
 
Line 1: Line 1:
==Overview===
+
==Overview==
 
Docking allows to combine several windows (forms) into one window and to split them. The central instance to control how a form is docked to another is the '''docking manager'''. For exmaple the Delphi docking manager uses the Align property to combine forms. This limits the allowed docking layouts, but at least it has a rudimentary save/restore mechanism. The free Delphi package ''DockPanel'' uses the Align property, hidden panels and TPageControls to allow nested layouts and even page docking. The docking manager described on this page is TLazDockingManager and uses the LCL Anchor properties, TPageControl and TSplitters.
 
Docking allows to combine several windows (forms) into one window and to split them. The central instance to control how a form is docked to another is the '''docking manager'''. For exmaple the Delphi docking manager uses the Align property to combine forms. This limits the allowed docking layouts, but at least it has a rudimentary save/restore mechanism. The free Delphi package ''DockPanel'' uses the Align property, hidden panels and TPageControls to allow nested layouts and even page docking. The docking manager described on this page is TLazDockingManager and uses the LCL Anchor properties, TPageControl and TSplitters.
  
Line 29: Line 29:
 
The TLazDockingManager only requires, that the programmer drops a TLazControlDocker onto its form and give it a unique name and connect it to a TLazDockingManager.
 
The TLazDockingManager only requires, that the programmer drops a TLazControlDocker onto its form and give it a unique name and connect it to a TLazDockingManager.
 
You can create an arbitrary number of dock groups to forbid that some forms should never be docked together. But normally you use only one instance of TLazDockingManager for the whole application. This does ''not'' mean you have only one main docking window. There is no main docking window. The user can dock Form1 to Form2 and Form3 to Form4.
 
You can create an arbitrary number of dock groups to forbid that some forms should never be docked together. But normally you use only one instance of TLazDockingManager for the whole application. This does ''not'' mean you have only one main docking window. There is no main docking window. The user can dock Form1 to Form2 and Form3 to Form4.
 +
 +
==Anchor Docking with TLazDockingManager==
 +
 +
The TLazDockingManager is part of the LCL and can be found unit LDockCtrl. It is not yet complete and therefore not yet part of the IDE component palette. An example can be found in
 +
lazarus/examples/anchordocking/docking1.lpi.
 +
 +
===Features===

Revision as of 15:17, 30 December 2007

Overview

Docking allows to combine several windows (forms) into one window and to split them. The central instance to control how a form is docked to another is the docking manager. For exmaple the Delphi docking manager uses the Align property to combine forms. This limits the allowed docking layouts, but at least it has a rudimentary save/restore mechanism. The free Delphi package DockPanel uses the Align property, hidden panels and TPageControls to allow nested layouts and even page docking. The docking manager described on this page is TLazDockingManager and uses the LCL Anchor properties, TPageControl and TSplitters.

Not only forms

The VCL (Delphi's pendant to the LCL) docking is not limited to forms. It can dock and undock any TWinControl. A form is automatically created and the control is put onto it. What type of form is created is defined by the function GetFloatingDockSiteClass.

Splitters

Some docking managers automatically add splitters between the docked forms so the user can still resize the forms. This is done by TLazDockingManager.

Drag and Drop

Some docking managers allows to dock forms via drag and drop. This is not yet implemented in the LCL and especially not every widgetset provides the same support. So even if it starts working on one platform it is not enough for the IDE. The IDE docking must be usable without drag and drop. That's why TLazDockingManager provides a popup menu item which leads to a dialog to setup the docking.

Save/Restore

Some docking managers allows to save the current layout and restore it later. Some docking manager have a static restore. That means you need all forms to restore the layout. For example imagine three forms docked together:

+-----++-----+
|Form1||Form2|
|     |+-----+
|     |+-----+
|     ||Form3|
+-----++-----+

Now imagine the application is restarted and only Form1 and Form2 have been created at start. The layout is restored somehow. For example by expanding Form2's height. Then Form3 is created. Some docking managers will not automatically dock the third form - the user has to redo the layout. Or they will dock Form3, but with a different size or at a different place. And some applications define a strict ruleset how to dock forms, which makes save/restore easy. The TLazDockingManager uses a dynamic restore and tries to restore the docking layout every time a form is created. So if you create the 3 forms in any order they will be restored to the same layout. Many applications can live with a static restore. The IDE has lots of special windows - some are provided by design time packages, some are only created when needed (e.g. debugger, h2pas).

Usage

Some docking managers can only dock special form descendants, so to make a form dockable it must descend from such a class or must be put onto one. The TLazDockingManager only requires, that the programmer drops a TLazControlDocker onto its form and give it a unique name and connect it to a TLazDockingManager. You can create an arbitrary number of dock groups to forbid that some forms should never be docked together. But normally you use only one instance of TLazDockingManager for the whole application. This does not mean you have only one main docking window. There is no main docking window. The user can dock Form1 to Form2 and Form3 to Form4.

Anchor Docking with TLazDockingManager

The TLazDockingManager is part of the LCL and can be found unit LDockCtrl. It is not yet complete and therefore not yet part of the IDE component palette. An example can be found in lazarus/examples/anchordocking/docking1.lpi.

Features