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