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