FMX.ListView.Appearances.TCommonObjectAppearance
Delphi
TCommonObjectAppearance = class(TObjectAppearance, IMovablePersistent)
C++
class PASCALIMPLEMENTATION TCommonObjectAppearance : public TObjectAppearance
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
class | public | FMX.ListView.Appearances.pas FMX.ListView.Appearances.hpp |
FMX.ListView.Appearances | FMX.ListView.Appearances |
Description
Contents
Base class that provides some functionality on top of TObjectAppearance that makes it easier to create new object appearance types.
This is a list of built-in object appearance classes that subclass TCommonObjectAppearance:
- TAccessoryObjectAppearance
- TGlyphButtonObjectAppearance
- TImageObjectAppearance
- TTextButtonObjectAppearance
- TTextObjectAppearance
Using a TCommonObjectAppearance Subclass
An object appearance must have an owner, and a name that uniquely identifies the object appearance among the object appearances of its owner.
To change properties of an object appearance that affect its appearance, perform your changes between a call to BeginUpdate and a call to EndUpdate.
TCommonObjectAppearance provides the following properties to customize the object appearance:
- Align and VertAlign
- Opacity
- PlaceOffset (also ActualPlaceOffset, and InternalPlaceOffset)
- Width (also ActualWidth, WidthWhenVisible, and InternalWidth) and Height (also ActualHeight, HeightWhenVisible, and InternalHeight)
- Visible
The following table shows how properties of TCommonObjectAppearance match properties of TListItemDrawable:
TCommonObjectAppearance Property | Corresponding TListItemDrawable Property |
---|---|
ActualPlaceOffset | PlaceOffset |
Align | Align |
Opacity | Opacity |
SizeWhenVisible | Size |
VertAlign | VertAlign |
Visible | Visible |
Subclasses may define additional properties that affect the appearance and match properties of TListItemDrawable subclasses.
You can handle the OnChange event to react when any of these properties changes, or OnHeightChange to react when Height changes.
You may restore the default values of properties that affect the appearance at any moment.
Subclassing TCommonObjectAppearance
To define a custom object appearance type, create a subclass of TCommonObjectAppearance and do the following:
- Override AssignTo to implement copy support.
- Override
CreateDefaultValues
to return a valid value for DefaultValues (one created passingAIsDefaultValues
asTrue
to the constructor). - Override CreateObject to create an instance of a subclass of TListItemDrawable and, between a call to TListItemDrawable.BeginUpdate and a call to TListItemDrawable.EndUpdate, fill it with the relevant properties of your object appearance. You may use AssignTo if you implement it so that it supports the subclass of TListItemDrawable that CreateObject returns as a parameter.
- Override ResetObject. You can use ResetObjectT for your implementation.
On top of this, you should add as many additional properties as your object appearance requires.
Object appearance types are rarely implemented on their own. You usually implement a TListItemDrawable subclass first, and then you implement a matching object appearance type.