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