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