gtkmm 3.16.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::StyleContext Class Reference

This object stores styling information affecting a widget defined by WidgetPath. More...

`#include <gtkmm/stylecontext.h>`

Inheritance diagram for Gtk::StyleContext:
[legend]

## Public Member Functions

virtual | ~StyleContext ()
GtkStyleContext* | gobj ()
| Provides access to the underlying C GObject. More...
const GtkStyleContext* | gobj () const
| Provides access to the underlying C GObject. More...
GtkStyleContext* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
void | add_provider (const Glib::RefPtr< StyleProvider >& provider, guint priority)
| Adds a style provider to context, to be used in style construction. More...
void | remove_provider (const Glib::RefPtr< StyleProvider >& provider)
| Removes provider from the style providers list in context. More...
void | context_save ()
| Saves the context state, so temporary modifications done through add_class(), remove_class(), set_state(), etc. More...
void | context_restore ()
| Restores context state to a previous stage. More...
void | set_state (StateFlags flags)
| Sets the state to be used when rendering with any of the gtk_render_*() functions. More...
StateFlags | get_state () const
| Returns the state used when rendering. More...
void | set_scale (int scale)
| Sets the scale to use when getting image assets for the style . More...
int | get_scale () const
| Returns the scale used for assets. More...
bool | state_is_running (StateType state, gdouble* progress)
| Returns `true` if there is a transition animation running for the current region (see push_animatable_region()). More...
void | set_path (const WidgetPath& path)
| Sets the Gtk::WidgetPath used for style matching. More...
WidgetPath | get_path () const
| Returns the widget path used for style matching. More...
void | set_parent (const Glib::RefPtr< StyleContext >& parent)
| Sets the parent style context for context. More...
void | unset_parent ()
Glib::RefPtr< StyleContext > | get_parent ()
| Gets the parent context set via set_parent(). More...
Glib::RefPtr< const StyleContext > | get_parent () const
| Gets the parent context set via set_parent(). More...
std::vector< Glib::ustring > | list_classes () const
| Returns the list of classes currently defined in context. More...
void | add_class (const Glib::ustring& class_name)
| Adds a style class to context, so posterior calls to get() or any of the gtk_render_*() functions will make use of this new class for styling. More...
void | remove_class (const Glib::ustring& class_name)
| Removes class_name from context. More...
bool | has_class (const Glib::ustring& class_name)
| Returns `true` if context currently has defined the given class name. More...
GList* | list_regions ()
| Returns the list of regions currently defined in context. More...
void | add_region (const Glib::ustring& region_name, RegionFlags flags)
| Adds a region to context, so posterior calls to get() or any of the gtk_render_*() functions will make use of this new region for styling. More...
void | remove_region (const Glib::ustring& region_name)
| Removes a region from context. More...
bool | has_region (const Glib::ustring& region_name, RegionFlags& flags_return)
| Returns `true` if context has the region defined. More...
template<class PropertyType >
void | get_style_property (const Glib::ustring& property_name, PropertyType& value) const
| Gets the value of a style property. More...
void | get_style_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| Gets the value for a widget style property. More...
Glib::RefPtr< IconSet > | lookup_icon_set (const Glib::ustring& stock_id)
| Looks up stock_id in the icon factories associated to context and the default icon factory, returning an icon set if found, otherwise `0`. More...
void | set_screen (const Glib::RefPtr< Gdk::Screen >& screen)
| Attaches context to the given screen. More...
Glib::RefPtr< Gdk::Screen > | get_screen ()
| Returns the Gdk::Screen to which context is attached. More...
Glib::RefPtr< const Gdk::Screen > | get_screen () const
| Returns the Gdk::Screen to which context is attached. More...
void | set_direction (TextDirection direction)
| Sets the reading direction for rendering purposes. More...
TextDirection | get_direction () const
| Returns the widget direction used for rendering. More...
void | set_junction_sides (JunctionSides sides)
| Sets the sides where rendered elements (mostly through gtk_render_frame()) will visually connect with other visual elements. More...
JunctionSides | get_junction_sides () const
| Returns the sides where rendered elements connect visually with others. More...
bool | lookup_color (const Glib::ustring& color_name, Gdk::RGBA& color)
| Looks up and resolves a color name in the context color map. More...
void | notify_state_change (const Glib::RefPtr< Gdk::Window >& window, gpointer region_id, StateType state, bool state_value)
| Notifies a state change on context, so if the current style makes use of transition animations, one will be started so all rendered elements under region_id are animated for state state being set to value state_value. More...
void | cancel_animations (gpointer region_id)
| Stops all running animations for region_id and all animatable regions underneath. More...
void | scroll_animations (const Glib::RefPtr< Gdk::Window >& window, int dx, int dy)
| This function is analogous to gdk_window_scroll(), and should be called together with it so the invalidation areas for any ongoing animation are scrolled together with it. More...
void | push_animatable_region (gpointer region_id)
| Pushes an animatable region, so all further gtk_render_*() calls between this call and the following pop_animatable_region() will potentially show transition animations for this region if notify_state_change() is called for a given state, and the current theme/style defines transition animations for state changes. More...
void | pop_animatable_region ()
| Pops an animatable region from context. More...
Gdk::RGBA | get_color (StateFlags state=(StateFlags) 0) const
| Gets the foreground color for a given state. More...
Gdk::RGBA | get_background_color (StateFlags state=(StateFlags) 0) const
Gdk::RGBA | get_border_color (StateFlags state=(StateFlags) 0) const
Pango::FontDescription | get_font (StateFlags state=(StateFlags) 0) const
| Returns the font description for a given state. More...
Border | get_border (StateFlags state=(StateFlags) 0) const
Border | get_padding (StateFlags state=(StateFlags) 0) const
Border | get_margin (StateFlags state=(StateFlags) 0) const
void | invalidate ()
| Invalidates context style information, so it will be reconstructed again. More...
void | set_background (const Glib::RefPtr< Gdk::Window >& window)
| Sets the background of window to the background pattern or color specified in context for its current state. More...
void | render_check (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders a checkmark (as in a Gtk::CheckButton). More...
void | render_option (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders an option mark (as in a Gtk::RadioButton), the Gtk::STATE_FLAG_CHECKED state will determine whether the option is on or off, and Gtk::STATE_FLAG_INCONSISTENT whether it should be marked as undefined. More...
void | render_arrow (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double angle, double x, double y, double size)
| Renders an arrow pointing to angle. More...
void | render_background (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders the background of an element. More...
void | render_frame (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders a frame around the rectangle defined by x, y, width, height. More...
void | render_expander (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders an expander (as used in Gtk::TreeView and Gtk::Expander) in the area defined by x, y, width, height. More...
void | render_focus (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders a focus indicator on the rectangle determined by x, y, width, height. More...
void | render_layout (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, PangoLayout* layout)
| Renders layout on the coordinates x, y. More...
void | render_layout (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, const Glib::RefPtr< Pango::Layout >& layout)
| Renders layout on the coordinates x, y. More...
void | render_line (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x0, double y0, double x1, double y1)
| Renders a line from (x0, y0) to (x1, y1). More...
void | render_slider (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height, Orientation orientation)
| Renders a slider (as in Gtk::Scale) in the rectangle defined by x, y, width, height. More...
void | render_frame_gap (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height, PositionType gap_side, double xy0_gap, double xy1_gap)
| Renders a frame around the rectangle defined by ( x, y, width, height), leaving a gap on one side. More...
void | render_extension (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height, PositionType gap_side)
| Renders a extension (as in a Gtk::Notebook tab) in the rectangle defined by x, y, width, height. More...
void | render_handle (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders a handle (as in Gtk::HandleBox, Gtk::Paned and Gtk::Window’s resize grip), in the rectangle determined by x, y, width, height. More...
void | render_activity (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, double width, double height)
| Renders an activity indicator (such as in Gtk::Spinner). More...
Glib::RefPtr< Gdk::Pixbuf > | render_icon_pixbuf (const IconSource& source, IconSize size)
| Renders the icon specified by source at the given size, returning the result in a pixbuf. More...
void | render_icon (const ::Cairo::RefPtr< ::Cairo::Context >& cr, const Glib::RefPtr< Gdk::Pixbuf >& pixbuf, double x, double y)
| Renders the icon in pixbuf at the specified x and y coordinates. More...
void | render_insertion_cursor (const ::Cairo::RefPtr< ::Cairo::Context >& cr, double x, double y, const Glib::RefPtr< Pango::Layout >& layout, int index, Pango::Direction direction)
| Draws a text caret on cr at the specified index of layout. More...
Glib::SignalProxy0< void > | signal_changed ()
Glib::PropertyProxy< Glib::RefPtr< Gdk::Screen > > | property_screen ()
| The associated GdkScreen. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Screen > > | property_screen () const
| The associated GdkScreen. More...
Glib::PropertyProxy< TextDirection > | property_direction ()
| Text direction. More...
Glib::PropertyProxy_ReadOnly< TextDirection > | property_direction () const
| Text direction. More...
Glib::PropertyProxy< Glib::RefPtr< StyleContext > > | property_parent ()
| The parent style context. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< StyleContext > > | property_parent () const
| The parent style context. More...
Public Member Functions inherited from Glib::Object
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
void | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< StyleContext > | create ()
static void | add_provider_for_screen (const Glib::RefPtr< Gdk::Screen >& screen, const Glib::RefPtr< StyleProvider >& provider, guint priority)
| Adds a global style provider to screen, which will be used in style construction for all Gtk::StyleContexts under screen. More...
static void | remove_provider_for_screen (const Glib::RefPtr< Gdk::Screen >& screen, const Glib::RefPtr< StyleProvider >& provider)
| Removes provider from the global style providers list in screen. More...

## Protected Member Functions

| StyleContext ()
virtual void | on_changed ()
| This is a default handler for the signal signal_changed(). More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
virtual | ~Object ()
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
virtual | ~ObjectBase ()=0
void | initialize (GObject *castitem)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gtk::StyleContext > | wrap (GtkStyleContext* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members

Public Types inherited from Glib::Object
typedef void(* | DestroyNotify) (gpointer data)

## Detailed Description

This object stores styling information affecting a widget defined by WidgetPath.

In order to construct the final style information, StyleContext queries information from all attached StyleProviders. Style providers can be either attached explicitly to the context through add_provider(), or to the screen through add_provider_for_screen(). The resulting style is a combination of all providers' information in priority order.

For GTK+ widgets, any StyleContext returned by Widget::get_style_context() will already have a WidgetPath, a Gdk::Screen and RTL/LTR information set, The style context will be also updated automatically if any of these settings change on the widget.

If you are using the theming layer standalone, you will need to set a widget path and a screen yourself to the created style context through set_path() and set_screen(), as well as updating the context yourself using invalidate() whenever any of the conditions change, such as a change in the Settings::property_gtk_theme_name() setting or a hierarchy change in the rendered widget.

## Transition animations

StyleContext has built-in support for state change transitions. Note that these animations respect the Settings::property_gtk_enable_animations() setting.

For simple widgets where state changes affect the whole widget area, calling notify_state_change() with a no region is sufficient to trigger the transition animation. And GTK+ already does that when Widget::set_state() or Widget::set_state_flags() are called.

If a widget needs to declare several animatable regions (i.e. not affecting the whole widget area), its Widget::signal_draw() signal handler needs to wrap the render operations for the different regions with calls to push_animatable_region() and pop_animatable_region(). These methods take an identifier for the region which must be unique within the style context. For simple widgets with a fixed set of animatable regions, using an enumeration works well.

For complex widgets with an arbitrary number of animatable regions, it is up to the implementation to come up with a way to uniquely identify each animatable region. Using pointers to internal objects is one way to achieve this.

The widget also needs to notify the style context about a state change for a given animatable region so the animation is triggered. notify_state_change() can take no region IDs, meaning that the whole widget area will be updated by the animation.

Since gtkmm 3.0:

## Constructor & Destructor Documentation

virtual Gtk::StyleContext::~StyleContext | ( |  | ) |

virtual

Gtk::StyleContext::StyleContext | ( |  | ) |

protected

## Member Function Documentation

void Gtk::StyleContext::add_class | ( | const Glib::ustring & | class_name | ) |

Adds a style class to context, so posterior calls to get() or any of the gtk_render_*() functions will make use of this new class for styling.

In the CSS file format, a Gtk::Entry defining an “entry” class, would be matched by:

[C example ellipted]

While any widget defining an “entry” class would be matched by:

[C example ellipted]

Since gtkmm 3.0:

Parameters

  class_name | Class name to use in styling.

void Gtk::StyleContext::add_provider | ( | const Glib::RefPtr< StyleProvider >& | provider,
|  | guint | priority
| ) |  |

Adds a style provider to context, to be used in style construction.

Note that a style provider added by this function only affects the style of the widget to which context belongs. If you want to affect the style of all widgets, use add_provider_for_screen().

Note
  If both priorities are the same, a Gtk::StyleProvider added through this function takes precedence over another added through add_provider_for_screen().

Since gtkmm 3.0:

Parameters

  provider | A Gtk::StyleProvider.
  priority | The priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between Gtk::STYLE_PROVIDER_PRIORITY_FALLBACK and Gtk::STYLE_PROVIDER_PRIORITY_USER.

static void Gtk::StyleContext::add_provider_for_screen | ( | const Glib::RefPtr< Gdk::Screen >& | screen,
|  | const Glib::RefPtr< StyleProvider >& | provider,
|  | guint | priority
| ) |  |

static

Adds a global style provider to screen, which will be used in style construction for all Gtk::StyleContexts under screen.

GTK+ uses this to make styling information from Gtk::Settings available.

Note
  If both priorities are the same, A Gtk::StyleProvider added through add_provider() takes precedence over another added through this function.

Since gtkmm 3.0:

Parameters

  screen | A Gdk::Screen.
  provider | A Gtk::StyleProvider.
  priority | The priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between Gtk::STYLE_PROVIDER_PRIORITY_FALLBACK and Gtk::STYLE_PROVIDER_PRIORITY_USER.

void Gtk::StyleContext::add_region | ( | const Glib::ustring & | region_name,
|  | RegionFlags | flags
| ) |  |

Adds a region to context, so posterior calls to get() or any of the gtk_render_*() functions will make use of this new region for styling.

In the CSS file format, a Gtk::TreeView defining a “row” region, would be matched by:

[C example ellipted]

Pseudo-classes are used for matching flags, so the two following rules:

[C example ellipted]

would apply to even and odd rows, respectively.

Region names must only contain lowercase letters and “-”, starting always with a lowercase letter.

Since gtkmm 3.0:

Deprecated: 3.14

Deprecated:
  There is no replacement.

Parameters

  region_name | Region name to use in styling.
  flags | Flags that apply to the region.

void Gtk::StyleContext::cancel_animations | ( | gpointer | region_id | ) |

Stops all running animations for region_id and all animatable regions underneath.

A `0` region_id will stop all ongoing animations in context, when dealing with a Gtk::StyleContext obtained through Gtk::Widget::get_style_context(), this is normally done for you in all circumstances you would expect all widget to be stopped, so this should be only used in complex widgets with different animatable regions.

Since gtkmm 3.0:

Deprecated: 3.6: This function does nothing.

Deprecated:
  This function does nothing.

Parameters

  region_id | Animatable region to stop, or `0`. See push_animatable_region().

void Gtk::StyleContext::context_restore | ( |  | ) |

Restores context state to a previous stage.

See save().

Since gtkmm 3.0:

void Gtk::StyleContext::context_save | ( |  | ) |

Saves the context state, so temporary modifications done through add_class(), remove_class(), set_state(), etc.

can quickly be reverted in one go through restore().

The matching call to restore() must be done before GTK returns to the main loop.

Since gtkmm 3.0:

static Glib::RefPtr<StyleContext> Gtk::StyleContext::create | ( |  | ) |

static

Gdk::RGBA Gtk::StyleContext::get_background_color | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Deprecated:
  Use render_background() instead.

Border Gtk::StyleContext::get_border | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Gdk::RGBA Gtk::StyleContext::get_border_color | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Deprecated:
  Use render_frame() instead.

Gdk::RGBA Gtk::StyleContext::get_color | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Gets the foreground color for a given state.

Since gtkmm 3.0:

Parameters

  state | State to retrieve the color for.

Returns
  The foreground color for the given state.

TextDirection Gtk::StyleContext::get_direction | ( |  | ) | const

Returns the widget direction used for rendering.

Since gtkmm 3.0:

Deprecated: 3.8: Use get_state() and check for Gtk::STATE_FLAG_DIR_LTR and Gtk::STATE_FLAG_DIR_RTL instead.

Deprecated:
  Use get_state() and check for StateFlags::STATE_FLAG_DIR_LTR and StateFlags::STATE_FLAG_DIR_RTL instead.

Returns
  The widget direction.

Pango::FontDescription Gtk::StyleContext::get_font | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Returns the font description for a given state.

Since gtkmm 3.0:

Parameters

  state | State to retrieve the font for.

Returns
  The Pango::FontDescription for the given state.

JunctionSides Gtk::StyleContext::get_junction_sides | ( |  | ) | const

Returns the sides where rendered elements connect visually with others.

Since gtkmm 3.0:

Returns
  The junction sides.

Border Gtk::StyleContext::get_margin | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Border Gtk::StyleContext::get_padding | ( | StateFlags | state = `(StateFlags) 0` | ) | const

Glib::RefPtr<StyleContext> Gtk::StyleContext::get_parent | ( |  | ) |

Gets the parent context set via set_parent().

See that function for details.

Since gtkmm 3.4:

Returns
  The parent context or `0`.

Glib::RefPtr<const StyleContext> Gtk::StyleContext::get_parent | ( |  | ) | const

Gets the parent context set via set_parent().

See that function for details.

Since gtkmm 3.4:

Returns
  The parent context or `0`.

WidgetPath Gtk::StyleContext::get_path | ( |  | ) | const

Returns the widget path used for style matching.

Since gtkmm 3.0:

Returns
  A Gtk::WidgetPath.

int Gtk::StyleContext::get_scale | ( |  | ) | const

Returns the scale used for assets.

Since gtkmm 3.10:

Returns
  The scale.

Glib::RefPtr<Gdk::Screen> Gtk::StyleContext::get_screen | ( |  | ) |

Returns the Gdk::Screen to which context is attached.

Returns
  A Gdk::Screen.

Glib::RefPtr<const Gdk::Screen> Gtk::StyleContext::get_screen | ( |  | ) | const

Returns the Gdk::Screen to which context is attached.

Returns
  A Gdk::Screen.

StateFlags Gtk::StyleContext::get_state | ( |  | ) | const

Returns the state used when rendering.

Since gtkmm 3.0:

Returns
  The state flags.

template <class PropertyType >

void Gtk::StyleContext::get_style_property | ( | const Glib::ustring & | property_name,
|  | PropertyType & | value
| ) |  | const

Gets the value of a style property.

Parameters

  property_name | The name of a style property.
  value | Location to return the property value.

void Gtk::StyleContext::get_style_property_value | ( | const Glib::ustring & | property_name,
|  | Glib::ValueBase & | value
| ) |  | const

Gets the value for a widget style property.

When value is no longer needed, Glib::value_unset() must be called to free any allocated memory.

Parameters

  property_name | The name of the widget style property.
  value | Return location for the property value.

static GType Gtk::StyleContext::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GtkStyleContext* Gtk::StyleContext::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

const GtkStyleContext* Gtk::StyleContext::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

GtkStyleContext* Gtk::StyleContext::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gtk::StyleContext::has_class | ( | const Glib::ustring & | class_name | ) |

Returns `true` if context currently has defined the given class name.

Since gtkmm 3.0:

Parameters

  class_name | A class name.

Returns
  `true` if context has class_name defined.

bool Gtk::StyleContext::has_region | ( | const Glib::ustring & | region_name,
|  | RegionFlags& | flags_return
| ) |  |

Returns `true` if context has the region defined.

If flags_return is not `0`, it is set to the flags affecting the region.

Since gtkmm 3.0:

Deprecated: 3.14

Deprecated:
  There is no replacement.

Parameters

  region_name | A region name.
  flags_return | Return location for region flags.

Returns
  `true` if region is defined.

void Gtk::StyleContext::invalidate | ( |  | ) |

Invalidates context style information, so it will be reconstructed again.

It is useful if you modify the context and need the new information immediately.

Since gtkmm 3.0:

Deprecated: 3.12: Style contexts are invalidated automatically.

Deprecated:
  Style contexts are invalidated automatically.

std::vector<Glib::ustring> Gtk::StyleContext::list_classes | ( |  | ) | const

Returns the list of classes currently defined in context.

Since gtkmm 3.0:

Returns
  A List of strings with the currently defined classes. The contents of the list are owned by GTK+, but you must free the list itself with Glib::list_free() when you are done with it.

GList* Gtk::StyleContext::list_regions | ( |  | ) |

Returns the list of regions currently defined in context.

Since gtkmm 3.0:

Deprecated: 3.14

Deprecated:
  There is no replacement.

Returns
  A List of strings with the currently defined regions. The contents of the list are owned by GTK+, but you must free the list itself with Glib::list_free() when you are done with it.

bool Gtk::StyleContext::lookup_color | ( | const Glib::ustring & | color_name,
|  | Gdk::RGBA& | color
| ) |  |

Looks up and resolves a color name in the context color map.

Parameters

  color_name | Color name to lookup.
  color | Return location for the looked up color.

Returns
  `true` if color_name was found and resolved, `false` otherwise.

Glib::RefPtr<IconSet> Gtk::StyleContext::lookup_icon_set | ( | const Glib::ustring & | stock_id | ) |

Looks up stock_id in the icon factories associated to context and the default icon factory, returning an icon set if found, otherwise `0`.

Deprecated: 3.10: Use Gtk::IconTheme::lookup_icon() instead.

Deprecated:
  Use IconTheme::lookup_icon() instead.

Parameters

  stock_id | An icon name.

Returns
  The looked up Gtk::IconSet, or `0`.

void Gtk::StyleContext::notify_state_change | ( | const Glib::RefPtr< Gdk::Window >& | window,
|  | gpointer | region_id,
|  | StateType | state,
|  | bool | state_value
| ) |  |

Notifies a state change on context, so if the current style makes use of transition animations, one will be started so all rendered elements under region_id are animated for state state being set to value state_value.

The window parameter is used in order to invalidate the rendered area as the animation runs, so make sure it is the same window that is being rendered on by the gtk_render_*() functions.

If region_id is `0`, all rendered elements using context will be affected by this state transition.

As a practical example, a Gtk::Button notifying a state transition on the prelight state:

[C example ellipted]

Can be handled in the CSS file like this:

[C example ellipted]

This combination will animate the button background from red to white if a pointer enters the button, and back to red if the pointer leaves the button.

Note that state is used when finding the transition parameters, which is why the style places the transition under the :hover pseudo-class.

Since gtkmm 3.0:

Deprecated: 3.6: This function does nothing.

Deprecated:
  This function does nothing.

Parameters

  window | A Gdk::Window.
  region_id | Animatable region to notify on, or `0`. See push_animatable_region().
  state | State to trigger transition for.
  state_value | `true` if state is the state we are changing to, `false` if we are changing away from it.

virtual void Gtk::StyleContext::on_changed | ( |  | ) |

protected virtual

This is a default handler for the signal signal_changed().

void Gtk::StyleContext::pop_animatable_region | ( |  | ) |

Pops an animatable region from context.

See push_animatable_region().

Since gtkmm 3.0:

Deprecated: 3.6: This function does nothing.

Deprecated:
  This function does nothing.

Glib::PropertyProxy< TextDirection > Gtk::StyleContext::property_direction | ( |  | ) |

Text direction.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< TextDirection > Gtk::StyleContext::property_direction | ( |  | ) | const

Text direction.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< Glib::RefPtr<StyleContext> > Gtk::StyleContext::property_parent | ( |  | ) |

The parent style context.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<StyleContext> > Gtk::StyleContext::property_parent | ( |  | ) | const

The parent style context.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< Glib::RefPtr<Gdk::Screen> > Gtk::StyleContext::property_screen | ( |  | ) |

The associated GdkScreen.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gdk::Screen> > Gtk::StyleContext::property_screen | ( |  | ) | const

The associated GdkScreen.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

void Gtk::StyleContext::push_animatable_region | ( | gpointer | region_id | ) |

Pushes an animatable region, so all further gtk_render_*() calls between this call and the following pop_animatable_region() will potentially show transition animations for this region if notify_state_change() is called for a given state, and the current theme/style defines transition animations for state changes.

The region_id used must be unique in context so the themes can uniquely identify rendered elements subject to a state transition.

Since gtkmm 3.0:

Deprecated: 3.6: This function does nothing.

Deprecated:
  This function does nothing.

Parameters

  region_id | Unique identifier for the animatable region.

void Gtk::StyleContext::remove_class | ( | const Glib::ustring & | class_name | ) |

Removes class_name from context.

Since gtkmm 3.0:

Parameters

  class_name | Class name to remove.

void Gtk::StyleContext::remove_provider | ( | const Glib::RefPtr< StyleProvider >& | provider | ) |

Removes provider from the style providers list in context.

Since gtkmm 3.0:

Parameters

  provider | A Gtk::StyleProvider.

static void Gtk::StyleContext::remove_provider_for_screen | ( | const Glib::RefPtr< Gdk::Screen >& | screen,
|  | const Glib::RefPtr< StyleProvider >& | provider
| ) |  |

static

Removes provider from the global style providers list in screen.

Since gtkmm 3.0:

Parameters

  screen | A Gdk::Screen.
  provider | A Gtk::StyleProvider.

void Gtk::StyleContext::remove_region | ( | const Glib::ustring & | region_name | ) |

Removes a region from context.

Since gtkmm 3.0:

Deprecated: 3.14

Deprecated:
  There is no replacement.

Parameters

  region_name | Region name to unset.

void Gtk::StyleContext::render_activity | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders an activity indicator (such as in Gtk::Spinner).

The state Gtk::STATE_FLAG_CHECKED determines whether there is activity going on.

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_arrow | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | angle,
|  | double | x,
|  | double | y,
|  | double | size
| ) |  |

Renders an arrow pointing to angle.

Typical arrow rendering at 0, 1/2 ∏, ∏ and 3/2 ∏:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  angle | Arrow angle from 0 to 2* PI, being 0 the arrow pointing to the north.
  x | X origin of the render area.
  y | Y origin of the render area.
  size | Square side for render area.

void Gtk::StyleContext::render_background | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders the background of an element.

Typical background rendering, showing the effect of `background-image`, `border-width` and `border-radius`:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_check | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders a checkmark (as in a Gtk::CheckButton).

The Gtk::STATE_FLAG_CHECKED state determines whether the check is on or off, and Gtk::STATE_FLAG_INCONSISTENT determines whether it should be marked as undefined.

Typical checkmark rendering:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_expander | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders an expander (as used in Gtk::TreeView and Gtk::Expander) in the area defined by x, y, width, height.

The state Gtk::STATE_FLAG_CHECKED determines whether the expander is collapsed or expanded.

Typical expander rendering:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_extension | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | PositionType | gap_side
| ) |  |

Renders a extension (as in a Gtk::Notebook tab) in the rectangle defined by x, y, width, height.

The side where the extension connects to is defined by gap_side.

Typical extension rendering:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.
  gap_side | Side where the gap is.

void Gtk::StyleContext::render_focus | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders a focus indicator on the rectangle determined by x, y, width, height.

Typical focus rendering:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_frame | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders a frame around the rectangle defined by x, y, width, height.

Examples of frame rendering, showing the effect of `border-image`, `border-color`, `border-width`, `border-radius` and junctions:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_frame_gap | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | PositionType | gap_side,
|  | double | xy0_gap,
|  | double | xy1_gap
| ) |  |

Renders a frame around the rectangle defined by ( x, y, width, height), leaving a gap on one side.

xy0_gap and xy1_gap will mean X coordinates for Gtk::POS_TOP and Gtk::POS_BOTTOM gap sides, and Y coordinates for Gtk::POS_LEFT and Gtk::POS_RIGHT.

Typical rendering of a frame with a gap:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.
  gap_side | Side where the gap is.
  xy0_gap | Initial coordinate (X or Y depending on gap_side) for the gap.
  xy1_gap | End coordinate (X or Y depending on gap_side) for the gap.

void Gtk::StyleContext::render_handle | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders a handle (as in Gtk::HandleBox, Gtk::Paned and Gtk::Window’s resize grip), in the rectangle determined by x, y, width, height.

Handles rendered for the paned and grip classes:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_icon | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | const Glib::RefPtr< Gdk::Pixbuf >& | pixbuf,
|  | double | x,
|  | double | y
| ) |  |

Renders the icon in pixbuf at the specified x and y coordinates.

Since gtkmm 3.2:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  pixbuf | A Gdk::Pixbuf containing the icon to draw.
  x | X position for the pixbuf.
  y | Y position for the pixbuf.

Glib::RefPtr<Gdk::Pixbuf> Gtk::StyleContext::render_icon_pixbuf | ( | const IconSource& | source,
|  | IconSize | size
| ) |  |

Renders the icon specified by source at the given size, returning the result in a pixbuf.

Since gtkmm 3.0:

Deprecated: 3.10: Use Gtk::IconTheme::load_icon() instead.

Deprecated:
  Use IconTheme::load_icon() instead.

Parameters

  context | A Gtk::StyleContext.
  source | The Gtk::IconSource specifying the icon to render.
  size | The size to render the icon at. A size of (GtkIconSize) -1 means render at the size of the source and don’t scale.

Returns
  A newly-created Gdk::Pixbuf containing the rendered icon.

void Gtk::StyleContext::render_insertion_cursor | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | const Glib::RefPtr< Pango::Layout > & | layout,
|  | int | index,
|  | Pango::Direction | direction
| ) |  |

Draws a text caret on cr at the specified index of layout.

Since gtkmm 3.4:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin.
  y | Y origin.
  layout | The Pango::Layout of the text.
  index | The index in the Pango::Layout.
  direction | The Pango::Direction of the text.

void Gtk::StyleContext::render_layout | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | PangoLayout * | layout
| ) |  |

Renders layout on the coordinates x, y.

Since gtkmm 3.0:

Deprecated:
  Use the render_layout() taking a const Glib::RefPtr<Pango::Layout>& layout.

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin.
  y | Y origin.
  layout | The Pango::Layout to render.

void Gtk::StyleContext::render_layout | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | const Glib::RefPtr< Pango::Layout > & | layout
| ) |  |

Renders layout on the coordinates x, y.

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin.
  y | Y origin.
  layout | The Pango::Layout to render.

void Gtk::StyleContext::render_line | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x0,
|  | double | y0,
|  | double | x1,
|  | double | y1
| ) |  |

