Component Writer's Guide :: Layout Managers

From RadPHP XE2 Documentation
Jump to: navigation, search

Layout Managers allows a component developer to write code that gets executed whenever components on a form designer get moved/resized, this feature is used to provide the visual part of Layouts that work on PHP.

To develop some components, some features need a higher control of the controls contained by the component, and that control cannot be done in PHP due performance reasons, this is where Layout Managers get into action.

A Layout Manager must inherit from TD4PHPLayoutManager and must implement two methods:

       procedure Execute(params: TStringList; container: TWinControl); virtual; stdcall; abstract; //Called when control position changes
       procedure ResizeParent(params: TStringList; container: TWinControl; previousbounds: TRect); virtual; stdcall; abstract; //Called to resize/move all the children

After that, it must be registered into the IDE:

       //Register a layout manager for an specific layout type
       procedure RegisterLayoutManager(const layouttype: string; layoutmanagerclass: TD4PHPLayoutManagerClass);

When the Form Designer moves a control or resizes a control, checks if there is a layout manager available for the layout types involved in the move/resize operation, so you can perform any action with controls on the container, or even with the container itself.

Personal tools