LMD DockingPack Guide


Organizing Custom Central Zone


If built-in tabbed documents feature is not suitable for an application, the following technique can be used to organize custom central zone:

 

Many applications will potentially need locked central zone to prevent end-used from undocking main UI elements from the main form. Such central zone should have two following features:

 

-The content in it can’t be undocked/hidden by the end-user;

-The zone should not be shifted “down” (deeper) inside the zone tree, for example, into tabs as a result of docking another panel.

 

These requirements can be achieved by customizing the central zone:

 

First, its required to disable tabbed documents feature using manager's UseTabbedDocs property. Then, setting ShowHeader property of the central panel to False will hide the header, because it is not generally required for central panel. Also this will prevent end-user to undock or hide the panel. If the header should be visible, then the undocking of the central panel can be prevented by setting DragMode property value to dmManual and excluding close header button using Buttons property:

 

clip0017

 

Disabling some hotspots can be used to prevent zone to be shifted “down” inside the zone tree. Write the following OnUpdateHotSpot site event handler:

 

procedure TForm1.SiteUpdateHotSpots(Sender: TObject;

  AZone: TLMDDockZone; var EnabledAreas: TLMDHotSpotAreas);

begin

  if AZone = CentralPanel.Zone then

    Exclude(EnabledAreas, hsaZoneTabs);

end;

 

This code will disable the “tabs” point in zone hotspot if the hotspot is shown for the central zone, so preventing to dock into the central zone:

 

clip0018

 

Custom Inserts

 

Another way to prevent zone to be shifted “down” (deeper) inside the zone tree - is custom inserts. Custom inserts – is the technique that allows intercepting particular dock-drop event, making some custom actions instead of default docking. Two TLMDDockSite event handlers should be implemented to use custom inserts: OnCustomInsertQuery and OnCustomInsert.

 
The OnCustomInsertQuery event handler should check whether the custom insert is required, depending of the given AZone and AAlign parameters; if the custom insert is required, then the AIsCustomInsert var parameter should be set to True. For example:

 

procedure TForm1.SiteCustomInsertQuery(Sender: TObject;

  AClient: TControl; AZone: TLMDDockZone; AAlign: TAlign;

  var AIsCustomInsert: Boolean);

begin

  AIsCustomInsert := (AAlign = alClient) and 

   (AZone.Panel = CentralPanel);

end;

 

This code activates custom insert if the user tries to dock-drop on “tabs” point in zone hotspot over the central zone. This code tells to the site that no default docking will be performed. The site undocks control from the old site (if any) and fires the OnCustomInsert event. In the OnCustomInsert event handler the client control can be placed manually anywhere. That is the application is free to change the client’s Parent, Bounds, Align, ect. This is because the control is not considered as dock client anymore.

 

The following screenshot of the LMD-DockingPack demo (included in the package) shows, how custom inserts are used to organize tabbed documents in central zone, like in MS Visual Studio:

 

clip0019