Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions

Gtk::StyleContext Class Reference

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

Inheritance diagram for Gtk::StyleContext:
Inheritance graph
[legend]
Collaboration diagram for Gtk::StyleContext:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~StyleContext ()
GtkStyleContext* gobj ()
 Provides access to the underlying C GObject.
const GtkStyleContext* gobj () const
 Provides access to the underlying C GObject.
GtkStyleContext* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void add_provider (const Glib::RefPtr< StyleProvider >& provider, guint priority)
void remove_provider (const Glib::RefPtr< StyleProvider >& provider)
void context_save ()
void context_restore ()
void set_state (StateFlags flags)
StateFlags get_state () const
bool state_is_running (StateType state, gdouble* progress)
void set_path (const WidgetPath& path)
WidgetPath get_path () const
void add_class (const Glib::ustring& class_name)
void remove_class (const Glib::ustring& class_name)
bool has_class (const Glib::ustring& class_name)
GList* list_regions ()
void add_region (const Glib::ustring& region_name, RegionFlags flags)
void remove_region (const Glib::ustring& region_name)
bool has_region (const Glib::ustring& region_name, RegionFlags& flags_return)
Glib::RefPtr< IconSetlookup_icon_set (const Glib::ustring& stock_id)
void set_screen (const Glib::RefPtr< Gdk::Screen >& screen)
Glib::RefPtr< Gdk::Screenget_screen ()
Glib::RefPtr< const Gdk::Screenget_screen () const
void set_direction (TextDirection direction)
TextDirection get_direction () const
void set_junction_sides (JunctionSides sides)
JunctionSides get_junction_sides () const
bool lookup_color (const Glib::ustring& color_name, Gdk::RGBA& color)
void notify_state_change (const Glib::RefPtr< Gdk::Window >& window, gpointer region_id, StateType state, bool state_value)
void push_animatable_region (gpointer region_id)
void pop_animatable_region ()
Gdk::RGBA get_color (StateFlags state=(StateFlags) 0) const
Gdk::RGBA get_background_color (StateFlags state=(StateFlags) 0) const
Gdk::RGBA get_border_color (StateFlags state=(StateFlags) 0) const
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 ()
void set_background (const Glib::RefPtr< Gdk::Window >& window)
void render_check (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_option (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_arrow (const Cairo::RefPtr< Cairo::Context >& cr, double angle, double x, double y, double size)
void render_background (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_frame (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_expander (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_focus (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_layout (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, PangoLayout* layout)
void render_line (const Cairo::RefPtr< Cairo::Context >& cr, double x0, double y0, double x1, double y1)
void render_slider (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height, Orientation orientation)
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)
void render_extension (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height, PositionType gap_side)
void render_handle (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
void render_activity (const Cairo::RefPtr< Cairo::Context >& cr, double x, double y, double width, double height)
Glib::RefPtr< Gdk::Pixbufrender_icon_pixbuf (const IconSource& source, IconSize size)
Glib::SignalProxy0< void > signal_changed ()
Glib::PropertyProxy
< Glib::RefPtr< Gdk::Screen > > 
property_screen ()
 The associated GdkScreen.
Glib::PropertyProxy_ReadOnly
< Glib::RefPtr< Gdk::Screen > > 
property_screen () const
 The associated GdkScreen.
Glib::PropertyProxy
< TextDirection
property_direction ()
 Text direction.
Glib::PropertyProxy_ReadOnly
< TextDirection
property_direction () const
 Text direction.

Static Public Member Functions

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

Protected Member Functions

 StyleContext ()
virtual void on_changed ()

Related Functions

(Note that these are not member functions.)


Glib::RefPtr< Gtk::StyleContextwrap (GtkStyleContext* object, bool take_copy=false)
 A Glib::wrap() method for this object.

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 )
void Gtk::StyleContext::add_provider ( const Glib::RefPtr< StyleProvider >&  provider,
guint  priority 
)
static void Gtk::StyleContext::add_provider_for_screen ( const Glib::RefPtr< Gdk::Screen >&  screen,
const Glib::RefPtr< StyleProvider >&  provider,
guint  priority 
) [static]
void Gtk::StyleContext::add_region ( const Glib::ustring region_name,
RegionFlags  flags 
)
void Gtk::StyleContext::context_restore (  )
void Gtk::StyleContext::context_save (  )
static Glib::RefPtr<StyleContext> Gtk::StyleContext::create (  ) [static]
Gdk::RGBA Gtk::StyleContext::get_background_color ( StateFlags  state = (StateFlags) 0 ) const
Border Gtk::StyleContext::get_border ( StateFlags  state = (StateFlags) 0 ) const
Gdk::RGBA Gtk::StyleContext::get_border_color ( StateFlags  state = (StateFlags) 0 ) const
Gdk::RGBA Gtk::StyleContext::get_color ( StateFlags  state = (StateFlags) 0 ) const
TextDirection Gtk::StyleContext::get_direction (  ) const
JunctionSides Gtk::StyleContext::get_junction_sides (  ) const
Border Gtk::StyleContext::get_margin ( StateFlags  state = (StateFlags) 0 ) const
Border Gtk::StyleContext::get_padding ( StateFlags  state = (StateFlags) 0 ) const
WidgetPath Gtk::StyleContext::get_path (  ) const
Glib::RefPtr<Gdk::Screen> Gtk::StyleContext::get_screen (  )
Glib::RefPtr<const Gdk::Screen> Gtk::StyleContext::get_screen (  ) const
StateFlags Gtk::StyleContext::get_state (  ) const
const GtkStyleContext* Gtk::StyleContext::gobj (  ) const [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkStyleContext* Gtk::StyleContext::gobj (  ) [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

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 )
bool Gtk::StyleContext::has_region ( const Glib::ustring region_name,
RegionFlags flags_return 
)
void Gtk::StyleContext::invalidate (  )
GList* Gtk::StyleContext::list_regions (  )
bool Gtk::StyleContext::lookup_color ( const Glib::ustring color_name,
Gdk::RGBA color 
)
Glib::RefPtr<IconSet> Gtk::StyleContext::lookup_icon_set ( const Glib::ustring stock_id )
void Gtk::StyleContext::notify_state_change ( const Glib::RefPtr< Gdk::Window >&  window,
gpointer  region_id,
StateType  state,
bool  state_value 
)
virtual void Gtk::StyleContext::on_changed (  ) [protected, virtual]
void Gtk::StyleContext::pop_animatable_region (  )
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 property of the value, 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 that allows you to get or set the property of the value, 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 that allows you to get or set the property of the value, 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 property of the value, or receive notification when the value of the property changes.
void Gtk::StyleContext::push_animatable_region ( gpointer  region_id )
void Gtk::StyleContext::remove_class ( const Glib::ustring class_name )
void Gtk::StyleContext::remove_provider ( const Glib::RefPtr< StyleProvider >&  provider )
static void Gtk::StyleContext::remove_provider_for_screen ( const Glib::RefPtr< Gdk::Screen >&  screen,
const Glib::RefPtr< StyleProvider >&  provider 
) [static]
void Gtk::StyleContext::remove_region ( const Glib::ustring region_name )
void Gtk::StyleContext::render_activity ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
void Gtk::StyleContext::render_arrow ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  angle,
double  x,
double  y,
double  size 
)
void Gtk::StyleContext::render_background ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
void Gtk::StyleContext::render_check ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
void Gtk::StyleContext::render_expander ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
void Gtk::StyleContext::render_extension ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height,
PositionType  gap_side 
)
void Gtk::StyleContext::render_focus ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
void Gtk::StyleContext::render_frame ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  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 
)
void Gtk::StyleContext::render_handle ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
Glib::RefPtr<Gdk::Pixbuf> Gtk::StyleContext::render_icon_pixbuf ( const IconSource source,
IconSize  size 
)
void Gtk::StyleContext::render_layout ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
PangoLayout *  layout 
)
void Gtk::StyleContext::render_line ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x0,
double  y0,
double  x1,
double  y1 
)
void Gtk::StyleContext::render_option ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height 
)
void Gtk::StyleContext::render_slider ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  x,
double  y,
double  width,
double  height,
Orientation  orientation 
)
void Gtk::StyleContext::set_background ( const Glib::RefPtr< Gdk::Window >&  window )
void Gtk::StyleContext::set_direction ( TextDirection  direction )
void Gtk::StyleContext::set_junction_sides ( JunctionSides  sides )
void Gtk::StyleContext::set_path ( const WidgetPath path )
void Gtk::StyleContext::set_screen ( const Glib::RefPtr< Gdk::Screen >&  screen )
void Gtk::StyleContext::set_state ( StateFlags  flags )
Glib::SignalProxy0< void > Gtk::StyleContext::signal_changed (  )
Prototype:
void on_my_changed()
bool Gtk::StyleContext::state_is_running ( StateType  state,
gdouble *  progress 
)

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:
objectThe C instance.
take_copyFalse 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.

The documentation for this class was generated from the following file: