Docking

From Free Pascal wiki
Revision as of 08:56, 26 August 2010 by Chronos (talk | contribs) (Docking category)
Jump to navigationJump to search

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 example 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. In the Lazarus sources there are two docking implementations

Not only forms

Docking is not limited to forms in the LCL. 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. When a control is undocked the LCL automatically creates this class and add the control as child.

Splitters

Some docking managers automatically add splitters between the docked forms so the user can still resize the forms. The LCL provides TSplitter with some extended features like anchors, that Delphi does not have. This allows very flexible layouts and no hidden panels.

Drag and Drop

Some docking managers allows to dock forms via drag and drop. The dragging is implemented in the LCL and the docking managers can control the details. Some platforms like MS Windows sends drag events when dragging the title bar, others like Linux do not. Therefore docking managers under Linux require to add drag areas to each dockable form. These drag areas are often called dock headers. Dragging can start automatically via the DragKind and DragMode properties or manually via the DragManager.DragStart method.

Save/Restore

Some docking managers allow to save the current layout and restore it later. How this is done is totally up to the docking packages. The LCL provides no framework for save/restore layouts of multiple forms.

Most docking packages have methods to save/restore the whole layout. That means they save all opened forms, their bounds and nested states and can restore that. Some have also a dynamic restore. 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.

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. Because under Linux you must add a drag area, both existing dock managers wrap the dockable controls into docksites and add a drag area.

See also