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  * Conversion parameters:
26  * inFile  = pango-Coverage-Maps.html
27  * outPack = pango
28  * outFile = PgCoverage
29  * strct   = PangoCoverage
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgCoverage
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_coverage_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * 	- PangoCoverage* -> PgCoverage
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module pango.PgCoverage;
54 
55 public  import gtkc.pangotypes;
56 
57 private import gtkc.pango;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 
62 
63 
64 
65 
66 /**
67  * Description
68  * It is often necessary in Pango to determine if a particular font can
69  * represent a particular character, and also how well it can represent
70  * that character. The PangoCoverage is a data structure that is used
71  * to represent that information.
72  */
73 public class PgCoverage
74 {
75 	
76 	/** the main Gtk struct */
77 	protected PangoCoverage* pangoCoverage;
78 	
79 	
80 	public PangoCoverage* getPgCoverageStruct()
81 	{
82 		return pangoCoverage;
83 	}
84 	
85 	
86 	/** the main Gtk struct as a void* */
87 	protected void* getStruct()
88 	{
89 		return cast(void*)pangoCoverage;
90 	}
91 	
92 	/**
93 	 * Sets our main struct and passes it to the parent class
94 	 */
95 	public this (PangoCoverage* pangoCoverage)
96 	{
97 		this.pangoCoverage = pangoCoverage;
98 	}
99 	
100 	/**
101 	 */
102 	
103 	/**
104 	 * Create a new PangoCoverage
105 	 * Throws: ConstructionException GTK+ fails to create the object.
106 	 */
107 	public this ()
108 	{
109 		// PangoCoverage * pango_coverage_new (void);
110 		auto p = pango_coverage_new();
111 		if(p is null)
112 		{
113 			throw new ConstructionException("null returned by pango_coverage_new()");
114 		}
115 		this(cast(PangoCoverage*) p);
116 	}
117 	
118 	/**
119 	 * Increase the reference count on the PangoCoverage by one
120 	 * Returns: coverage
121 	 */
122 	public PgCoverage doref()
123 	{
124 		// PangoCoverage * pango_coverage_ref (PangoCoverage *coverage);
125 		auto p = pango_coverage_ref(pangoCoverage);
126 		
127 		if(p is null)
128 		{
129 			return null;
130 		}
131 		
132 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
133 	}
134 	
135 	/**
136 	 * Decrease the reference count on the PangoCoverage by one.
137 	 * If the result is zero, free the coverage and all associated memory.
138 	 */
139 	public void unref()
140 	{
141 		// void pango_coverage_unref (PangoCoverage *coverage);
142 		pango_coverage_unref(pangoCoverage);
143 	}
144 	
145 	/**
146 	 * Copy an existing PangoCoverage. (This function may now be unnecessary
147 	 * since we refcount the structure. File a bug if you use it.)
148 	 * Returns: the newly allocated PangoCoverage, with a reference count of one, which should be freed with pango_coverage_unref().
149 	 */
150 	public PgCoverage copy()
151 	{
152 		// PangoCoverage * pango_coverage_copy (PangoCoverage *coverage);
153 		auto p = pango_coverage_copy(pangoCoverage);
154 		
155 		if(p is null)
156 		{
157 			return null;
158 		}
159 		
160 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
161 	}
162 	
163 	/**
164 	 * Determine whether a particular index is covered by coverage
165 	 * Params:
166 	 * index = the index to check
167 	 * Returns: the coverage level of coverage for character index_.
168 	 */
169 	public PangoCoverageLevel get(int index)
170 	{
171 		// PangoCoverageLevel pango_coverage_get (PangoCoverage *coverage,  int index_);
172 		return pango_coverage_get(pangoCoverage, index);
173 	}
174 	
175 	/**
176 	 * Set the coverage for each index in coverage to be the max (better)
177 	 * value of the current coverage for the index and the coverage for
178 	 * the corresponding index in other.
179 	 * Params:
180 	 * other = another PangoCoverage
181 	 */
182 	public void max(PgCoverage other)
183 	{
184 		// void pango_coverage_max (PangoCoverage *coverage,  PangoCoverage *other);
185 		pango_coverage_max(pangoCoverage, (other is null) ? null : other.getPgCoverageStruct());
186 	}
187 	
188 	/**
189 	 * Modify a particular index within coverage
190 	 * Params:
191 	 * index = the index to modify
192 	 * level = the new level for index_
193 	 */
194 	public void set(int index, PangoCoverageLevel level)
195 	{
196 		// void pango_coverage_set (PangoCoverage *coverage,  int index_,  PangoCoverageLevel level);
197 		pango_coverage_set(pangoCoverage, index, level);
198 	}
199 	
200 	/**
201 	 * Convert a PangoCoverage structure into a flat binary format
202 	 * Params:
203 	 * bytes = location to store result (must be freed with g_free())
204 	 */
205 	public void toBytes(out char[] bytes)
206 	{
207 		// void pango_coverage_to_bytes (PangoCoverage *coverage,  guchar **bytes,  int *n_bytes);
208 		guchar* outbytes = null;
209 		int nBytes;
210 		
211 		pango_coverage_to_bytes(pangoCoverage, &outbytes, &nBytes);
212 		
213 		bytes = outbytes[0 .. nBytes];
214 	}
215 	
216 	/**
217 	 * Convert data generated from pango_converage_to_bytes() back
218 	 * to a PangoCoverage
219 	 * Params:
220 	 * bytes = binary data representing a PangoCoverage
221 	 * Returns: a newly allocated PangoCoverage, or NULL if the data was invalid.
222 	 */
223 	public static PgCoverage fromBytes(char[] bytes)
224 	{
225 		// PangoCoverage * pango_coverage_from_bytes (guchar *bytes,  int n_bytes);
226 		auto p = pango_coverage_from_bytes(bytes.ptr, cast(int) bytes.length);
227 		
228 		if(p is null)
229 		{
230 			return null;
231 		}
232 		
233 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
234 	}
235 }