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