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