Style Files - FireMonkey Guide

Back to Styles

‘Style files’ store a collection of style elements as well as some optional meta-data. TStyleManager contains routines to read them from files or resources.

A style file uses the same streaming mechanism used by Delphi to store and read form data. If you have ever looked at the text version of a form file then you are already familiar with the format. We need not concern ourselves with the storage format in order to use form files, but it is useful to know if you ever need to edit a form file directly.

Note, however, that as of XE4 the form data is stored in a binary format. Delphi includes utility functions to convert binary data to text and back again but this is obviously somewhat inconvenient.

File Format Overview

While we don’t need to know the details of the file format, it is useful to know what is stored in a file, especially since this is what will be seen in the style editor.

Here’s the file layout of a typical custom style file.

stylecontainerTStyleContainer
    
<untitled>: TStyleDescription
  
button1style1TLayout
  
checkbox1style1TLayout
  
edit1style1TLayout
    stylebook1windows 71style
.pngTImage 


The file starts with an object of class TStyleContainer. This is simply an object used to contain the other items in the file. TStyleContainer was introduced in XE4. In older styles you will see a TLayout object being used instead and some styles included with XE4 still use a TLayout.

Next you see a list of the children of the outer container. The children can appear in any order.

The first child here is an optional TStyleDescription containing meta data about the style such as the platforms on which it can be used.

The next three items are style ‘elements’, where each element is the tree of components for styling a control. Some of these items are style elements used to style portions of a control. For example, the style for a scroll bar references other elements to style the individual buttons.

Finally, in our example, is a TImage. This is a graphic image used in bitmap styles. Here it is the graphic for the Windows 7 style. This object will be referenced by the TSubImage components within the file.

There can be more than one of these image elements in a style with each being used by different TSubImage components. This is useful when customising bitmap styles.

Categories:

div title=