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