TPresentedControl = class(TStyledControl)
class PASCALIMPLEMENTATION TPresentedControl : public Fmx::Controls::TStyledControl
The base class for presented controls that can provide several UI presentations. A presented control uses separate objects to handle a used data (data model) and UI presentation (presentation layer).
The following properties of presented controls that provide a UI presentation:
- Model represents a data model that contains the data used by a presented control.
- PresentationProxy allows the presented control and data model to exchange information with the Receiver, which is the actual presentation layer.
- Receiver is the presentation layer providing the actual visual presentation of the control UI.
The presented control instantiates these properties automatically at run time. An empty model is created as soon as you create an instance of a presented control, and the presentation proxy is created when your presented control loads.
Reimplement DefineModelClass to determine the class that a presented control uses for its data model. Reimplement DefinePresentationName to determine the name of the default presentation proxy that a presented control uses. To define a custom name for the presentation proxy of specific instances of a presented control, handle the OnPresentationNameChoosing event instead.
The ControlType property determines whether the presentation layer represents your control using a native control of the platform where your application is running (
Platform), or the presentation layer represents your control using the default FireMonkey style system (
Styled). On platforms for which FireMonkey does not provide native presentation support, FireMonkey uses the default styled presentation regardless of the value of the ControlType property.
Working with Presentations
Presented controls use the following methods and properties for working with presentations:
- The Presentation property provides access to the presentation that you work with and retrieves the presentation from the Receiver property of PresentationProxy.
- The PresentationProxy property provides access to the loaded presentation proxy. The LoadPresentation method creates and loads the presentation proxy with the presentation proxy name returned by the OnPresentationNameChoosing event handler or by DefinePresentationName. Then LoadPresentation calls InitPresentation and AncestorPresentationLoaded that notifies child controls that the new presentation is loaded. InitPresentation uses the loaded presentation proxy to send initialization messages (like
PM_GET_SIZE) to the presentation. LoadPresentation is automatically called from Loaded control after the form file has been read into memory. The LoadPresentation uses the Current Presentation Proxy Factory to retrieve the appropriate presentation proxy name registered in the Presentations collection.
- The HasPresentationProxy method retrieves whether the presentation proxy is loaded or not.
- The ControlType property defines which type of presentation should be loaded.
Styledrepresents the standard FireMonkey styled control. Such controls look the same on all versions of a given platform. This is the default value.
Platformrepresents the native control of the target platform. The ControlType value is used to generate a presentation proxy class name in DefinePresentationName.
Working with Models
Presented controls use the following methods and properties for working with models:
- The Model property provides access to the data model used by the presented control. This Model data model is created in the constructor of the presented control.
- The DefineModelClass method returns a class reference to a data model class that the constructor of the current presented control uses to create a data model for the presented control. By default, DefineModelClass returns TDataModel. Descendant classes reimplement DefineModelClass to determine the data model class that a descendant presented control uses for its data model.
- The GetModel method is used in a descendant presented control class to cast data models to the data model class used with this presented control.