.. _api_StyleSheet: StyleSheet ========== Inherited: :ref:`Resource` .. _api_StyleSheet_description: Description ----------- The StyleSheet class is responsible for handling CSS style rules, which can be applied to Widget objects. It includes functionality for storing, loading, saving, and resolving styles, along with utility methods to convert CSS color and length values. .. _api_StyleSheet_public: Public Methods -------------- +------------------------------+----------------------------------------------------------------+ | :ref:`TString` | :ref:`data` () const | +------------------------------+----------------------------------------------------------------+ | void | :ref:`resolve` (Widget * widget) | +------------------------------+----------------------------------------------------------------+ | void | :ref:`setData` (const TString & data) | +------------------------------+----------------------------------------------------------------+ .. _api_StyleSheet_static: Static Methods -------------- +------------------------------+----------------------------------------------------------------------------------------------------------------+ | void | :ref:`resolveInline` (Widget * widget, const TString & style) | +------------------------------+----------------------------------------------------------------------------------------------------------------+ | void | :ref:`setStyleProperty` (Widget * widget, const TString & key, const TString & value) | +------------------------------+----------------------------------------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`toColor` (const TString & value) | +------------------------------+----------------------------------------------------------------------------------------------------------------+ | float | :ref:`toLength` (const TString & value, bool & pixels) | +------------------------------+----------------------------------------------------------------------------------------------------------------+ .. _api_StyleSheet_methods: Methods Description ------------------- .. _api_StyleSheet_9b827fe0: :ref:`TString` **StyleSheet::data** () const Returns content as a string. **See also** setData(). ---- .. _api_StyleSheet_b08a35f2: void **StyleSheet::resolve** (:ref:`Widget` * *widget*) Resolves the styles for a given *widget* based on the parsed CSS rules. It iterates through the CSS selectors and applies matching rules to the widget. ---- .. _api_StyleSheet_6839bae1: void **StyleSheet::resolveInline** (:ref:`Widget` * *widget*, :ref:`TString` & *style*) Resolves inline styles provided as a string (e.g., from the *style* attribute in XML). The method splits the inline styles into key-value pairs and applies them to the widget. ---- .. _api_StyleSheet_d329f5e7: void **StyleSheet::setData** (:ref:`TString` & *data*) Sets a new content data. **See also** data(). ---- .. _api_StyleSheet_1384be7a: void **StyleSheet::setStyleProperty** (:ref:`Widget` * *widget*, :ref:`TString` & *key*, :ref:`TString` & *value*) Directly sets a style property for a widget. It adds the specified *key* and *value* pair to the widget's style rules. ---- .. _api_StyleSheet_c235a84e: :ref:`Vector4` **StyleSheet::toColor** (:ref:`TString` & *value*) Converts a CSS color *value* (e.g., named colors like "blue" or hexadecimal colors like "#ff0000") to a Vector4 representing RGBA values. It handles both named colors and hex codes (including short hex formats like #FFF). ---- .. _api_StyleSheet_1527de90: float **StyleSheet::toLength** (:ref:`TString` & *value*, bool & *pixels*) Converts a length *value* (e.g., "10px" or "50%") into a numeric *value* and returns whether the *value* is in *pixels* or percentages.