Renders a line from (x0, y0) to (x1, y1).

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x0 | X coordinate for the origin of the line.
  y0 | Y coordinate for the origin of the line.
  x1 | X coordinate for the end of the line.
  y1 | Y coordinate for the end of the line.

void Gtk::StyleContext::render_option | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Renders an option mark (as in a Gtk::RadioButton), the Gtk::STATE_FLAG_CHECKED state will determine whether the option is on or off, and Gtk::STATE_FLAG_INCONSISTENT whether it should be marked as undefined.

Typical option mark rendering:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.

void Gtk::StyleContext::render_slider | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | cr,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | Orientation | orientation
| ) |  |

Renders a slider (as in Gtk::Scale) in the rectangle defined by x, y, width, height.

orientation defines whether the slider is vertical or horizontal.

Typical slider rendering:

Since gtkmm 3.0:

Parameters

  context | A Gtk::StyleContext.
  cr | A #cairo_t.
  x | X origin of the rectangle.
  y | Y origin of the rectangle.
  width | Rectangle width.
  height | Rectangle height.
  orientation | Orientation of the slider.

void Gtk::StyleContext::scroll_animations | ( | const Glib::RefPtr< Gdk::Window >& | window,
|  | int | dx,
|  | int | dy
| ) |  |

This function is analogous to gdk_window_scroll(), and should be called together with it so the invalidation areas for any ongoing animation are scrolled together with it.

