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