LMD DesignPack Guide


Designer Component


TLMDDesigner is a key component of the LMD DesignPack which implements functionality similar to the Borland Delphi form designer. To set up a designer, its Module property must be set to refer to a Design Module component (with Module's Root property set to a valid Root control) and its Selection property must be set to refer to TLMDDesignObjects component. If the root is not a TCustomForm descendant, DesignPanel property must be also set to a TLMDDesignPanel component instance. If the root is a TCustomForm descendant, you can still use the design panel. In this case the designing form will apear inside the design panel in a BDS like style. If some of these properties are inconsistently changed, the designer will be automatically deactivated.

 

The designer has AllComponents property that can be linked to TLMDDesignObjects collection. In this case designer will maintain the collection to represent all root children including (optionally) root itself. The collection will change when you add some new component to the root or remove some existing. You can also link this collection to TLMDObjectComboBox.ListObjects property. This will force the combo box to show all available components in its drop down list.

 

As you know, Delphi form designer interoperate with component palette, so, when you select component in component palette and click on designed form, designer creates new component. TLMDDesigner also has two events to follow this scenario. LMD-DesignPack does not provide a component palette abstraction, but the LMD-IDETools package provides it.

 

Write OnComponentInserting event handler to provide the class of the component that should be inserted. If no component should be inserted (no component palette button is down) set the AComponentClass parameter to nil. OnComponentInserting event is fired before any click on the designing root control or one of its children.

 

If OnComponentInserting event handler provides a component class, new component of that class will be created by designer and inserted into the root control or one of its children. Then designer fires OnComponentInserted event. This event can be used to reset previously down component palette button.

 

TLMDDesigner supports working with non-visual components that are not descendants of TControl. Just like Delphi designer it paints small 3d squares with images for such components. The non-visual components visualization is optional and switched off by default. It can be switched on setting ShowNonvisualComponents property value to True. OnShowNonvisualComponent event can be used to control non-visual component visibility for every component individually.

 

Also HiddenClasses collection can be used to specify classes of components that should be hidden. HiddenClasses usually used to register classes, such as TMenuItem, so that menu items will never be visible in designer. The NonvisualImages property and OnGetImageIndex can be used together to provide images for non-visual components.

 

TLMDDesigner supports component locking. Different locking modes are available. You can lock some individual component against moving, deleting, changing its size, copying to clipboard, etc. Also some custom locking modes, which must be interpreted by user application, are supported.

 

TLMDDesigner intercepts keyboard and mouse events from the Root and its children. So, use TLMDDesigner events instead of root control events while designing. Also designer controls Root visibility, so the Root’s Visible property value has no effect on real root visibility. And finally, when you attempts to close designing form, TLMDDesigner.OnDesignFormClose event will be fired.

 

When TLMDDesigner modifies some components it dispatches Global component modification notifications. So allowing all other LMD-DesignPack controls to update they view.