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 glib.c.functions;
29 private import gobject.ObjectG;
30 public  import gtkc.pangotypes;
31 private import gtkd.Loader;
32 private import pango.c.functions;
33 public  import pango.c.types;
34 
35 
36 /**
37  * The #PangoColor structure is used to
38  * represent a color in an uncalibrated RGB color-space.
39  */
40 public final class PgColor
41 {
42 	/** the main Gtk struct */
43 	protected PangoColor* pangoColor;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public PangoColor* getPgColorStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return pangoColor;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)pangoColor;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (PangoColor* pangoColor, bool ownedRef = false)
64 	{
65 		this.pangoColor = pangoColor;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 	~this ()
70 	{
71 		if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef )
72 			pango_color_free(pangoColor);
73 	}
74 
75 
76 	/**
77 	 * value of red component
78 	 */
79 	public @property ushort red()
80 	{
81 		return pangoColor.red;
82 	}
83 
84 	/** Ditto */
85 	public @property void red(ushort value)
86 	{
87 		pangoColor.red = value;
88 	}
89 
90 	/**
91 	 * value of green component
92 	 */
93 	public @property ushort green()
94 	{
95 		return pangoColor.green;
96 	}
97 
98 	/** Ditto */
99 	public @property void green(ushort value)
100 	{
101 		pangoColor.green = value;
102 	}
103 
104 	/**
105 	 * value of blue component
106 	 */
107 	public @property ushort blue()
108 	{
109 		return pangoColor.blue;
110 	}
111 
112 	/** Ditto */
113 	public @property void blue(ushort value)
114 	{
115 		pangoColor.blue = value;
116 	}
117 
118 	/** */
119 	public static GType getType()
120 	{
121 		return pango_color_get_type();
122 	}
123 
124 	/**
125 	 * Creates a copy of @src, which should be freed with
126 	 * pango_color_free(). Primarily used by language bindings,
127 	 * not that useful otherwise (since colors can just be copied
128 	 * by assignment in C).
129 	 *
130 	 * Returns: the newly allocated #PangoColor, which
131 	 *     should be freed with pango_color_free(), or %NULL if
132 	 *     @src was %NULL.
133 	 */
134 	public PgColor copy()
135 	{
136 		auto p = pango_color_copy(pangoColor);
137 
138 		if(p is null)
139 		{
140 			return null;
141 		}
142 
143 		return ObjectG.getDObject!(PgColor)(cast(PangoColor*) p, true);
144 	}
145 
146 	/**
147 	 * Frees a color allocated by pango_color_copy().
148 	 */
149 	public void free()
150 	{
151 		pango_color_free(pangoColor);
152 		ownedRef = false;
153 	}
154 
155 	/**
156 	 * Fill in the fields of a color from a string specification. The
157 	 * string can either one of a large set of standard names. (Taken
158 	 * from the CSS <ulink url="http://dev.w3.org/csswg/css-color/#named-colors">specification</ulink>), or it can be a hexadecimal
159 	 * value in the
160 	 * form '&num;rgb' '&num;rrggbb' '&num;rrrgggbbb' or '&num;rrrrggggbbbb' where
161 	 * 'r', 'g' and 'b' are hex digits of the red, green, and blue
162 	 * components of the color, respectively. (White in the four
163 	 * forms is '&num;fff' '&num;ffffff' '&num;fffffffff' and '&num;ffffffffffff')
164 	 *
165 	 * Params:
166 	 *     spec = a string specifying the new color
167 	 *
168 	 * Returns: %TRUE if parsing of the specifier succeeded,
169 	 *     otherwise false.
170 	 */
171 	public bool parse(string spec)
172 	{
173 		return pango_color_parse(pangoColor, Str.toStringz(spec)) != 0;
174 	}
175 
176 	/**
177 	 * Returns a textual specification of @color in the hexadecimal form
178 	 * <literal>&num;rrrrggggbbbb</literal>, where <literal>r</literal>,
179 	 * <literal>g</literal> and <literal>b</literal> are hex digits representing
180 	 * the red, green, and blue components respectively.
181 	 *
182 	 * Returns: a newly-allocated text string that must be freed with g_free().
183 	 *
184 	 * Since: 1.16
185 	 */
186 	public override string toString()
187 	{
188 		auto retStr = pango_color_to_string(pangoColor);
189 
190 		scope(exit) Str.freeString(retStr);
191 		return Str.toString(retStr);
192 	}
193 }