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 	alias doref = ref_;
123 	/**
124 	 * Increase the reference count on the #PangoCoverage by one
125 	 *
126 	 * Returns: @coverage
127 	 */
128 	public PgCoverage ref_()
129 	{
130 		auto p = pango_coverage_ref(pangoCoverage);
131 
132 		if(p is null)
133 		{
134 			return null;
135 		}
136 
137 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
138 	}
139 
140 	/**
141 	 * Modify a particular index within @coverage
142 	 *
143 	 * Params:
144 	 *     index = the index to modify
145 	 *     level = the new level for @index_
146 	 */
147 	public void set(int index, PangoCoverageLevel level)
148 	{
149 		pango_coverage_set(pangoCoverage, index, level);
150 	}
151 
152 	/**
153 	 * Convert a #PangoCoverage structure into a flat binary format
154 	 *
155 	 * Params:
156 	 *     bytes = location to store result (must be freed with g_free())
157 	 */
158 	public void toBytes(out ubyte[] bytes)
159 	{
160 		ubyte* outbytes = null;
161 		int nBytes;
162 
163 		pango_coverage_to_bytes(pangoCoverage, cast(char**)&outbytes, &nBytes);
164 
165 		bytes = outbytes[0 .. nBytes];
166 	}
167 
168 	/**
169 	 * Decrease the reference count on the #PangoCoverage by one.
170 	 * If the result is zero, free the coverage and all associated memory.
171 	 */
172 	public void unref()
173 	{
174 		pango_coverage_unref(pangoCoverage);
175 	}
176 
177 	/**
178 	 * Convert data generated from pango_coverage_to_bytes() back
179 	 * to a #PangoCoverage
180 	 *
181 	 * Params:
182 	 *     bytes = binary data
183 	 *         representing a #PangoCoverage
184 	 *
185 	 * Returns: a newly allocated
186 	 *     #PangoCoverage, or %NULL if the data was invalid.
187 	 */
188 	public static PgCoverage fromBytes(char[] bytes)
189 	{
190 		auto p = pango_coverage_from_bytes(bytes.ptr, cast(int)bytes.length);
191 
192 		if(p is null)
193 		{
194 			return null;
195 		}
196 
197 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p, true);
198 	}
199 
200 	/**
201 	 * Create a new #PangoCoverage
202 	 *
203 	 * Returns: the newly allocated #PangoCoverage,
204 	 *     initialized to %PANGO_COVERAGE_NONE
205 	 *     with a reference count of one, which
206 	 *     should be freed with pango_coverage_unref().
207 	 *
208 	 * Throws: ConstructionException GTK+ fails to create the object.
209 	 */
210 	public this()
211 	{
212 		auto p = pango_coverage_new();
213 
214 		if(p is null)
215 		{
216 			throw new ConstructionException("null returned by new");
217 		}
218 
219 		this(cast(PangoCoverage*) p);
220 	}
221 }