#include <Pt/Forms/StyleOptions.h>
Stores named appearance options. More...
Public Member Functions | |
| StyleOptions () | |
| Constructs an empty options object. | |
| StyleOptions (const StyleOptions &o) | |
| Copies o. | |
| ~StyleOptions () | |
| Destructor. | |
| StyleOptions & | operator= (const StyleOptions &o) |
| Assigns o. | |
| std::size_t | generation () const |
| Returns the current change generation. | |
| bool | hasOptions () const |
| Returns true if this object contains any local option. | |
| bool | isDefault (const StyleOptions &base) const |
| Returns true if this object does not override base. | |
| void | bind (const StyleOptions *inherited) |
| Binds this overlay to the parent options inherited. | |
| const StyleOptions * | parent () const |
| Returns the bound parent options, or 0. | |
| template<typename T> | |
| const T * | findLocal () const |
| Returns the local option of type T, or 0. | |
| template<typename T> | |
| const T * | find () const |
| Returns the local or inherited option of type T, or 0. | |
| template<typename T> | |
| const T & | get () const |
| Returns the local or inherited option of type T. | |
| template<typename T> | |
| void | set (const T &option) |
| Adds or replaces the local option of type T. | |
| template<typename T> | |
| void | reset () |
| Removes the local option of type T if present. | |
Static Public Member Functions | |
| static StyleOptions | defaults () |
| Returns options filled with the built-in default values. | |
Static Public Attributes | |
| static const std::size_t | InvalidGeneration = 0 |
| Invalid generation value. | |
A StyleOptions object contains named appearance options, such as the application background, text colors, accent color, contour pen, and default font. A Style uses these values when it prepares the renderers that paint controls.
Application owns the global style options. It creates them from defaults() and uses them with the default PlatinumStyle. To change the application theme, create an options object, change the values that the application requires, and pass it to Application::setStyleOptions(). The application resets its renderers and invalidates its widgets so that the new appearance is applied.
The default constructor creates an empty options object. An empty object is useful as a local overlay for a control. A styler binds this overlay to the application options. A local option overrides the option of the same type in the application options, while an option that is not present locally continues to use the application value. Application owns the live global instance, constructed from defaults(). Application::styleOptions() returns that object as const.
findLocal() searches only this object and returns 0 when the option is not stored locally. find() searches this object and then its bound parent. After bind(), get() returns a local or inherited token and throws std::logic_error when the requested option is not available. set() adds or replaces a local option, and reset() removes a local option.
StyleOptions stores tokens that every style can honor. Look-specific metrics stay in the derived style or renderer.
FontOption supports complete and partial font overrides. A local option can change only the font size, weight, or slant while inheriting the font family and all remaining attributes from the application font.
generation() changes when local options or their binding change. Stylers use the generation to detect that a renderer must prepare its drawing state again.
| std::size_t generation | ( | ) | const |
The generation changes when local options or their binding change.
| void bind | ( | const StyleOptions * | inherited | ) |
Rebinding with the same parent and parent generation does no work. Passing 0 removes the parent.
| const T & get | ( | ) | const |
| %std::logic_error | if the requested option is not available. |