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.Display;
28 private import gdkpixbuf.Pixbuf;
29 private import gio.IconIF;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 public  import gtkc.gtktypes;
36 
37 
38 /**
39  * Basic tooltips can be realized simply by using gtk_widget_set_tooltip_text()
40  * or gtk_widget_set_tooltip_markup() without any explicit tooltip object.
41  * 
42  * When you need a tooltip with a little more fancy contents, like adding an
43  * image, or you want the tooltip to have different contents per #GtkTreeView
44  * row or cell, you will have to do a little more work:
45  * 
46  * - Set the #GtkWidget:has-tooltip property to %TRUE, this will make GTK+
47  * monitor the widget for motion and related events which are needed to
48  * determine when and where to show a tooltip.
49  * 
50  * - Connect to the #GtkWidget::query-tooltip signal.  This signal will be
51  * emitted when a tooltip is supposed to be shown. One of the arguments passed
52  * to the signal handler is a GtkTooltip object. This is the object that we
53  * are about to display as a tooltip, and can be manipulated in your callback
54  * using functions like gtk_tooltip_set_icon(). There are functions for setting
55  * the tooltip’s markup, setting an image from a named icon, or even putting in
56  * a custom widget.
57  * 
58  * Return %TRUE from your query-tooltip handler. This causes the tooltip to be
59  * show. If you return %FALSE, it will not be shown.
60  * 
61  * In the probably rare case where you want to have even more control over the
62  * tooltip that is about to be shown, you can set your own #GtkWindow which
63  * will be used as tooltip window.  This works as follows:
64  * 
65  * - Set #GtkWidget:has-tooltip and connect to #GtkWidget::query-tooltip as before.
66  * Use gtk_widget_set_tooltip_window() to set a #GtkWindow created by you as
67  * tooltip window.
68  * 
69  * - In the #GtkWidget::query-tooltip callback you can access your window using
70  * gtk_widget_get_tooltip_window() and manipulate as you wish. The semantics of
71  * the return value are exactly as before, return %TRUE to show the window,
72  * %FALSE to not show it.
73  */
74 public class Tooltip : ObjectG
75 {
76 	/** the main Gtk struct */
77 	protected GtkTooltip* gtkTooltip;
78 
79 	/** Get the main Gtk struct */
80 	public GtkTooltip* getTooltipStruct(bool transferOwnership = false)
81 	{
82 		if (transferOwnership)
83 			ownedRef = false;
84 		return gtkTooltip;
85 	}
86 
87 	/** the main Gtk struct as a void* */
88 	protected override void* getStruct()
89 	{
90 		return cast(void*)gtkTooltip;
91 	}
92 
93 	protected override void setStruct(GObject* obj)
94 	{
95 		gtkTooltip = cast(GtkTooltip*)obj;
96 		super.setStruct(obj);
97 	}
98 
99 	/**
100 	 * Sets our main struct and passes it to the parent class.
101 	 */
102 	public this (GtkTooltip* gtkTooltip, bool ownedRef = false)
103 	{
104 		this.gtkTooltip = gtkTooltip;
105 		super(cast(GObject*)gtkTooltip, ownedRef);
106 	}
107 
108 	/**
109 	 * Sets the icon of the tooltip (which is in front of the text) to be
110 	 * the stock item indicated by stockID with the size indicated by size.
111 	 */
112 	void setIcon(StockID stockID, GtkIconSize size)
113 	{
114 		setIconFromStock(cast(string)stockID, size);
115 	}
116 
117 	/**
118 	 */
119 
120 	/** */
121 	public static GType getType()
122 	{
123 		return gtk_tooltip_get_type();
124 	}
125 
126 	/**
127 	 * Triggers a new tooltip query on @display, in order to update the current
128 	 * visible tooltip, or to show/hide the current tooltip.  This function is
129 	 * useful to call when, for example, the state of the widget changed by a
130 	 * key press.
131 	 *
132 	 * Params:
133 	 *     display = a #GdkDisplay
134 	 *
135 	 * Since: 2.12
136 	 */
137 	public static void triggerTooltipQuery(Display display)
138 	{
139 		gtk_tooltip_trigger_tooltip_query((display is null) ? null : display.getDisplayStruct());
140 	}
141 
142 	/**
143 	 * Replaces the widget packed into the tooltip with
144 	 * @custom_widget. @custom_widget does not get destroyed when the tooltip goes
145 	 * away.
146 	 * By default a box with a #GtkImage and #GtkLabel is embedded in
147 	 * the tooltip, which can be configured using gtk_tooltip_set_markup()
148 	 * and gtk_tooltip_set_icon().
149 	 *
150 	 * Params:
151 	 *     customWidget = a #GtkWidget, or %NULL to unset the old custom widget.
152 	 *
153 	 * Since: 2.12
154 	 */
155 	public void setCustom(Widget customWidget)
156 	{
157 		gtk_tooltip_set_custom(gtkTooltip, (customWidget is null) ? null : customWidget.getWidgetStruct());
158 	}
159 
160 	/**
161 	 * Sets the icon of the tooltip (which is in front of the text) to be
162 	 * @pixbuf.  If @pixbuf is %NULL, the image will be hidden.
163 	 *
164 	 * Params:
165 	 *     pixbuf = a #GdkPixbuf, or %NULL
166 	 *
167 	 * Since: 2.12
168 	 */
169 	public void setIcon(Pixbuf pixbuf)
170 	{
171 		gtk_tooltip_set_icon(gtkTooltip, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
172 	}
173 
174 	/**
175 	 * Sets the icon of the tooltip (which is in front of the text)
176 	 * to be the icon indicated by @gicon with the size indicated
177 	 * by @size. If @gicon is %NULL, the image will be hidden.
178 	 *
179 	 * Params:
180 	 *     gicon = a #GIcon representing the icon, or %NULL
181 	 *     size = a stock icon size (#GtkIconSize)
182 	 *
183 	 * Since: 2.20
184 	 */
185 	public void setIconFromGicon(IconIF gicon, GtkIconSize size)
186 	{
187 		gtk_tooltip_set_icon_from_gicon(gtkTooltip, (gicon is null) ? null : gicon.getIconStruct(), size);
188 	}
189 
190 	/**
191 	 * Sets the icon of the tooltip (which is in front of the text) to be
192 	 * the icon indicated by @icon_name with the size indicated
193 	 * by @size.  If @icon_name is %NULL, the image will be hidden.
194 	 *
195 	 * Params:
196 	 *     iconName = an icon name, or %NULL
197 	 *     size = a stock icon size (#GtkIconSize)
198 	 *
199 	 * Since: 2.14
200 	 */
201 	public void setIconFromIconName(string iconName, GtkIconSize size)
202 	{
203 		gtk_tooltip_set_icon_from_icon_name(gtkTooltip, Str.toStringz(iconName), size);
204 	}
205 
206 	/**
207 	 * Sets the icon of the tooltip (which is in front of the text) to be
208 	 * the stock item indicated by @stock_id with the size indicated
209 	 * by @size.  If @stock_id is %NULL, the image will be hidden.
210 	 *
211 	 * Deprecated: Use gtk_tooltip_set_icon_from_icon_name() instead.
212 	 *
213 	 * Params:
214 	 *     stockId = a stock id, or %NULL
215 	 *     size = a stock icon size (#GtkIconSize)
216 	 *
217 	 * Since: 2.12
218 	 */
219 	public void setIconFromStock(string stockId, GtkIconSize size)
220 	{
221 		gtk_tooltip_set_icon_from_stock(gtkTooltip, Str.toStringz(stockId), size);
222 	}
223 
224 	/**
225 	 * Sets the text of the tooltip to be @markup, which is marked up
226 	 * with the [Pango text markup language][PangoMarkupFormat].
227 	 * If @markup is %NULL, the label will be hidden.
228 	 *
229 	 * Params:
230 	 *     markup = a markup string (see [Pango markup format][PangoMarkupFormat]) or %NULL
231 	 *
232 	 * Since: 2.12
233 	 */
234 	public void setMarkup(string markup)
235 	{
236 		gtk_tooltip_set_markup(gtkTooltip, Str.toStringz(markup));
237 	}
238 
239 	/**
240 	 * Sets the text of the tooltip to be @text. If @text is %NULL, the label
241 	 * will be hidden. See also gtk_tooltip_set_markup().
242 	 *
243 	 * Params:
244 	 *     text = a text string or %NULL
245 	 *
246 	 * Since: 2.12
247 	 */
248 	public void setText(string text)
249 	{
250 		gtk_tooltip_set_text(gtkTooltip, Str.toStringz(text));
251 	}
252 
253 	/**
254 	 * Sets the area of the widget, where the contents of this tooltip apply,
255 	 * to be @rect (in widget coordinates).  This is especially useful for
256 	 * properly setting tooltips on #GtkTreeView rows and cells, #GtkIconViews,
257 	 * etc.
258 	 *
259 	 * For setting tooltips on #GtkTreeView, please refer to the convenience
260 	 * functions for this: gtk_tree_view_set_tooltip_row() and
261 	 * gtk_tree_view_set_tooltip_cell().
262 	 *
263 	 * Params:
264 	 *     rect = a #GdkRectangle
265 	 *
266 	 * Since: 2.12
267 	 */
268 	public void setTipArea(GdkRectangle* rect)
269 	{
270 		gtk_tooltip_set_tip_area(gtkTooltip, rect);
271 	}
272 }