gtkmm 4.10.0

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

Add tips to your widgets. More...

`#include <gtkmm/tooltip.h>`

Inheritance diagram for Gtk::Tooltip:
[legend]

## Public Member Functions
| Tooltip (Tooltip && src) noexcept
Tooltip & | operator= (Tooltip && src) noexcept
| ~Tooltip () noexcept override
GtkTooltip * | gobj ()
| Provides access to the underlying C GObject. More...
const GtkTooltip * | gobj () const
| Provides access to the underlying C GObject. More...
GtkTooltip * | 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 | set_markup (const Glib::ustring & markup)
| Sets the text of the tooltip to be markup. More...
void | unset_markup ()
| Hide the label. More...
void | set_text (const Glib::ustring & text)
| Sets the text of the tooltip to be text. More...
void | unset_text ()
| Hide the label. More...
void | set_icon (const Glib::RefPtr< Gdk::Paintable > & paintable)
| Sets the icon of the tooltip (which is in front of the text) to be paintable. More...
void | set_icon (const Glib::RefPtr< Gio::Icon > & gicon)
| Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by gicon with the size indicated by size. More...
void | set_icon (const Glib::ustring & icon_name)
| Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by icon_name with the size indicated by size. More...
void | unset_icon ()
| Hide the image. More...
void | set_custom (Widget & custom_widget)
| Replaces the widget packed into the tooltip with custom_widget. More...
void | unset_custom ()
| Remove the custom widget. More...
void | set_tip_area (const Gdk::Rectangle & rect)
| Sets the area of the widget, where the contents of this tooltip apply, to be rect (in widget coordinates). More...
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
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
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
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
PropertyType | get_property (const Glib::ustring &property_name) const
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
sigc::connection | connect_property_changed (const Glib::ustring &property_name, 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
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src) noexcept
| ~trackable ()
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src) noexcept
void | remove_destroy_notify_callback (notifiable *data) const

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

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

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(*)(gpointer data | DestroyNotify)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify | func_destroy_notify
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Detailed Description

Add tips to your widgets.

Basic tooltips can be realized simply by using set_tooltip_text() or set_tooltip_markup() without any explicit tooltip object.

When you need a tooltip with a little more fancy contents, like adding an image, or you want the tooltip to have different contents per Gtk::TreeView row or cell, you will have to do a little more work:

- Call Gtk::Widget:set_has_tooltip(); this will make GTK+ monitor the widget for motion and related events which are needed to determine when and where to show a tooltip.
- Connect to Gtk::Widget::signal_query_tooltip(). This signal will be emitted when a tooltip is supposed to be shown. One of the arguments passed to the signal handler is a Gtk::Tooltip object. This is the object that we are about to display as a tooltip, and can be manipulated in your callback using functions like Gtk::Tooltip::set_icon(). There are functions for setting the tooltip's markup, setting an image from a named icon, or even putting in a custom widget.

- Return true from your query-tooltip handler. This causes the tooltip to be show. If you return false, it will not be shown.

  Since gtkmm 2.12:

## Constructor & Destructor Documentation

## ◆ Tooltip()

Gtk::Tooltip::Tooltip | ( | Tooltip && | src | ) |
| noexcept

## ◆ ~Tooltip()

Gtk::Tooltip::~Tooltip | ( |  | ) |
| override noexcept

## Member Function Documentation

## ◆ get_type()

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

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

## ◆ gobj() [1/2]

GtkTooltip* Gtk::Tooltip::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkTooltip* Gtk::Tooltip::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkTooltip* Gtk::Tooltip::gobj_copy | ( |  | ) |

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

## ◆ operator=()

Tooltip& Gtk::Tooltip::operator= | ( | Tooltip && | src | ) |
| noexcept

## ◆ set_custom()

void Gtk::Tooltip::set_custom | ( | Widget & | custom_widget | ) |

Replaces the widget packed into the tooltip with custom_widget.

custom_widget does not get destroyed when the tooltip goes away. By default a box with a `Gtk::Image` and `Gtk::Label` is embedded in the tooltip, which can be configured using set_markup() and set_icon().

Parameters

  custom_widget | A `Gtk::Widget`, or `nullptr` to unset the old custom widget.

## ◆ set_icon() [1/3]

void Gtk::Tooltip::set_icon | ( | const Glib::RefPtr< Gdk::Paintable > & | paintable | ) |

Sets the icon of the tooltip (which is in front of the text) to be paintable.

If paintable is `nullptr`, the image will be hidden.

Parameters

  paintable | A `Gdk::Paintable`.

## ◆ set_icon() [2/3]

void Gtk::Tooltip::set_icon | ( | const Glib::RefPtr< Gio::Icon > & | gicon | ) |

Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by gicon with the size indicated by size.

If gicon is `nullptr`, the image will be hidden.

Parameters

  gicon | A `Gio::Icon` representing the icon.

## ◆ set_icon() [3/3]

void Gtk::Tooltip::set_icon | ( | const Glib::ustring & | icon_name | ) |

Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by icon_name with the size indicated by size.

If icon_name is `nullptr`, the image will be hidden.

Parameters

  icon_name | An icon name.

## ◆ set_markup()

void Gtk::Tooltip::set_markup | ( | const Glib::ustring & | markup | ) |

Sets the text of the tooltip to be markup.

The string must be marked up with Pango markup. If markup is `nullptr`, the label will be hidden.

Parameters

  markup | A string with Pango markup or N::LL.

## ◆ set_text()

void Gtk::Tooltip::set_text | ( | const Glib::ustring & | text | ) |

Sets the text of the tooltip to be text.

If text is `nullptr`, the label will be hidden. See also set_markup().

Parameters

  text | A text string.

## ◆ set_tip_area()

void Gtk::Tooltip::set_tip_area | ( | const Gdk::Rectangle & | rect | ) |

Sets the area of the widget, where the contents of this tooltip apply, to be rect (in widget coordinates).

This is especially useful for properly setting tooltips on `Gtk::TreeView` rows and cells, `Gtk::IconViews`, etc.

For setting tooltips on `Gtk::TreeView`, please refer to the convenience functions for this: Gtk::TreeView::set_tooltip_row() and Gtk::TreeView::set_tooltip_cell().

Parameters

  rect | A `Gdk::Rectangle`.

## ◆ unset_custom()

void Gtk::Tooltip::unset_custom | ( |  | ) |

Remove the custom widget.

Since gtkmm 3.2:

## ◆ unset_icon()

void Gtk::Tooltip::unset_icon | ( |  | ) |

Hide the image.

Since gtkmm 3.2:

## ◆ unset_markup()

void Gtk::Tooltip::unset_markup | ( |  | ) |

Hide the label.

Since gtkmm 3.2:

## ◆ unset_text()

void Gtk::Tooltip::unset_text | ( |  | ) |

Hide the label.

Since gtkmm 3.2:

## Friends And Related Function Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::Tooltip > wrap | ( | GtkTooltip * | 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.