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 
65 	public static GType getType()
66 	{
67 		return pango_color_get_type();
68 	}
69 
70 	/**
71 	 * Creates a copy of @src, which should be freed with
72 	 * pango_color_free(). Primarily used by language bindings,
73 	 * not that useful otherwise (since colors can just be copied
74 	 * by assignment in C).
75 	 *
76 	 * Return: the newly allocated #PangoColor, which should
77 	 *     be freed with pango_color_free(), or %NULL
78 	 *     if @src was %NULL.
79 	 */
80 	public PgColor copy()
81 	{
82 		auto p = pango_color_copy(pangoColor);
83 		
84 		if(p is null)
85 		{
86 			return null;
87 		}
88 		
89 		return ObjectG.getDObject!(PgColor)(cast(PangoColor*) p);
90 	}
91 
92 	/**
93 	 * Frees a color allocated by pango_color_copy().
94 	 */
95 	public void free()
96 	{
97 		pango_color_free(pangoColor);
98 	}
99 
100 	/**
101 	 * Fill in the fields of a color from a string specification. The
102 	 * string can either one of a large set of standard names. (Taken
103 	 * from the CSS <ulink url="http://dev.w3.org/csswg/css-color/#named-colors">specification</ulink>), or it can be a hexadecimal
104 	 * value in the
105 	 * form '&num;rgb' '&num;rrggbb' '&num;rrrgggbbb' or '&num;rrrrggggbbbb' where
106 	 * 'r', 'g' and 'b' are hex digits of the red, green, and blue
107 	 * components of the color, respectively. (White in the four
108 	 * forms is '&num;fff' '&num;ffffff' '&num;fffffffff' and '&num;ffffffffffff')
109 	 *
110 	 * Params:
111 	 *     spec = a string specifying the new color
112 	 *
113 	 * Return: %TRUE if parsing of the specifier succeeded,
114 	 *     otherwise false.
115 	 */
116 	public bool parse(string spec)
117 	{
118 		return pango_color_parse(pangoColor, Str.toStringz(spec)) != 0;
119 	}
120 
121 	/**
122 	 * Returns a textual specification of @color in the hexadecimal form
123 	 * <literal>&num;rrrrggggbbbb</literal>, where <literal>r</literal>,
124 	 * <literal>g</literal> and <literal>b</literal> are hex digits representing
125 	 * the red, green, and blue components respectively.
126 	 *
127 	 * Return: a newly-allocated text string that must be freed with g_free().
128 	 *
129 	 * Since: 1.16
130 	 */
131 	public override string toString()
132 	{
133 		return Str.toString(pango_color_to_string(pangoColor));
134 	}
135 }