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 pango.PgColor;
26 
27 private import glib.Str;
28 private import gobject.ObjectG;
29 private import gtkc.pango;
30 public  import gtkc.pangotypes;
31 
32 
33 /**
34  * The #PangoColor structure is used to
35  * represent a color in an uncalibrated RGB color-space.
36  */
37 public class PgColor
38 {
39 	/** the main Gtk struct */
40 	protected PangoColor* pangoColor;
41 
42 	/** Get the main Gtk struct */
43 	public PangoColor* getPgColorStruct()
44 	{
45 		return pangoColor;
46 	}
47 
48 	/** the main Gtk struct as a void* */
49 	protected void* getStruct()
50 	{
51 		return cast(void*)pangoColor;
52 	}
53 
54 	/**
55 	 * Sets our main struct and passes it to the parent class.
56 	 */
57 	public this (PangoColor* pangoColor)
58 	{
59 		this.pangoColor = pangoColor;
60 	}
61 
62 
63 	/** */
64 	public static GType getType()
65 	{
66 		return pango_color_get_type();
67 	}
68 
69 	/**
70 	 * Creates a copy of @src, which should be freed with
71 	 * pango_color_free(). Primarily used by language bindings,
72 	 * not that useful otherwise (since colors can just be copied
73 	 * by assignment in C).
74 	 *
75 	 * Return: the newly allocated #PangoColor, which
76 	 *     should be freed with pango_color_free(), or %NULL if
77 	 *     @src was %NULL.
78 	 */
79 	public PgColor copy()
80 	{
81 		auto p = pango_color_copy(pangoColor);
82 		
83 		if(p is null)
84 		{
85 			return null;
86 		}
87 		
88 		return ObjectG.getDObject!(PgColor)(cast(PangoColor*) p);
89 	}
90 
91 	/**
92 	 * Frees a color allocated by pango_color_copy().
93 	 */
94 	public void free()
95 	{
96 		pango_color_free(pangoColor);
97 	}
98 
99 	/**
100 	 * Fill in the fields of a color from a string specification. The
101 	 * string can either one of a large set of standard names. (Taken
102 	 * from the CSS <ulink url="http://dev.w3.org/csswg/css-color/#named-colors">specification</ulink>), or it can be a hexadecimal
103 	 * value in the
104 	 * form '&num;rgb' '&num;rrggbb' '&num;rrrgggbbb' or '&num;rrrrggggbbbb' where
105 	 * 'r', 'g' and 'b' are hex digits of the red, green, and blue
106 	 * components of the color, respectively. (White in the four
107 	 * forms is '&num;fff' '&num;ffffff' '&num;fffffffff' and '&num;ffffffffffff')
108 	 *
109 	 * Params:
110 	 *     spec = a string specifying the new color
111 	 *
112 	 * Return: %TRUE if parsing of the specifier succeeded,
113 	 *     otherwise false.
114 	 */
115 	public bool parse(string spec)
116 	{
117 		return pango_color_parse(pangoColor, Str.toStringz(spec)) != 0;
118 	}
119 
120 	/**
121 	 * Returns a textual specification of @color in the hexadecimal form
122 	 * <literal>&num;rrrrggggbbbb</literal>, where <literal>r</literal>,
123 	 * <literal>g</literal> and <literal>b</literal> are hex digits representing
124 	 * the red, green, and blue components respectively.
125 	 *
126 	 * Return: a newly-allocated text string that must be freed with g_free().
127 	 *
128 	 * Since: 1.16
129 	 */
130 	public override string toString()
131 	{
132 		return Str.toString(pango_color_to_string(pangoColor));
133 	}
134 }