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.PgCoverage;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtkc.pango;
31 public  import gtkc.pangotypes;
32 
33 
34 /**
35  * The #PangoCoverage structure represents a map from Unicode characters
36  * to #PangoCoverageLevel. It is an opaque structure with no public fields.
37  */
38 public class PgCoverage
39 {
40 	/** the main Gtk struct */
41 	protected PangoCoverage* pangoCoverage;
42 
43 	/** Get the main Gtk struct */
44 	public PangoCoverage* getPgCoverageStruct()
45 	{
46 		return pangoCoverage;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected void* getStruct()
51 	{
52 		return cast(void*)pangoCoverage;
53 	}
54 
55 	/**
56 	 * Sets our main struct and passes it to the parent class.
57 	 */
58 	public this (PangoCoverage* pangoCoverage)
59 	{
60 		this.pangoCoverage = pangoCoverage;
61 	}
62 
63 	/**
64 	 */
65 
66 	/**
67 	 * Copy an existing #PangoCoverage. (This function may now be unnecessary
68 	 * since we refcount the structure. File a bug if you use it.)
69 	 *
70 	 * Return: the newly allocated #PangoCoverage,
71 	 *     with a reference count of one, which should be freed
72 	 *     with pango_coverage_unref().
73 	 */
74 	public PgCoverage copy()
75 	{
76 		auto p = pango_coverage_copy(pangoCoverage);
77 		
78 		if(p is null)
79 		{
80 			return null;
81 		}
82 		
83 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
84 	}
85 
86 	/**
87 	 * Determine whether a particular index is covered by @coverage
88 	 *
89 	 * Params:
90 	 *     index = the index to check
91 	 *
92 	 * Return: the coverage level of @coverage for character @index_.
93 	 */
94 	public PangoCoverageLevel get(int index)
95 	{
96 		return pango_coverage_get(pangoCoverage, index);
97 	}
98 
99 	/**
100 	 * Set the coverage for each index in @coverage to be the max (better)
101 	 * value of the current coverage for the index and the coverage for
102 	 * the corresponding index in @other.
103 	 *
104 	 * Params:
105 	 *     other = another #PangoCoverage
106 	 */
107 	public void max(PgCoverage other)
108 	{
109 		pango_coverage_max(pangoCoverage, (other is null) ? null : other.getPgCoverageStruct());
110 	}
111 
112 	/**
113 	 * Increase the reference count on the #PangoCoverage by one
114 	 *
115 	 * Return: @coverage
116 	 */
117 	public PgCoverage doref()
118 	{
119 		auto p = pango_coverage_ref(pangoCoverage);
120 		
121 		if(p is null)
122 		{
123 			return null;
124 		}
125 		
126 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
127 	}
128 
129 	/**
130 	 * Modify a particular index within @coverage
131 	 *
132 	 * Params:
133 	 *     index = the index to modify
134 	 *     level = the new level for @index_
135 	 */
136 	public void set(int index, PangoCoverageLevel level)
137 	{
138 		pango_coverage_set(pangoCoverage, index, level);
139 	}
140 
141 	/**
142 	 * Convert a #PangoCoverage structure into a flat binary format
143 	 *
144 	 * Params:
145 	 *     bytes = location to store result (must be freed with g_free())
146 	 *     nBytes = location to store size of result
147 	 */
148 	public void toBytes(out string bytes)
149 	{
150 		char* outbytes = null;
151 		int nBytes;
152 		
153 		pango_coverage_to_bytes(pangoCoverage, &outbytes, &nBytes);
154 		
155 		bytes = Str.toString(outbytes, nBytes);
156 	}
157 
158 	/**
159 	 * Decrease the reference count on the #PangoCoverage by one.
160 	 * If the result is zero, free the coverage and all associated memory.
161 	 */
162 	public void unref()
163 	{
164 		pango_coverage_unref(pangoCoverage);
165 	}
166 
167 	/**
168 	 * Convert data generated from pango_coverage_to_bytes() back
169 	 * to a #PangoCoverage
170 	 *
171 	 * Params:
172 	 *     bytes = binary data
173 	 *         representing a #PangoCoverage
174 	 *     nBytes = the size of @bytes in bytes
175 	 *
176 	 * Return: a newly allocated #PangoCoverage, or
177 	 *     %NULL if the data was invalid.
178 	 */
179 	public static PgCoverage fromBytes(string bytes)
180 	{
181 		auto p = pango_coverage_from_bytes(Str.toStringz(bytes), cast(int)bytes.length);
182 		
183 		if(p is null)
184 		{
185 			return null;
186 		}
187 		
188 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
189 	}
190 
191 	/**
192 	 * Create a new #PangoCoverage
193 	 *
194 	 * Return: the newly allocated #PangoCoverage,
195 	 *     initialized to %PANGO_COVERAGE_NONE
196 	 *     with a reference count of one, which
197 	 *     should be freed with pango_coverage_unref().
198 	 *
199 	 * Throws: ConstructionException GTK+ fails to create the object.
200 	 */
201 	public this()
202 	{
203 		auto p = pango_coverage_new();
204 		
205 		if(p is null)
206 		{
207 			throw new ConstructionException("null returned by new");
208 		}
209 		
210 		this(cast(PangoCoverage*) p);
211 	}
212 }