Since gtkmm 3.0:

Deprecated: 3.6: This function does nothing.

Deprecated:
  This function does nothing.

Parameters

  window | A Gdk::Window used previously in notify_state_change().
  dx | Amount to scroll in the X axis.
  dy | Amount to scroll in the Y axis.

void Gtk::StyleContext::set_background | ( | const Glib::RefPtr< Gdk::Window >& | window | ) |

Sets the background of window to the background pattern or color specified in context for its current state.

Since gtkmm 3.0:

Parameters

  window | A Gdk::Window.

void Gtk::StyleContext::set_direction | ( | TextDirection | direction | ) |

Sets the reading direction for rendering purposes.

If you are using a Gtk::StyleContext returned from Gtk::Widget::get_style_context(), you do not need to call this yourself.

Since gtkmm 3.0:

Deprecated: 3.8: Use set_state() with Gtk::STATE_FLAG_DIR_LTR and Gtk::STATE_FLAG_DIR_RTL instead.

Deprecated:
  Use set_state() with StateFlags::STATE_FLAG_DIR_LTR and StateFlags::STATE_FLAG_DIR_RTL instead.

Parameters

  direction | The new direction.

void Gtk::StyleContext::set_junction_sides | ( | JunctionSides | sides | ) |

Sets the sides where rendered elements (mostly through gtk_render_frame()) will visually connect with other visual elements.

