Show: Delphi C++
Display Preferences

FireMonkey Component Rendering

From RAD Studio
Jump to: navigation, search

Go Up to FireMonkey Components Guide

Basic 2D Component Rendering

To understand component rendering, first consider the relevant FMX class hierachy. TFmxObject branches from TComponent to form the FMX root, providing the object lifecycle. From that comes TControl, which encapsulates a canvas and adds painting.

The two relevant branches of TControl are the primitive classes in the FMX.Objects unit, and the user-interaction styled controls in FMX.Controls, FMX.ExtCtrls, and other units. The primitives include such objects as shapes and images:

and their descendants, like:

Styled controls descend from TStyledControl and include:

Painting versus Compositing

Primitives override the TControl.Paint procedure and draw directly on the canvas. Each style that embodies a TStyledControl is an arrangement of a tree of subcontrols and primitives. A style eventually resolves to a layered set of primitives, and those primitives draw in turn on the canvas to render the control.

A custom component can be drawn with one technique or the other, or a combination of the two with a control that contains custom primitives.

  • For custom primitives, you can subclass TControl directly; or TShape, which has several brushes and a bounding rectangle. Add any necessary properties, and then override TControl.Paint to draw on the TControl.Canvas.
  • Subclasses of TStyledControl will attempt to find their style-resource among those assigned to the form's StyleBook property, using a simple search routine based on class names in TStyledControl.GetStyleObject.
    • Application developers can always customize controls by creating a style with the proper name. That style will automatically apply to all instances of the control. They can also assign styles to individual controls by setting the StyleLookup property.
    • Style theme artists can include styles for custom controls by creating a style with the proper name in their theme.
    • To define the appearance of the control when there is no matching style, a component writer can override GetStyleObject.

See Also

Personal tools
In other languages
Previous Versions
Assistance