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.NumerableIcon; 26 27 private import gio.EmblemedIcon; 28 private import gio.IconIF; 29 private import gio.IconT; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gtk.StyleContext; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 public import gtkc.gtktypes; 37 38 39 /** 40 * GtkNumerableIcon is a subclass of #GEmblemedIcon that can 41 * show a number or short string as an emblem. The number can 42 * be overlayed on top of another emblem, if desired. 43 * 44 * It supports theming by taking font and color information 45 * from a provided #GtkStyleContext; see 46 * gtk_numerable_icon_set_style_context(). 47 * 48 * Typical numerable icons: 49 * ![](numerableicon.png) 50 * ![](numerableicon2.png) 51 */ 52 public class NumerableIcon : EmblemedIcon 53 { 54 /** the main Gtk struct */ 55 protected GtkNumerableIcon* gtkNumerableIcon; 56 57 /** Get the main Gtk struct */ 58 public GtkNumerableIcon* getNumerableIconStruct(bool transferOwnership = false) 59 { 60 if (transferOwnership) 61 ownedRef = false; 62 return gtkNumerableIcon; 63 } 64 65 /** the main Gtk struct as a void* */ 66 protected override void* getStruct() 67 { 68 return cast(void*)gtkNumerableIcon; 69 } 70 71 /** 72 * Sets our main struct and passes it to the parent class. 73 */ 74 public this (GtkNumerableIcon* gtkNumerableIcon, bool ownedRef = false) 75 { 76 this.gtkNumerableIcon = gtkNumerableIcon; 77 super(cast(GEmblemedIcon*)gtkNumerableIcon, ownedRef); 78 } 79 80 81 /** */ 82 public static GType getType() 83 { 84 return gtk_numerable_icon_get_type(); 85 } 86 87 /** 88 * Creates a new unthemed #GtkNumerableIcon. 89 * 90 * Params: 91 * baseIcon = a #GIcon to overlay on 92 * 93 * Returns: a new #GIcon 94 * 95 * Since: 3.0 96 * 97 * Throws: ConstructionException GTK+ fails to create the object. 98 */ 99 public this(IconIF baseIcon) 100 { 101 auto p = gtk_numerable_icon_new((baseIcon is null) ? null : baseIcon.getIconStruct()); 102 103 if(p is null) 104 { 105 throw new ConstructionException("null returned by new"); 106 } 107 108 this(cast(GtkNumerableIcon*) p, true); 109 } 110 111 /** 112 * Creates a new #GtkNumerableIcon which will themed according 113 * to the passed #GtkStyleContext. This is a convenience constructor 114 * that calls gtk_numerable_icon_set_style_context() internally. 115 * 116 * Params: 117 * baseIcon = a #GIcon to overlay on 118 * context = a #GtkStyleContext 119 * 120 * Returns: a new #GIcon 121 * 122 * Since: 3.0 123 * 124 * Throws: ConstructionException GTK+ fails to create the object. 125 */ 126 public this(IconIF baseIcon, StyleContext context) 127 { 128 auto p = gtk_numerable_icon_new_with_style_context((baseIcon is null) ? null : baseIcon.getIconStruct(), (context is null) ? null : context.getStyleContextStruct()); 129 130 if(p is null) 131 { 132 throw new ConstructionException("null returned by new_with_style_context"); 133 } 134 135 this(cast(GtkNumerableIcon*) p, true); 136 } 137 138 /** 139 * Returns the #GIcon that was set as the base background image, or 140 * %NULL if there’s none. The caller of this function does not own 141 * a reference to the returned #GIcon. 142 * 143 * Returns: a #GIcon, or %NULL 144 * 145 * Since: 3.0 146 */ 147 public IconIF getBackgroundGicon() 148 { 149 auto p = gtk_numerable_icon_get_background_gicon(gtkNumerableIcon); 150 151 if(p is null) 152 { 153 return null; 154 } 155 156 return ObjectG.getDObject!(IconIF)(cast(GIcon*) p); 157 } 158 159 /** 160 * Returns the icon name used as the base background image, 161 * or %NULL if there’s none. 162 * 163 * Returns: an icon name, or %NULL 164 * 165 * Since: 3.0 166 */ 167 public string getBackgroundIconName() 168 { 169 return Str.toString(gtk_numerable_icon_get_background_icon_name(gtkNumerableIcon)); 170 } 171 172 /** 173 * Returns the value currently displayed by @self. 174 * 175 * Returns: the currently displayed value 176 * 177 * Since: 3.0 178 */ 179 public int getCount() 180 { 181 return gtk_numerable_icon_get_count(gtkNumerableIcon); 182 } 183 184 /** 185 * Returns the currently displayed label of the icon, or %NULL. 186 * 187 * Returns: the currently displayed label 188 * 189 * Since: 3.0 190 */ 191 public string getLabel() 192 { 193 return Str.toString(gtk_numerable_icon_get_label(gtkNumerableIcon)); 194 } 195 196 /** 197 * Returns the #GtkStyleContext used by the icon for theming, 198 * or %NULL if there’s none. 199 * 200 * Returns: a #GtkStyleContext, or %NULL. 201 * This object is internal to GTK+ and should not be unreffed. 202 * Use g_object_ref() if you want to keep it around 203 * 204 * Since: 3.0 205 */ 206 public StyleContext getStyleContext() 207 { 208 auto p = gtk_numerable_icon_get_style_context(gtkNumerableIcon); 209 210 if(p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(StyleContext)(cast(GtkStyleContext*) p); 216 } 217 218 /** 219 * Updates the icon to use @icon as the base background image. 220 * If @icon is %NULL, @self will go back using style information 221 * or default theming for its background image. 222 * 223 * If this method is called and an icon name was already set as 224 * background for the icon, @icon will be used, i.e. the last method 225 * called between gtk_numerable_icon_set_background_gicon() and 226 * gtk_numerable_icon_set_background_icon_name() has always priority. 227 * 228 * Params: 229 * icon = a #GIcon, or %NULL 230 * 231 * Since: 3.0 232 */ 233 public void setBackgroundGicon(IconIF icon) 234 { 235 gtk_numerable_icon_set_background_gicon(gtkNumerableIcon, (icon is null) ? null : icon.getIconStruct()); 236 } 237 238 /** 239 * Updates the icon to use the icon named @icon_name from the 240 * current icon theme as the base background image. If @icon_name 241 * is %NULL, @self will go back using style information or default 242 * theming for its background image. 243 * 244 * If this method is called and a #GIcon was already set as 245 * background for the icon, @icon_name will be used, i.e. the 246 * last method called between gtk_numerable_icon_set_background_icon_name() 247 * and gtk_numerable_icon_set_background_gicon() has always priority. 248 * 249 * Params: 250 * iconName = an icon name, or %NULL 251 * 252 * Since: 3.0 253 */ 254 public void setBackgroundIconName(string iconName) 255 { 256 gtk_numerable_icon_set_background_icon_name(gtkNumerableIcon, Str.toStringz(iconName)); 257 } 258 259 /** 260 * Sets the currently displayed value of @self to @count. 261 * 262 * The numeric value is always clamped to make it two digits, i.e. 263 * between -99 and 99. Setting a count of zero removes the emblem. 264 * If this method is called, and a label was already set on the icon, 265 * it will automatically be reset to %NULL before rendering the number, 266 * i.e. the last method called between gtk_numerable_icon_set_count() 267 * and gtk_numerable_icon_set_label() has always priority. 268 * 269 * Params: 270 * count = a number between -99 and 99 271 * 272 * Since: 3.0 273 */ 274 public void setCount(int count) 275 { 276 gtk_numerable_icon_set_count(gtkNumerableIcon, count); 277 } 278 279 /** 280 * Sets the currently displayed value of @self to the string 281 * in @label. Setting an empty label removes the emblem. 282 * 283 * Note that this is meant for displaying short labels, such as 284 * roman numbers, or single letters. For roman numbers, consider 285 * using the Unicode characters U+2160 - U+217F. Strings longer 286 * than two characters will likely not be rendered very well. 287 * 288 * If this method is called, and a number was already set on the 289 * icon, it will automatically be reset to zero before rendering 290 * the label, i.e. the last method called between 291 * gtk_numerable_icon_set_label() and gtk_numerable_icon_set_count() 292 * has always priority. 293 * 294 * Params: 295 * label = a short label, or %NULL 296 * 297 * Since: 3.0 298 */ 299 public void setLabel(string label) 300 { 301 gtk_numerable_icon_set_label(gtkNumerableIcon, Str.toStringz(label)); 302 } 303 304 /** 305 * Updates the icon to fetch theme information from the 306 * given #GtkStyleContext. 307 * 308 * Params: 309 * style = a #GtkStyleContext 310 * 311 * Since: 3.0 312 */ 313 public void setStyleContext(StyleContext style) 314 { 315 gtk_numerable_icon_set_style_context(gtkNumerableIcon, (style is null) ? null : style.getStyleContextStruct()); 316 } 317 }