| 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, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <glibmm/object.h> |
| 18 |
#include <giomm/icon.h> |
| 19 |
#include <gdkmm/pixbuf.h> |
| 20 |
#include <gtkmm/enums.h> |
| 21 |
#include <gtkmm/widget.h> |
| 22 |
|
| 23 |
_DEFS(gtkmm,gtk) |
| 24 |
_PINCLUDE(glibmm/private/object_p.h) |
| 25 |
|
| 26 |
namespace Gtk |
| 27 |
{ |
| 28 |
|
| 29 |
/** Add tips to your widgets |
| 30 |
* |
| 31 |
* Basic tooltips can be realized simply by using set_tooltip_text() |
| 32 |
* or set_tooltip_markup() without any explicit tooltip object. |
| 33 |
* |
| 34 |
* When you need a tooltip with a little more fancy contents, like |
| 35 |
* adding an image, or you want the tooltip to have different contents |
| 36 |
* per Gtk::TreeView row or cell, you will have to do a little more work: |
| 37 |
* |
| 38 |
* - Call Gtk::Widget:set_has_tooltip(); this will |
| 39 |
* make GTK+ monitor the widget for motion and related events |
| 40 |
* which are needed to determine when and where to show a tooltip. |
| 41 |
* |
| 42 |
* - Connect to Gtk::Widget::signal_query_tooltip(). This signal |
| 43 |
* will be emitted when a tooltip is supposed to be shown. One |
| 44 |
* of the arguments passed to the signal handler is a Gtk::Tooltip |
| 45 |
* object. This is the object that we are about to display as a |
| 46 |
* tooltip, and can be manipulated in your callback using functions |
| 47 |
* like Gtk::Tooltip::set_icon(). There are functions for setting |
| 48 |
* the tooltip's markup, setting an image from a stock icon, or |
| 49 |
* even putting in a custom widget. |
| 50 |
* |
| 51 |
* - Return true from your query-tooltip handler. This causes |
| 52 |
* the tooltip to be show. If you return false, it will not be shown. |
| 53 |
* |
| 54 |
* In the probably rare case where you want to have even more control |
| 55 |
* over the tooltip that is about to be shown, you can set your own |
| 56 |
* Window which will be used as tooltip window. This works as follows: |
| 57 |
* |
| 58 |
* - Do Gtk::Widget::set_has_tooltip() and connect to |
| 59 |
* Gtk::Widget::signal_query_tooltip() as before. |
| 60 |
* |
| 61 |
* - Use Gtk::Widget::set_tooltip_window() to set a Gtk::Window created |
| 62 |
* by you as tooltip window. |
| 63 |
* |
| 64 |
* - In the query-tooltip callback you can access your window |
| 65 |
* using Gtk::Widget::get_tooltip_window() and manipulate it as you |
| 66 |
* wish. The semantics of the return value are exactly as before, |
| 67 |
* return true to show the window, false to not show it. |
| 68 |
* |
| 69 |
* @newin{2,12} |
| 70 |
*/ |
| 71 |
class GTKMM_API Tooltip : public Glib::Object |
| 72 |
{ |
| 73 |
protected: |
| 74 |
_CLASS_GOBJECT(Tooltip, GtkTooltip, GTK_TOOLTIP, Glib::Object, GObject, , , GTKMM_API) |
| 75 |
|
| 76 |
public: |
| 77 |
_WRAP_METHOD(void set_markup(const Glib::ustring& markup), gtk_tooltip_set_markup) |
| 78 |
|
| 79 |
/** Hide the label. |
| 80 |
* @newin{3,2} |
| 81 |
*/ |
| 82 |
void unset_markup(); |
| 83 |
|
| 84 |
_WRAP_METHOD(void set_text(const Glib::ustring& text), gtk_tooltip_set_text) |
| 85 |
|
| 86 |
/** Hide the label. |
| 87 |
* @newin{3,2} |
| 88 |
*/ |
| 89 |
void unset_text(); |
| 90 |
|
| 91 |
_WRAP_METHOD(void set_icon(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_tooltip_set_icon) |
| 92 |
_WRAP_METHOD(void set_icon(const Glib::RefPtr<Gio::Icon>& gicon, IconSize size), gtk_tooltip_set_icon_from_gicon) |
| 93 |
|
| 94 |
//TODO: Remove the _from_*() suffixes? |
| 95 |
_WRAP_METHOD(void set_icon_from_stock(const StockID& stock_id, IconSize size), gtk_tooltip_set_icon_from_stock, deprecated "Use set_icon_from_icon_name() instead.") |
| 96 |
_WRAP_METHOD(void set_icon_from_icon_name(const Glib::ustring& icon_name, IconSize size), gtk_tooltip_set_icon_from_icon_name) |
| 97 |
|
| 98 |
/** Hide the image. |
| 99 |
* @newin{3,2} |
| 100 |
*/ |
| 101 |
void unset_icon(); |
| 102 |
|
| 103 |
_WRAP_METHOD(void set_custom(Widget& custom_widget), gtk_tooltip_set_custom) |
| 104 |
|
| 105 |
/** Remove the custom widget. |
| 106 |
* @newin{3,2} |
| 107 |
*/ |
| 108 |
void unset_custom(); |
| 109 |
|
| 110 |
_WRAP_METHOD(void set_tip_area(const Gdk::Rectangle& rect), gtk_tooltip_set_tip_area) |
| 111 |
|
| 112 |
_IGNORE(gtk_tooltip_trigger_tooltip_query) |
| 113 |
static void trigger_tooltip_query(const Glib::RefPtr<Gdk::Display>& display); |
| 114 |
}; |
| 115 |
|
| 116 |
} // namespace Gtk |