This is merely a hint that may or may not be honored by themes.

Container widgets are expected to set junction hints as appropriate for their children, so it should not normally be necessary to call this function manually.

Since gtkmm 3.0:

Parameters

  sides | Sides where rendered elements are visually connected to other elements.

void Gtk::StyleContext::set_parent | ( | const Glib::RefPtr< StyleContext >& | parent | ) |

Sets the parent style context for context.

The parent style context is used to implement inheritance of properties.

If you are using a Gtk::StyleContext returned from Gtk::Widget::get_style_context(), the parent will be set for you.

Since gtkmm 3.4:

Parameters

  parent | The new parent or `0`.

void Gtk::StyleContext::set_path | ( | const WidgetPath& | path | ) |

Sets the Gtk::WidgetPath used for style matching.

As a consequence, the style will be regenerated to match the new given path.

If you are using a Gtk::StyleContext returned from Gtk::Widget::get_style_context(), you do not need to call this yourself.

Since gtkmm 3.0:

Parameters

  path | A Gtk::WidgetPath.

void Gtk::StyleContext::set_scale | ( | int | scale | ) |

Sets the scale to use when getting image assets for the style .

Since gtkmm 3.10:

Parameters

  scale | Scale.

void Gtk::StyleContext::set_screen | ( | const Glib::RefPtr< Gdk::Screen >& | screen | ) |

