Main Page Widgets Namespaces Book

# Gtk::Tooltip Class Reference

Inheritance diagram for Gtk::Tooltip:

[legend]

List of all members.

## Detailed Description

Add tips to your widgets.

Gtk::Tooltip belongs to the new tooltips API that was introduced in GTK+ 2.12 and which deprecates the old Gtk::Tooltips API.

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 stock 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.

In the probably rare case where you want to have even more control over the tooltip that is about to be shown, you can set your own Window which will be used as tooltip window. This works as follows:

- Do Gtk::Widget::set_has_tooltip() and connect to Gtk::Widget::signal_query_tooltip() as before.

- Use Gtk::Widget::set_tooltip_window() to set a Gtk::Window created by you as tooltip window.

- In the query-tooltip callback you can access your window using Gtk::Widget::get_tooltip_window() and manipulate it as you wish. The semantics of the return value are exactly as before, return true to show the window, false to not show it.

Since gtkmm 2.12:

## Public Member Functions
const GtkTooltip* | gobj () const
| Provides access to the underlying C GObject.
GtkTooltip* | gobj ()
| Provides access to the underlying C GObject.
GtkTooltip* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | set_custom (Widget& custom_widget)
| Replaces the widget packed into the tooltip with custom_widget.
void | set_icon (const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
| Sets the icon of the tooltip (which is in front of the text) to be pixbuf.
void | set_icon_from_icon_name (const Glib::ustring& icon_name, IconSize size)
| 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.
void | set_icon_from_stock (const StockID& stock_id, IconSize size)
| Sets the icon of the tooltip (which is in front of the text) to be the stock item indicated by stock_id with the size indicated by size.
void | set_markup (const Glib::ustring& markup)
| Sets the text of the tooltip to be markup, which is marked up with the Pango text markup language.
void | set_text (const Glib::ustring& markup)
| Sets the text of the tooltip to be text.
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).
virtual | ~Tooltip ()
## Static Public Member Functions
static void | trigger_tooltip_query (const Glib::RefPtr<Gdk::Display>& display)
## 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.

## Constructor & Destructor Documentation

virtual Gtk::Tooltip::~Tooltip | ( |  | ) | `[virtual]`

## Member Function Documentation

const GtkTooltip* Gtk::Tooltip::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

GtkTooltip* Gtk::Tooltip::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

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.

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

Replaces the widget packed into the tooltip with custom_widget.

By default a box with a Gtk::Image and Gtk::Label is embedded in the tooltip, which can be configured using gtk_tooltip_set_markup() and gtk_tooltip_set_icon().

Since gtkmm 2.12:

Parameters:

  | custom_widget | A Gtk::Widget.

void Gtk::Tooltip::set_icon | ( | const Glib::RefPtr<Gdk::Pixbuf>& | pixbuf | ) |

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

If pixbuf is `0`, the image will be hidden.

Since gtkmm 2.12:

Parameters:

  | pixbuf | A Gdk::Pixbuf, or `0`.

void Gtk::Tooltip::set_icon_from_icon_name | ( | const Glib::ustring & | icon_name,
|  | IconSize | size |
| ) |  |  |

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 `0`, the image will be hidden.

Since gtkmm 2.14:

Parameters:

  | icon_name | An icon name, or `0`.
  | size | A stock icon size.

void Gtk::Tooltip::set_icon_from_stock | ( | const StockID& | stock_id,
|  | IconSize | size |
| ) |  |  |

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

If stock_id is `0`, the image will be hidden.

Since gtkmm 2.12:

Parameters:

  | stock_id | A stock id, or `0`.
  | size | A stock icon size.

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

Sets the text of the tooltip to be markup, which is marked up with the Pango text markup language.

If markup is `0`, the label will be hidden.

Since gtkmm 2.12:

Parameters:

  | markup | A markup string (see Pango markup format) or `0`.

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

Sets the text of the tooltip to be text.

If text is `0`, the label will be hidden. See also gtk_tooltip_set_markup().

Since gtkmm 2.12:

Parameters:

  | text | A text string or `0`.

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().

Since gtkmm 2.12:

Parameters:

  | rect | A Gdk::Rectangle.

static void Gtk::Tooltip::trigger_tooltip_query | ( | const Glib::RefPtr<Gdk::Display>& | display | ) | `[static]`

## Friends And Related Function Documentation

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.

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

- tooltip.h