gtkmm: Gtk::StyleProperty< T > Class Template Reference

gtkmm 3.24.8

Public Types | Public Member Functions | List of all members
Gtk::StyleProperty< T > Class Template Reference

Represents a widget style property. More...

`#include <gtkmm/styleproperty.h>`

Inheritance diagram for Gtk::StyleProperty< T >:
[legend]

## Public Types
typedef T | PropertyType
typedef Glib::Value< T > | ValueType

## Public Member Functions
| StyleProperty (Gtk::Widget & widget, const Glib::ustring & name)
| Constructs a style property for widget with name.
| StyleProperty (Gtk::Widget & widget, const Glib::ustring & name, const PropertyType & default_value)
| Constructs a style property for widget with name and default_value.
PropertyType | get_value () const
| Returns the value of the style property.
| operator PropertyType () const
| Returns the value of the style property.
Public Member Functions inherited from Gtk::StylePropertyBase
Glib::ustring | get_name () const
| Returns the name of the style property.

## Additional Inherited Members
Protected Member Functions inherited from Gtk::StylePropertyBase
| StylePropertyBase (Gtk::Widget & widget, GType value_type)
| Constructs a style property of type value_type for widget.
| ~StylePropertyBase () noexcept
bool | lookup_style_property (const Glib::ustring & name)
| Checks if the style property has already been installed.
void | install_style_property (GParamSpec * param_spec)
| Installs the style property specified by the given param_spec.
const char * | get_name_internal () const
| Returns the name of the style property.
Protected Attributes inherited from Gtk::StylePropertyBase
Gtk::Widget * | widget_
GType | value_type_
GParamSpec * | param_spec_

## Detailed Description

template<class T>
class Gtk::StyleProperty< T >

Represents a widget style property.

This class maps one to one to a style property of a widget in Gtk. A style property is similar to object properties (Glib::Property), but its value is stored in the style object associated with the widget. The style property, similarly to the object properties, has some global data for each property. The global data includes the following information about the style property:

- unique name, used to identify the style property
- human-readable nickname
- short description
- default value, minimum and maximum bounds (applicable depending on the type of the style property)
- flags, defining, among other things, whether the property can be read or written

The StyleProperty class currently supports only the name and default value. The minimum and maximum bounds are set to the full range of the value. The nickname and the description are set to empty. The flags are set to indicate that the property is read-only (this doesn't disallow a style provider to set the value of the property).

The global information must be installed into the widget once per property. This is handled automatically. A reference to the widget must be passed on the construction of the style property.

Since gtkmm 3.16:

## Member Typedef Documentation

## ◆ PropertyType

template <class T >

typedef T Gtk::StyleProperty< T >::PropertyType

## ◆ ValueType

template <class T >

typedef Glib::Value<T> Gtk::StyleProperty< T >::ValueType

## Constructor & Destructor Documentation

## ◆ StyleProperty() [1/2]

template <class T >

Gtk::StyleProperty< T >::StyleProperty | ( | Gtk::Widget & | widget,
|  | const Glib::ustring & | name
| ) |  |

Constructs a style property for widget with name.

For each instance of the widget, the same property must be constructed with the same name.

## ◆ StyleProperty() [2/2]

template <class T >

Gtk::StyleProperty< T >::StyleProperty | ( | Gtk::Widget & | widget,
|  | const Glib::ustring & | name,
|  | const PropertyType & | default_value
| ) |  |

Constructs a style property for widget with name and default_value.

For each instance of the widget, the same property must be constructed with the same name and default value.

## Member Function Documentation

## ◆ get_value()

template <class T >

PropertyType Gtk::StyleProperty< T >::get_value | ( |  | ) | const
| inline

Returns the value of the style property.

Equivalent to Gtk::Widget::get_style_property(get_name(), PropertyType& value).

## ◆ operator PropertyType()

template <class T >

Gtk::StyleProperty< T >::operator PropertyType | ( |  | ) | const
| inline

Returns the value of the style property.

Equivalent to Gtk::Widget::get_style_property(get_name(), PropertyType& value).