1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Tooltip;
26 
27 private import gdk.PaintableIF;
28 private import gio.IconIF;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkTooltip` is an object representing a widget tooltip.
38  * 
39  * Basic tooltips can be realized simply by using
40  * [method@Gtk.Widget.set_tooltip_text] or
41  * [method@Gtk.Widget.set_tooltip_markup] without
42  * any explicit tooltip object.
43  * 
44  * When you need a tooltip with a little more fancy contents,
45  * like adding an image, or you want the tooltip to have different
46  * contents per `GtkTreeView` row or cell, you will have to do a
47  * little more work:
48  * 
49  * - Set the [property@Gtk.Widget:has-tooltip] property to %TRUE.
50  * This will make GTK monitor the widget for motion and related events
51  * which are needed to determine when and where to show a tooltip.
52  * 
53  * - Connect to the [signal@Gtk.Widget::query-tooltip] signal.
54  * This signal will be emitted when a tooltip is supposed to be shown.
55  * One of the arguments passed to the signal handler is a `GtkTooltip`
56  * object. This is the object that we are about to display as a tooltip,
57  * and can be manipulated in your callback using functions like
58  * [method@Gtk.Tooltip.set_icon]. There are functions for setting
59  * the tooltip’s markup, setting an image from a named icon, or even
60  * putting in a custom widget.
61  * 
62  * - Return %TRUE from your ::query-tooltip handler. This causes the tooltip
63  * to be show. If you return %FALSE, it will not be shown.
64  */
65 public class Tooltip : ObjectG
66 {
67 	/** the main Gtk struct */
68 	protected GtkTooltip* gtkTooltip;
69 
70 	/** Get the main Gtk struct */
71 	public GtkTooltip* getTooltipStruct(bool transferOwnership = false)
72 	{
73 		if (transferOwnership)
74 			ownedRef = false;
75 		return gtkTooltip;
76 	}
77 
78 	/** the main Gtk struct as a void* */
79 	protected override void* getStruct()
80 	{
81 		return cast(void*)gtkTooltip;
82 	}
83 
84 	/**
85 	 * Sets our main struct and passes it to the parent class.
86 	 */
87 	public this (GtkTooltip* gtkTooltip, bool ownedRef = false)
88 	{
89 		this.gtkTooltip = gtkTooltip;
90 		super(cast(GObject*)gtkTooltip, ownedRef);
91 	}
92 
93 
94 	/** */
95 	public static GType getType()
96 	{
97 		return gtk_tooltip_get_type();
98 	}
99 
100 	/**
101 	 * Replaces the widget packed into the tooltip with
102 	 * @custom_widget. @custom_widget does not get destroyed when the tooltip goes
103 	 * away.
104 	 * By default a box with a #GtkImage and #GtkLabel is embedded in
105 	 * the tooltip, which can be configured using gtk_tooltip_set_markup()
106 	 * and gtk_tooltip_set_icon().
107 	 *
108 	 * Params:
109 	 *     customWidget = a #GtkWidget, or %NULL to unset the old custom widget.
110 	 */
111 	public void setCustom(Widget customWidget)
112 	{
113 		gtk_tooltip_set_custom(gtkTooltip, (customWidget is null) ? null : customWidget.getWidgetStruct());
114 	}
115 
116 	/**
117 	 * Sets the icon of the tooltip (which is in front of the text) to be
118 	 * @paintable.  If @paintable is %NULL, the image will be hidden.
119 	 *
120 	 * Params:
121 	 *     paintable = a #GdkPaintable, or %NULL
122 	 */
123 	public void setIcon(PaintableIF paintable)
124 	{
125 		gtk_tooltip_set_icon(gtkTooltip, (paintable is null) ? null : paintable.getPaintableStruct());
126 	}
127 
128 	/**
129 	 * Sets the icon of the tooltip (which is in front of the text)
130 	 * to be the icon indicated by @gicon with the size indicated
131 	 * by @size. If @gicon is %NULL, the image will be hidden.
132 	 *
133 	 * Params:
134 	 *     gicon = a #GIcon representing the icon, or %NULL
135 	 */
136 	public void setIconFromGicon(IconIF gicon)
137 	{
138 		gtk_tooltip_set_icon_from_gicon(gtkTooltip, (gicon is null) ? null : gicon.getIconStruct());
139 	}
140 
141 	/**
142 	 * Sets the icon of the tooltip (which is in front of the text) to be
143 	 * the icon indicated by @icon_name with the size indicated
144 	 * by @size.  If @icon_name is %NULL, the image will be hidden.
145 	 *
146 	 * Params:
147 	 *     iconName = an icon name, or %NULL
148 	 */
149 	public void setIconFromIconName(string iconName)
150 	{
151 		gtk_tooltip_set_icon_from_icon_name(gtkTooltip, Str.toStringz(iconName));
152 	}
153 
154 	/**
155 	 * Sets the text of the tooltip to be @markup.
156 	 *
157 	 * The string must be marked up with Pango markup.
158 	 * If @markup is %NULL, the label will be hidden.
159 	 *
160 	 * Params:
161 	 *     markup = a string with Pango markup or %NLL
162 	 */
163 	public void setMarkup(string markup)
164 	{
165 		gtk_tooltip_set_markup(gtkTooltip, Str.toStringz(markup));
166 	}
167 
168 	/**
169 	 * Sets the text of the tooltip to be @text.
170 	 *
171 	 * If @text is %NULL, the label will be hidden.
172 	 * See also [method@Gtk.Tooltip.set_markup].
173 	 *
174 	 * Params:
175 	 *     text = a text string or %NULL
176 	 */
177 	public void setText(string text)
178 	{
179 		gtk_tooltip_set_text(gtkTooltip, Str.toStringz(text));
180 	}
181 
182 	/**
183 	 * Sets the area of the widget, where the contents of this tooltip apply,
184 	 * to be @rect (in widget coordinates).  This is especially useful for
185 	 * properly setting tooltips on #GtkTreeView rows and cells, #GtkIconViews,
186 	 * etc.
187 	 *
188 	 * For setting tooltips on #GtkTreeView, please refer to the convenience
189 	 * functions for this: gtk_tree_view_set_tooltip_row() and
190 	 * gtk_tree_view_set_tooltip_cell().
191 	 *
192 	 * Params:
193 	 *     rect = a #GdkRectangle
194 	 */
195 	public void setTipArea(GdkRectangle* rect)
196 	{
197 		gtk_tooltip_set_tip_area(gtkTooltip, rect);
198 	}
199 }