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