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