1/* Copyright (C) 2007 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free
15 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#include <glibmm/object.h>
19#include <giomm/icon.h>
20#include <gdkmm/pixbuf.h>
21#include <gtkmm/enums.h>
22#include <gtkmm/widget.h>
23
24_DEFS(gtkmm,gtk)
25_PINCLUDE(glibmm/private/object_p.h)
26
27namespace Gtk
28{
29
30/** Add tips to your widgets
31 *
32 * Gtk::Tooltip belongs to the new tooltips API that was introduced in GTK+ 2.12
33 * and which deprecates the old Gtk::Tooltips API.
34 *
35 * Basic tooltips can be realized simply by using set_tooltip_text()
36 * or set_tooltip_markup() without any explicit tooltip object.
37 *
38 * When you need a tooltip with a little more fancy contents, like
39 * adding an image, or you want the tooltip to have different contents
40 * per Gtk::TreeView row or cell, you will have to do a little more work:
41 *
42 * - Call Gtk::Widget:set_has_tooltip(); this will
43 * make GTK+ monitor the widget for motion and related events
44 * which are needed to determine when and where to show a tooltip.
45 *
46 * - Connect to Gtk::Widget::signal_query_tooltip(). This signal
47 * will be emitted when a tooltip is supposed to be shown. One
48 * of the arguments passed to the signal handler is a Gtk::Tooltip
49 * object. This is the object that we are about to display as a
50 * tooltip, and can be manipulated in your callback using functions
51 * like Gtk::Tooltip::set_icon(). There are functions for setting
52 * the tooltip's markup, setting an image from a stock icon, or
53 * even putting in a custom widget.
54 *
55 * - Return true from your query-tooltip handler. This causes
56 * the tooltip to be show. If you return false, it will not be shown.
57 *
58 * In the probably rare case where you want to have even more control
59 * over the tooltip that is about to be shown, you can set your own
60 * Window which will be used as tooltip window. This works as follows:
61 *
62 * - Do Gtk::Widget::set_has_tooltip() and connect to
63 * Gtk::Widget::signal_query_tooltip() as before.
64 *
65 * - Use Gtk::Widget::set_tooltip_window() to set a Gtk::Window created
66 * by you as tooltip window.
67 *
68 * - In the query-tooltip callback you can access your window
69 * using Gtk::Widget::get_tooltip_window() and manipulate it as you
70 * wish. The semantics of the return value are exactly as before,
71 * return true to show the window, false to not show it.
72 *
73 * @newin{2,12}
74 */
75class Tooltip : public Glib::Object
76{
77protected:
78  _CLASS_GOBJECT(Tooltip, GtkTooltip, GTK_TOOLTIP, Glib::Object, GObject)
79
80public:
81  _WRAP_METHOD(void set_markup(const Glib::ustring& markup), gtk_tooltip_set_markup)
82  _WRAP_METHOD(void set_text(const Glib::ustring& markup), gtk_tooltip_set_text)
83  _WRAP_METHOD(void set_icon(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_tooltip_set_icon)
84  _WRAP_METHOD(void set_icon(const Glib::RefPtr<Gio::Icon>& icon, IconSize size), gtk_tooltip_set_icon_from_gicon)
85
86  //TODO: Remove the _from_*() suffixes?
87  _WRAP_METHOD(void set_icon_from_stock(const StockID& stock_id, IconSize size), gtk_tooltip_set_icon_from_stock)
88  _WRAP_METHOD(void set_icon_from_icon_name(const Glib::ustring& icon_name, IconSize size), gtk_tooltip_set_icon_from_icon_name)
89
90
91  _WRAP_METHOD(void set_custom(Widget& custom_widget), gtk_tooltip_set_custom)
92  _WRAP_METHOD(void set_tip_area(const Gdk::Rectangle& rect), gtk_tooltip_set_tip_area)
93
94  _IGNORE(gtk_tooltip_trigger_tooltip_query)
95  static void trigger_tooltip_query(const Glib::RefPtr<Gdk::Display>& display);
96};
97
98} // namespace Gtk
99