StyleBook¶
Qualified name: delphifmx.StyleBook
- class StyleBook¶
Bases:
FmxObject
TStyleBook stores a collection of styles for a form. There are two ways to create and use a TStyleBook component:
Drop a TStyleBook component from the Tool Palette onto the Form Designer and make your new TStyleBook component the value of the StyleBook property of the form. This works for desktop applications and mobile applications. Right-click a control on a FireMonkey desktop form and choose either Edit Default Style or Edit Custom Style. This automatically creates a TStyleBook component, sets it to the form’s StyleBook, and opens the Style Designer. TStyleBook stores the style definition as text in the Resource property and can be loaded from a .style file. Double-clicking the TStyleBook component on the form opens the Style Designer.
TStyleBook and Form Inheritance If you want all the descendant forms to have the same style as the base form, place the TStyleBook in the base form. If you want the descendant forms to have different styles, place separate TStyleBooks in the descendant forms. Note: At design time, using the StyleLookup property of a control in any form in the current project group you can access any custom style defined in any TStyleBook component used in the current project group. That is, even if the form does not have a particular TStyleBook component, controls from this form can use custom styles defined in this TStyleBook component (if this TStyleBook component is used in any form in the current project group). At run time, only styles in the current project and only after an owner of the TStyleBook containing these styles is already created can be accessed.
Methods
Clears the style collection of a TStyleBook.
Gets the style of the CurrentItem stored in TStyleCollectionItem. Getter of Style.
Method to load a style to a TStyleBook, from a file.
Method to load a style to the TStyleBook, from a stream.
Attributes
ActionClient
Specifies whether the component object has an associated action.
Children
Stores an array of children attached to this parent component.
ChildrenCount
Read-only property that specifies the number of children in the children list.
ClassName
Returns the TObject.ClassName
ComObject
Specifies the interface reference implemented by the component.
ComponentCount
Returns the owned component count
ComponentIndex
Indicates the position of the component in its owner's Components property array.
ComponentState
Describes the current state of the component, indicating when a component needs to avoid certain actions.
ComponentStyle
Governs the behavior of the component.
Components
Returns an iterator over the owned components
Current style in the style collection.
Index of the current style in the style collection.
Data
Stores a Tvalue, which is a data structure that can store different kinds of data types.
DesignInfo is a TStyleBookDesignInfo record that contains design-time information only used by the Form designer.
The name of the file that contains the style definition.
Index
Specifies the index of the child object in the children array attached to this object.
Name
Specifies the name of the component as referenced in code.
Observers
Indicates the TObservers object added to the TComponent.
Owner
Returns the Component Owner
Returns/Sets the Control Visibility
The style definition.
Root
Specifies the root parent of this object.
Stored
Specifies whether this object is stored in the .XFM file.
Represents the current style as a TFmxObject.
StyleName
Specifies the style name for this FMX component.
Contains the collection of styles stored in the TStyleBook.
Tag
Stores a NativeInt integral value as a part of a component.
TagFloat
Custom property that stores any floating-point value.
TagObject
Custom property that stores any object value.
TagString
Custom property that stores any string value.
Indicates whether the style can be loaded in the current target platform.
Specifies whether the TStyleManager replaces the default style for the whole application.
VCLComObject
Represents information used internally by components that support COM.
- Clear()¶
Clears the style collection of a TStyleBook. TStyleCollection is a collection that stores the styles for the different platforms. Clear deletes all items from the collection.
- CurrentItem¶
Current style in the style collection. CurrentItem is the current StyleCollectionItem from the StyleCollection.
- Type:
StyleCollectionItem
- CurrentItemIndex¶
Index of the current style in the style collection. CurrentItemIndex is the index of the current StyleCollectionItem from the StyleCollection array. CurrentItemIndex is an integer value.
- Type:
int
- DesignInfo¶
DesignInfo is a TStyleBookDesignInfo record that contains design-time information only used by the Form designer.
ClassName: Class name of the selected control. CustomStyle: True when edit custom style mode is active. DefaultStyleLookup: The default StyleLookup for the selected control. Name: Name of the selected control. StyleLookup: Name of the StyleLookup for the selected control. Control: The selected control itself.
- Type:
StyleBookDesignInfo
- FileName¶
The name of the file that contains the style definition. Use FileName to specify the .style file from which the TStyleBook loads its Resource. Setting the FileName also loads and applies the style.
- Type:
str
- GetStyle(Context: FmxObject) FmxObject ¶
- Gets the style of the CurrentItem stored in TStyleCollectionItem. Getter of Style.
TStyleCollectionItem stores one style for the specified platform. GetStyle gets the style item.
The style is a TFmxObject type. Gets the style of the CurrentItem stored in TStyleCollectionItem. Getter of Style.
TStyleCollectionItem stores one style for the specified platform. GetStyle gets the style item.
The style is a TFmxObject type.
- LoadFromFile(AFileName: str) None ¶
Method to load a style to a TStyleBook, from a file. Select the full path to the file or the file name when located in the project folder. FireMonkey styles are delivered in the RAD Studio product installation, at the following paths:
C:Program Files (x86)EmbarcaderoStudio21.0RediststylesFmx C:UsersPublicDocumentsEmbarcaderoStudio21.0Styles Apply the style to the form using the StyleBook property of the form, for example:
procedure TForm1.FormCreate(Sender: TObject); begin
StyleBook1.LoadFromFile(‘Air.Style’); Form1.StyleBook := StyleBook1;
end;
To load a style to an item of the TStyleCollection, that is a style for each platform added to the TStyleBook, then use FMX.Controls.TStyleCollectionItem.LoadFromFile.
- LoadFromStream(Stream: Stream) None ¶
Method to load a style to the TStyleBook, from a stream. To load the style from a file use LoadFromFile.
procedure TForm1.FormCreate(Sender: TObject); var
S: TFileStream;
- begin
S := TFileStream.Create(‘Air.Style’, fmOpenRead); Stylebook1.LoadFromStream(S);
end;
procedure TForm2.FormCreate(Sender: TObject); var
iStream: TMemoryStream;
- begin
StyleBook1.LoadFromFile(‘Air.Style’); //Loads the style from a file. iStream := TMemoryStream.Create; //Instanziate the memory stream var. TStyleStreaming.SaveToStream(StyleBook1.Style, iStream); //saves the style as a memory stream. StyleBook1.Clear; //Clear the styles from the stylebook. iStream.Position := 0; //Sets the position to start the streaming. StyleBook1.LoadFromStream(iStream); //Loads the style to the stylebook from the memory stream.
end;
- Parent¶
Returns/Sets the Control Visibility
- Resource¶
The style definition. Resource is a string list containing the style defined by the TStyleBook.
- Type:
- Styles¶
Contains the collection of styles stored in the TStyleBook.
- Type:
StyleCollection
- UnsupportedPlatform¶
Indicates whether the style can be loaded in the current target platform. If the style cannot be loaded, UnsupportedPlatform is True and Style is empty.
- Type:
bool
- UseStyleManager¶
Specifies whether the TStyleManager replaces the default style for the whole application.
- Type:
bool