Attaches context to the given screen.

The screen is used to add style information from “global” style providers, such as the screens Gtk::Settings instance.

If you are using a Gtk::StyleContext returned from Gtk::Widget::get_style_context(), you do not need to call this yourself.

Since gtkmm 3.0:

Parameters

  screen | A Gdk::Screen.

void Gtk::StyleContext::set_state | ( | StateFlags | flags | ) |

Sets the state to be used when rendering with any of the gtk_render_*() functions.

Since gtkmm 3.0:

Parameters

  flags | State to represent.

Glib::SignalProxy0< void > Gtk::StyleContext::signal_changed | ( |  | ) |

Slot Prototype:
  `void on_my_changed()`

bool Gtk::StyleContext::state_is_running | ( | StateType | state,
|  | gdouble * | progress
| ) |  |

Returns `true` if there is a transition animation running for the current region (see push_animatable_region()).

If progress is not `0`, the animation progress will be returned there, 0.0 means the state is closest to being unset, while 1.0 means it’s closest to being set. This means transition animation will run from 0 to 1 when state is being set and from 1 to 0 when it’s being unset.

Since gtkmm 3.0:

Deprecated: 3.6: This function always returns `false`

Deprecated:
  This function always returns `false`.

Parameters

  state | A widget state.
  progress | Return location for the transition progress.

Returns
  `true` if there is a running transition animation for state.

void Gtk::StyleContext::unset_parent | ( |  | ) |

## Friends And Related Function Documentation

Glib::RefPtr< Gtk::StyleContext > wrap | ( | GtkStyleContext * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.