gtkmm 3.24.7
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>

Inherits Glib::Object.

Public Member Functions

 Tooltip (Tooltip && src) noexcept
 
Tooltipoperator= (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, which is marked up with the [Pango text markup language][PangoMarkupFormat]. 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::Pixbuf > & pixbuf)
 Sets the icon of the tooltip (which is in front of the text) to be pixbuf. More...
 
void set_icon (const Glib::RefPtr< Gio::Icon > & gicon, IconSize size)
 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_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. More...
 
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. 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...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static void trigger_tooltip_query (const Glib::RefPtr< Gdk::Display > & display)
 

Related Functions

(Note that these are not member functions.)

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

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:

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:

Constructor & Destructor Documentation

◆ Tooltip()

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

◆ ~Tooltip()

Gtk::Tooltip::~Tooltip ( )
overridenoexcept

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

Since gtkmm 2.12:
Parameters
custom_widgetA Gtk::Widget, or nullptr to unset the old custom widget.

◆ set_icon() [1/2]

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

Since gtkmm 2.12:
Parameters
pixbufA Gdk::Pixbuf, or nullptr.

◆ set_icon() [2/2]

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

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.

Since gtkmm 2.20:
Parameters
giconA Gio::Icon representing the icon, or nullptr.
sizeA stock icon size (Gtk::IconSize).

◆ set_icon_from_icon_name()

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

Since gtkmm 2.14:
Parameters
icon_nameAn icon name, or nullptr.
sizeA stock icon size (Gtk::IconSize).

◆ set_icon_from_stock()

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

Since gtkmm 2.12:

Deprecated: 3.10: Use set_icon_from_icon_name() instead.

Deprecated:
Use set_icon_from_icon_name() instead.
Parameters
stock_idA stock id, or nullptr.
sizeA stock icon size (Gtk::IconSize).

◆ set_markup()

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][PangoMarkupFormat].

If markup is nullptr, the label will be hidden.

Since gtkmm 2.12:
Parameters
markupA markup string (see [Pango markup format][PangoMarkupFormat]) or nullptr.

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

Since gtkmm 2.12:
Parameters
textA text string or nullptr.

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

Since gtkmm 2.12:
Parameters
rectA Gdk::Rectangle.

◆ trigger_tooltip_query()

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

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