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 /** 94 * Sets our main struct and passes it to the parent class. 95 */ 96 public this (GtkTooltip* gtkTooltip, bool ownedRef = false) 97 { 98 this.gtkTooltip = gtkTooltip; 99 super(cast(GObject*)gtkTooltip, ownedRef); 100 } 101 102 /** 103 * Sets the icon of the tooltip (which is in front of the text) to be 104 * the stock item indicated by stockID with the size indicated by size. 105 */ 106 void setIcon(StockID stockID, GtkIconSize size) 107 { 108 setIconFromStock(cast(string)stockID, size); 109 } 110 111 /** 112 */ 113 114 /** */ 115 public static GType getType() 116 { 117 return gtk_tooltip_get_type(); 118 } 119 120 /** 121 * Triggers a new tooltip query on @display, in order to update the current 122 * visible tooltip, or to show/hide the current tooltip. This function is 123 * useful to call when, for example, the state of the widget changed by a 124 * key press. 125 * 126 * Params: 127 * display = a #GdkDisplay 128 * 129 * Since: 2.12 130 */ 131 public static void triggerTooltipQuery(Display display) 132 { 133 gtk_tooltip_trigger_tooltip_query((display is null) ? null : display.getDisplayStruct()); 134 } 135 136 /** 137 * Replaces the widget packed into the tooltip with 138 * @custom_widget. @custom_widget does not get destroyed when the tooltip goes 139 * away. 140 * By default a box with a #GtkImage and #GtkLabel is embedded in 141 * the tooltip, which can be configured using gtk_tooltip_set_markup() 142 * and gtk_tooltip_set_icon(). 143 * 144 * Params: 145 * customWidget = a #GtkWidget, or %NULL to unset the old custom widget. 146 * 147 * Since: 2.12 148 */ 149 public void setCustom(Widget customWidget) 150 { 151 gtk_tooltip_set_custom(gtkTooltip, (customWidget is null) ? null : customWidget.getWidgetStruct()); 152 } 153 154 /** 155 * Sets the icon of the tooltip (which is in front of the text) to be 156 * @pixbuf. If @pixbuf is %NULL, the image will be hidden. 157 * 158 * Params: 159 * pixbuf = a #GdkPixbuf, or %NULL 160 * 161 * Since: 2.12 162 */ 163 public void setIcon(Pixbuf pixbuf) 164 { 165 gtk_tooltip_set_icon(gtkTooltip, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 166 } 167 168 /** 169 * Sets the icon of the tooltip (which is in front of the text) 170 * to be the icon indicated by @gicon with the size indicated 171 * by @size. If @gicon is %NULL, the image will be hidden. 172 * 173 * Params: 174 * gicon = a #GIcon representing the icon, or %NULL 175 * size = a stock icon size (#GtkIconSize) 176 * 177 * Since: 2.20 178 */ 179 public void setIconFromGicon(IconIF gicon, GtkIconSize size) 180 { 181 gtk_tooltip_set_icon_from_gicon(gtkTooltip, (gicon is null) ? null : gicon.getIconStruct(), size); 182 } 183 184 /** 185 * Sets the icon of the tooltip (which is in front of the text) to be 186 * the icon indicated by @icon_name with the size indicated 187 * by @size. If @icon_name is %NULL, the image will be hidden. 188 * 189 * Params: 190 * iconName = an icon name, or %NULL 191 * size = a stock icon size (#GtkIconSize) 192 * 193 * Since: 2.14 194 */ 195 public void setIconFromIconName(string iconName, GtkIconSize size) 196 { 197 gtk_tooltip_set_icon_from_icon_name(gtkTooltip, Str.toStringz(iconName), size); 198 } 199 200 /** 201 * Sets the icon of the tooltip (which is in front of the text) to be 202 * the stock item indicated by @stock_id with the size indicated 203 * by @size. If @stock_id is %NULL, the image will be hidden. 204 * 205 * Deprecated: Use gtk_tooltip_set_icon_from_icon_name() instead. 206 * 207 * Params: 208 * stockId = a stock id, or %NULL 209 * size = a stock icon size (#GtkIconSize) 210 * 211 * Since: 2.12 212 */ 213 public void setIconFromStock(string stockId, GtkIconSize size) 214 { 215 gtk_tooltip_set_icon_from_stock(gtkTooltip, Str.toStringz(stockId), size); 216 } 217 218 /** 219 * Sets the text of the tooltip to be @markup, which is marked up 220 * with the [Pango text markup language][PangoMarkupFormat]. 221 * If @markup is %NULL, the label will be hidden. 222 * 223 * Params: 224 * markup = a markup string (see [Pango markup format][PangoMarkupFormat]) or %NULL 225 * 226 * Since: 2.12 227 */ 228 public void setMarkup(string markup) 229 { 230 gtk_tooltip_set_markup(gtkTooltip, Str.toStringz(markup)); 231 } 232 233 /** 234 * Sets the text of the tooltip to be @text. If @text is %NULL, the label 235 * will be hidden. See also gtk_tooltip_set_markup(). 236 * 237 * Params: 238 * text = a text string or %NULL 239 * 240 * Since: 2.12 241 */ 242 public void setText(string text) 243 { 244 gtk_tooltip_set_text(gtkTooltip, Str.toStringz(text)); 245 } 246 247 /** 248 * Sets the area of the widget, where the contents of this tooltip apply, 249 * to be @rect (in widget coordinates). This is especially useful for 250 * properly setting tooltips on #GtkTreeView rows and cells, #GtkIconViews, 251 * etc. 252 * 253 * For setting tooltips on #GtkTreeView, please refer to the convenience 254 * functions for this: gtk_tree_view_set_tooltip_row() and 255 * gtk_tree_view_set_tooltip_cell(). 256 * 257 * Params: 258 * rect = a #GdkRectangle 259 * 260 * Since: 2.12 261 */ 262 public void setTipArea(GdkRectangle* rect) 263 { 264 gtk_tooltip_set_tip_area(gtkTooltip, rect); 265 } 266 }