gtkmm 3.24.7
Public Member Functions | Static Public Member Functions | Protected Attributes | Related Functions | List of all members
Gtk::WidgetPath Class Reference

This represents a widget hierarchy from the topmost widget, typically a toplevel, to any child. More...

#include <gtkmm/widgetpath.h>

Public Member Functions

 WidgetPath ()
 
 WidgetPath (GtkWidgetPath * gobject, bool make_a_copy=true)
 
 WidgetPath (const WidgetPath & other)
 
WidgetPathoperator= (const WidgetPath & other)
 
 WidgetPath (WidgetPath && other) noexcept
 
WidgetPathoperator= (WidgetPath && other) noexcept
 
 ~WidgetPath () noexcept
 
void swap (WidgetPath & other) noexcept
 
GtkWidgetPath * gobj ()
 Provides access to the underlying C instance. More...
 
const GtkWidgetPath * gobj () const
 Provides access to the underlying C instance. More...
 
GtkWidgetPath * gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More...
 
Glib::ustring to_string () const
 Dumps the widget path into a string representation. More...
 
int path_length () const
 Returns the number of Gtk::Widget Types between the represented widget and its topmost container. More...
 
int path_append_type (GType type)
 Appends a widget type to the widget hierarchy represented by path. More...
 
void prepend_type (GType type)
 Prepends a widget type to the widget hierachy represented by path. More...
 
GType iter_get_object_type (int pos) const
 Returns the object GType that is at position pos in the widget hierarchy defined in path. More...
 
void iter_set_object_type (int pos, GType type)
 Sets the object type for a given position in the widget hierarchy defined by path. More...
 
Glib::ustring iter_get_name (int pos) const
 Returns the name corresponding to the widget found at the position pos in the widget hierarchy defined by path. More...
 
void iter_set_name (int pos, const Glib::ustring & name)
 Sets the widget name for the widget found at position pos in the widget hierarchy defined by path. More...
 
bool iter_has_name (int pos, const Glib::ustring & name) const
 Returns true if the widget at position pos has the name name, false otherwise. More...
 
WidgetPath iter_get_siblings (int pos=-1) const
 Returns the list of siblings for the element at pos. More...
 
guint get_sibling_index (int pos=-1)
 Returns the index into the list of siblings for the element at pos as returned by iter_get_siblings(). More...
 
void iter_add_class (int pos, const Glib::ustring & name)
 Adds the class name to the widget at position pos in the hierarchy defined in path. More...
 
void iter_remove_class (int pos, const Glib::ustring & name)
 Removes the class name from the widget at position pos in the hierarchy defined in path. More...
 
void iter_clear_classes (int pos=-1)
 Removes all classes from the widget at position pos in the hierarchy defined in path. More...
 
std::vector< Glib::ustring > iter_list_classes (int pos=-1) const
 Returns a list with all the class names defined for the widget at position pos in the hierarchy defined in path. More...
 
bool iter_has_class (int pos, const Glib::ustring & name) const
 Returns true if the widget at position pos has the class name defined, false otherwise. More...
 
void iter_add_region (int pos, const Glib::ustring & name, RegionFlags flags)
 Adds the region name to the widget at position pos in the hierarchy defined in path. More...
 
void iter_remove_region (int pos, const Glib::ustring & name)
 Removes the region name from the widget at position pos in the hierarchy defined in path. More...
 
void iter_clear_regions (int pos=-1)
 Removes all regions from the widget at position pos in the hierarchy defined in path. More...
 
std::vector< Glib::ustring > iter_list_regions (int pos=-1) const
 Returns a list with all the region names defined for the widget at position pos in the hierarchy defined in path. More...
 
bool iter_has_region (int pos, const Glib::ustring & name, RegionFlags & flags) const
 Returns true if the widget at position pos has the class name defined, false otherwise. More...
 
GType get_object_type () const
 Returns the topmost object type, that is, the object type this path is representing. More...
 
bool is_type (GType type) const
 Returns true if the widget type represented by this path is type, or a subtype of it. More...
 
bool has_parent (GType type) const
 Returns true if any of the parents of the widget represented in path is of type type, or any subtype of it. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Protected Attributes

GtkWidgetPath * gobject_
 

Related Functions

(Note that these are not member functions.)

void swap (WidgetPath & lhs, WidgetPath & rhs) noexcept
 
