~ubuntu-branches/ubuntu/precise/gtkmm3.0/precise

« back to all changes in this revision

Viewing changes to gtk/src/tooltip.hg

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-17 00:12:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110617001244-9hl5an15hiaaahi6
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

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