TStyleManager - FireMonkey Guide

Unit: FMX.Styles
Parent: TObject

TStyleManager is a collection of class procedures, functions and properties for managing styles within an application.

All the members of TStyleManager are class procedures. This means that you don’t need to create an instance of TStyleManager to use it, simply call the procedure (etc.) and precede it with the class name. E.g.

procedure TForm1.LoadStyle;
begin
  TStyleManager
.SetStyleFromFile('c:\mystyle.style');
end

It should be noted that routines which read a style will fail if the style contains a TStyleDescription which specifies a platform other than the current one.

SystemStyle

As discussed in Style Management, SystemStyle is the default style for the current platform.

The SetSystemStyle procedure causes the SystemStyle and SystemStyleHiRes to be loaded. Since these are set at start up anyway this procedure should not be needed. SystemStyle and SystemStyleHiRes return the current system style objects (of class TFMXObject).

ActiveStyle

Again refer to Style Management for details, but in summary ActiveStyle is the current default style.

ActiveStyle and ActiveStyleHiRes return the current active styles. The SetStyle and SetStyleHiRes methods set the current active style. They both take a TFMXObject as a parameter. Two more procedures, SetStyleFromFile and SetStyleFromFileHiRes load the styles from a file when passed a filename.

Loading Styles

A set of functions are provided for loading styles from files and resources. Those which load a style return a TTMFObject suitable for passing to SetStyle or SetStyleHiRes.

// Load style from a resource
class function LoadFromResource(InstanceHINST; const ResourceNamestringResourceTypePChar): TFmxObject;
// Test whether a style from a resource can be loaded (i.e. is is a valid style file and valid for the current platform).
class function TryLoadFromResource(InstanceHINST; const ResourceNamestringResourceTypePChar): Boolean;
// Test whether a style from a file can be loaded (i.e. is is a valid style file and valid for the current platform).
class function TryLoadFromFile(const FileNamestring)Boolean;
// Load style from a file
class function LoadFromFile(const FileNamestring)TFmxObject;
// Load style from a file
class function LoadFromStream(const AStreamTStream): TFmxObject

Miscellaneous Members

UpdateScenes updates you application when styles have changed. You don’t normally need to call this yourself.

procedure SaveStyleToIndexedBinary(const Style: TFmxObject; const Stream: TStream); saves a style to a binary file (as opposed to the usual textual files).

UnInitialize is for internal use only.

class function FindStyleDescriptor(const AObject: TFmxObject): TStyleDescription; finds and returns a TStyleDescription in the style passed in AObject.

class property StyleNames: TArray

read GetStyleNames; is claimed to return a list of style classes (whatever that means) but is currently not implemented.

Version: XE4

Categories:

div title=