Gtk::WidgetPath wrap (GtkWidgetPath * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

This represents a widget hierarchy from the topmost widget, typically a toplevel, to any child.

This widget path abstraction is used in StyleContext on behalf of the real widget in order to query style information.

If you are using gtkmm widgets, you probably will not need to use this API directly, as there is Widget::get_path(), and the style context returned by Widget::get_style_context() will be automatically updated on widget hierarchy changes.

Since gtkmm 3.0:

Constructor & Destructor Documentation

◆ WidgetPath() [1/4]

Gtk::WidgetPath::WidgetPath ( )

◆ WidgetPath() [2/4]

Gtk::WidgetPath::WidgetPath ( GtkWidgetPath *  gobject,
bool  make_a_copy = true 
)
explicit

◆ WidgetPath() [3/4]

Gtk::WidgetPath::WidgetPath ( const WidgetPath other)

◆ WidgetPath() [4/4]

Gtk::WidgetPath::WidgetPath ( WidgetPath &&  other)
noexcept

◆ ~WidgetPath()

Gtk::WidgetPath::~WidgetPath ( )
noexcept

Member Function Documentation

◆ get_object_type()

GType Gtk::WidgetPath::get_object_type ( ) const

Returns the topmost object type, that is, the object type this path is representing.

Since gtkmm 3.0:
Returns
The object type.

◆ get_sibling_index()

guint Gtk::WidgetPath::get_sibling_index ( int  pos = -1)

Returns the index into the list of siblings for the element at pos as returned by iter_get_siblings().

If that function would return nullptr because the element at pos has no siblings, this function will return 0.

Parameters
posPosition to get the sibling index for, -1 for the path head.
Returns
0 or the index into the list of siblings for the element at pos.

◆ get_type()

static GType Gtk::WidgetPath::get_type ( )
static

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

◆ gobj() [1/2]

GtkWidgetPath * Gtk::WidgetPath::gobj ( )
inline

Provides access to the underlying C instance.

◆ gobj() [2/2]

const GtkWidgetPath * Gtk::WidgetPath::gobj ( ) const
inline

Provides access to the underlying C instance.

◆ gobj_copy()

GtkWidgetPath * Gtk::WidgetPath::gobj_copy ( ) const

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

◆ has_parent()

bool Gtk::WidgetPath::has_parent ( GType  type) const

Returns true if any of the parents of the widget represented in path is of type type, or any subtype of it.

Since gtkmm 3.0:
Parameters
typeWidget type to check in parents.
Returns
true if any parent is of type type.

◆ is_type()

bool Gtk::WidgetPath::is_type ( GType  type) const

Returns true if the widget type represented by this path is type, or a subtype of it.

Since gtkmm 3.0:
Parameters
typeWidget type to match.
Returns
true if the widget represented by path is of type type.

◆ iter_add_class()

void Gtk::WidgetPath::iter_add_class ( int  pos,
const Glib::ustring &  name 
)

Adds the class name to the widget at position pos in the hierarchy defined in path.

See Gtk::StyleContext::add_class().

Since gtkmm 3.0:
Parameters
posPosition to modify, -1 for the path head.
nameA class name.

◆ iter_add_region()

void Gtk::WidgetPath::iter_add_region ( int  pos,
const Glib::ustring &  name,
RegionFlags  flags 
)

Adds the region name to the widget at position pos in the hierarchy defined in path.

See Gtk::StyleContext::add_region().

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

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
The use of regions is deprecated.
Parameters
posPosition to modify, -1 for the path head.
nameRegion name.
flagsFlags affecting the region.

◆ iter_clear_classes()

void Gtk::WidgetPath::iter_clear_classes ( int  pos = -1)

Removes all classes from the widget at position pos in the hierarchy defined in path.

Since gtkmm 3.0:
Parameters
posPosition to modify, -1 for the path head.

◆ iter_clear_regions()

void Gtk::WidgetPath::iter_clear_regions ( int  pos = -1)

Removes all regions from the widget at position pos in the hierarchy defined in path.

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
The use of regions is deprecated.
Parameters
posPosition to modify, -1 for the path head.

◆ iter_get_name()

Glib::ustring Gtk::WidgetPath::iter_get_name ( int  pos) const

Returns the name corresponding to the widget found at the position pos in the widget hierarchy defined by path.

Parameters
posPosition to get the widget name for, -1 for the path head.
Returns
The widget name, or nullptr if none was set.

◆ iter_get_object_type()

GType Gtk::WidgetPath::iter_get_object_type ( int  pos) const

Returns the object GType that is at position pos in the widget hierarchy defined in path.

Since gtkmm 3.0:
Parameters
posPosition to get the object type for, -1 for the path head.
Returns
A widget type.

◆ iter_get_siblings()

WidgetPath Gtk::WidgetPath::iter_get_siblings ( int  pos = -1) const

Returns the list of siblings for the element at pos.

If the element was not added with siblings, nullptr is returned.

Parameters
posPosition to get the siblings for, -1 for the path head.
Returns
nullptr or the list of siblings for the element at pos.

◆ iter_has_class()

bool Gtk::WidgetPath::iter_has_class ( int  pos,
const Glib::ustring &  name 
) const

Returns true if the widget at position pos has the class name defined, false otherwise.

Since gtkmm 3.0:
Parameters
posPosition to query, -1 for the path head.
nameClass name.
Returns
true if the class name is defined for the widget at pos.

◆ iter_has_name()

bool Gtk::WidgetPath::iter_has_name ( int  pos,
const Glib::ustring &  name 
) const

Returns true if the widget at position pos has the name name, false otherwise.

Since gtkmm 3.0:
Parameters
posPosition to query, -1 for the path head.
nameA widget name.
Returns
true if the widget at pos has this name.

◆ iter_has_region()

bool Gtk::WidgetPath::iter_has_region ( int  pos,
const Glib::ustring &  name,
RegionFlags flags 
) const

Returns true if the widget at position pos has the class name defined, false otherwise.

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
The use of regions is deprecated.
Parameters
posPosition to query, -1 for the path head.
nameRegion name.
flagsReturn location for the region flags.
Returns
true if the class name is defined for the widget at pos.

◆ iter_list_classes()

std::vector< Glib::ustring > Gtk::WidgetPath::iter_list_classes ( int  pos = -1) const

Returns a list with all the class names defined for the widget at position pos in the hierarchy defined in path.

Since gtkmm 3.0:
Parameters
posPosition to query, -1 for the path head.
Returns
The list of classes, This is a list of strings, the SList contents are owned by GTK+.

◆ iter_list_regions()

std::vector< Glib::ustring > Gtk::WidgetPath::iter_list_regions ( int  pos = -1) const

Returns a list with all the region names defined for the widget at position pos in the hierarchy defined in path.

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
The use of regions is deprecated.
Parameters
posPosition to query, -1 for the path head.
Returns
The list of regions, This is a list of strings, the SList contents are owned by GTK+.

◆ iter_remove_class()

void Gtk::WidgetPath::iter_remove_class ( int  pos,
const Glib::ustring &  name 
)

Removes the class name from the widget at position pos in the hierarchy defined in path.

Since gtkmm 3.0:
Parameters
posPosition to modify, -1 for the path head.
nameClass name.

◆ iter_remove_region()

void Gtk::WidgetPath::iter_remove_region ( int  pos,
const Glib::ustring &  name 
)

Removes the region name from the widget at position pos in the hierarchy defined in path.

Since gtkmm 3.0:

Deprecated: 3.14: The use of regions is deprecated.

Deprecated:
The use of regions is deprecated.
Parameters
posPosition to modify, -1 for the path head.
nameRegion name.

◆ iter_set_name()

void Gtk::WidgetPath::iter_set_name ( int  pos,
const Glib::ustring &  name 
)

Sets the widget name for the widget found at position pos in the widget hierarchy defined by path.

Since gtkmm 3.0:
Parameters
posPosition to modify, -1 for the path head.
nameWidget name.

◆ iter_set_object_type()

void Gtk::WidgetPath::iter_set_object_type ( int  pos,
GType  type 
)

Sets the object type for a given position in the widget hierarchy defined by path.

Since gtkmm 3.0:
Parameters
posPosition to modify, -1 for the path head.
typeObject type to set.

◆ operator=() [1/2]

WidgetPath & Gtk::WidgetPath::operator= ( const WidgetPath other)

◆ operator=() [2/2]

WidgetPath & Gtk::WidgetPath::operator= ( WidgetPath &&  other)
noexcept

◆ path_append_type()

int Gtk::WidgetPath::path_append_type ( GType  type)

Appends a widget type to the widget hierarchy represented by path.

Since gtkmm 3.0:
Parameters
typeWidget type to append.
Returns
The position where the element was inserted.

◆ path_length()

int Gtk::WidgetPath::path_length ( ) const

Returns the number of Gtk::Widget Types between the represented widget and its topmost container.

Since gtkmm 3.0:
Returns
The number of elements in the path.

◆ prepend_type()

void Gtk::WidgetPath::prepend_type ( GType  type)

Prepends a widget type to the widget hierachy represented by path.

Since gtkmm 3.0:
Parameters
typeWidget type to prepend.

◆ swap()

void Gtk::WidgetPath::swap ( WidgetPath other)
noexcept

◆ to_string()

Glib::ustring Gtk::WidgetPath::to_string ( ) const

Dumps the widget path into a string representation.

It tries to match the CSS style as closely as possible (Note that there might be paths that cannot be represented in CSS).

The main use of this code is for debugging purposes, so that you can Glib::print() the path or dump it in a gdb session.

Since gtkmm 3.2:
Returns
A new string describing path.

Friends And Related Function Documentation

◆ swap()

void swap ( WidgetPath lhs,
WidgetPath rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side

◆ wrap()

Gtk::WidgetPath wrap ( GtkWidgetPath *  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.

Member Data Documentation

◆ gobject_

GtkWidgetPath* Gtk::WidgetPath::gobject_
protected