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