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-Glyph-Storage.html
27  * outPack = pango
28  * outFile = PgMatrix
29  * strct   = PangoMatrix
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgMatrix
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_
41  * 	- pango_matrix_
42  * omit structs:
43  * omit prefixes:
44  * 	- pango_glyph_string_
45  * 	- pango_glyph_item_
46  * 	- pango_glyph_item_iter_
47  * omit code:
48  * omit signals:
49  * imports:
50  * structWrap:
51  * 	- PangoMatrix* -> PgMatrix
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module pango.PgMatrix;
58 
59 public  import gtkc.pangotypes;
60 
61 private import gtkc.pango;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 
66 
67 private import gobject.Boxed;
68 
69 /**
70  * pango_shape() produces a string of glyphs which
71  * can be measured or drawn to the screen. The following
72  * structures are used to store information about
73  * glyphs.
74  */
75 public class PgMatrix : Boxed
76 {
77 	
78 	/** the main Gtk struct */
79 	protected PangoMatrix* pangoMatrix;
80 	
81 	
82 	/** Get the main Gtk struct */
83 	public PangoMatrix* getPgMatrixStruct()
84 	{
85 		return pangoMatrix;
86 	}
87 	
88 	
89 	/** the main Gtk struct as a void* */
90 	protected void* getStruct()
91 	{
92 		return cast(void*)pangoMatrix;
93 	}
94 	
95 	/**
96 	 * Sets our main struct and passes it to the parent class
97 	 */
98 	public this (PangoMatrix* pangoMatrix)
99 	{
100 		this.pangoMatrix = pangoMatrix;
101 	}
102 	
103 	/**
104 	 */
105 	
106 	/**
107 	 * Converts a number in Pango units to floating-point: divides
108 	 * it by PANGO_SCALE.
109 	 * Since 1.16
110 	 * Params:
111 	 * i = value in Pango units
112 	 * Returns: the double value.
113 	 */
114 	public static double unitsToDouble(int i)
115 	{
116 		// double pango_units_to_double (int i);
117 		return pango_units_to_double(i);
118 	}
119 	
120 	/**
121 	 * Converts a floating-point number to Pango units: multiplies
122 	 * it by PANGO_SCALE and rounds to nearest integer.
123 	 * Since 1.16
124 	 * Params:
125 	 * d = double floating-point value
126 	 * Returns: the value in Pango units.
127 	 */
128 	public static int unitsFromDouble(double d)
129 	{
130 		// int pango_units_from_double (double d);
131 		return pango_units_from_double(d);
132 	}
133 	
134 	/**
135 	 * Converts extents from Pango units to device units, dividing by the
136 	 * PANGO_SCALE factor and performing rounding.
137 	 * The inclusive rectangle is converted by flooring the x/y coordinates and extending
138 	 * width/height, such that the final rectangle completely includes the original
139 	 * rectangle.
140 	 * The nearest rectangle is converted by rounding the coordinates
141 	 * of the rectangle to the nearest device unit (pixel).
142 	 * The rule to which argument to use is: if you want the resulting device-space
143 	 * rectangle to completely contain the original rectangle, pass it in as inclusive.
144 	 * If you want two touching-but-not-overlapping rectangles stay
145 	 * touching-but-not-overlapping after rounding to device units, pass them in
146 	 * as nearest.
147 	 * Since 1.16
148 	 * Params:
149 	 * inclusive = rectangle to round to pixels inclusively, or NULL. [allow-none]
150 	 * nearest = rectangle to round to nearest pixels, or NULL. [allow-none]
151 	 */
152 	public static void extentsToPixels(PangoRectangle* inclusive, PangoRectangle* nearest)
153 	{
154 		// void pango_extents_to_pixels (PangoRectangle *inclusive,  PangoRectangle *nearest);
155 		pango_extents_to_pixels(inclusive, nearest);
156 	}
157 	
158 	/**
159 	 * Copies a PangoMatrix.
160 	 * Since 1.6
161 	 * Params:
162 	 * matrix = a PangoMatrix, may be NULL
163 	 * Returns: the newly allocated PangoMatrix, which should be freed with pango_matrix_free(), or NULL if matrix was NULL.
164 	 */
165 	public PgMatrix matrixCopy()
166 	{
167 		// PangoMatrix * pango_matrix_copy (const PangoMatrix *matrix);
168 		auto p = pango_matrix_copy(pangoMatrix);
169 		
170 		if(p is null)
171 		{
172 			return null;
173 		}
174 		
175 		return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) p);
176 	}
177 	
178 	/**
179 	 * Free a PangoMatrix created with pango_matrix_copy().
180 	 * Since 1.6
181 	 * Params:
182 	 * matrix = a PangoMatrix, may be NULL
183 	 */
184 	public void matrixFree()
185 	{
186 		// void pango_matrix_free (PangoMatrix *matrix);
187 		pango_matrix_free(pangoMatrix);
188 	}
189 	
190 	/**
191 	 * Changes the transformation represented by matrix to be the
192 	 * transformation given by first translating by (tx, ty)
193 	 * then applying the original transformation.
194 	 * Since 1.6
195 	 * Params:
196 	 * matrix = a PangoMatrix
197 	 * tx = amount to translate in the X direction
198 	 * ty = amount to translate in the Y direction
199 	 */
200 	public void matrixTranslate(double tx, double ty)
201 	{
202 		// void pango_matrix_translate (PangoMatrix *matrix,  double tx,  double ty);
203 		pango_matrix_translate(pangoMatrix, tx, ty);
204 	}
205 	
206 	/**
207 	 * Changes the transformation represented by matrix to be the
208 	 * transformation given by first scaling by sx in the X direction
209 	 * and sy in the Y direction then applying the original
210 	 * transformation.
211 	 * Since 1.6
212 	 * Params:
213 	 * matrix = a PangoMatrix
214 	 * scaleX = amount to scale by in X direction
215 	 * scaleY = amount to scale by in Y direction
216 	 */
217 	public void matrixScale(double scaleX, double scaleY)
218 	{
219 		// void pango_matrix_scale (PangoMatrix *matrix,  double scale_x,  double scale_y);
220 		pango_matrix_scale(pangoMatrix, scaleX, scaleY);
221 	}
222 	
223 	/**
224 	 * Changes the transformation represented by matrix to be the
225 	 * transformation given by first rotating by degrees degrees
226 	 * counter-clockwise then applying the original transformation.
227 	 * Since 1.6
228 	 * Params:
229 	 * matrix = a PangoMatrix
230 	 * degrees = degrees to rotate counter-clockwise
231 	 */
232 	public void matrixRotate(double degrees)
233 	{
234 		// void pango_matrix_rotate (PangoMatrix *matrix,  double degrees);
235 		pango_matrix_rotate(pangoMatrix, degrees);
236 	}
237 	
238 	/**
239 	 * Changes the transformation represented by matrix to be the
240 	 * transformation given by first applying transformation
241 	 * given by new_matrix then applying the original transformation.
242 	 * Since 1.6
243 	 * Params:
244 	 * matrix = a PangoMatrix
245 	 * newMatrix = a PangoMatrix
246 	 */
247 	public void matrixConcat(PgMatrix newMatrix)
248 	{
249 		// void pango_matrix_concat (PangoMatrix *matrix,  const PangoMatrix *new_matrix);
250 		pango_matrix_concat(pangoMatrix, (newMatrix is null) ? null : newMatrix.getPgMatrixStruct());
251 	}
252 	
253 	/**
254 	 * Transforms the point (x, y) by matrix.
255 	 * Since 1.16
256 	 * Params:
257 	 * matrix = a PangoMatrix, or NULL
258 	 * x = in/out X position. [inout]
259 	 * y = in/out Y position. [inout]
260 	 */
261 	public void matrixTransformPoint(ref double x, ref double y)
262 	{
263 		// void pango_matrix_transform_point (const PangoMatrix *matrix,  double *x,  double *y);
264 		pango_matrix_transform_point(pangoMatrix, &x, &y);
265 	}
266 	
267 	/**
268 	 * Transforms the distance vector (dx,dy) by matrix. This is
269 	 * similar to pango_matrix_transform_point() except that the translation
270 	 * components of the transformation are ignored. The calculation of
271 	 * Since 1.16
272 	 * Params:
273 	 * matrix = a PangoMatrix, or NULL
274 	 * dx = in/out X component of a distance vector. [inout]
275 	 * dy = in/out Y component of a distance vector. [inout]
276 	 */
277 	public void matrixTransformDistance(ref double dx, ref double dy)
278 	{
279 		// void pango_matrix_transform_distance (const PangoMatrix *matrix,  double *dx,  double *dy);
280 		pango_matrix_transform_distance(pangoMatrix, &dx, &dy);
281 	}
282 	
283 	/**
284 	 * First transforms rect using matrix, then calculates the bounding box
285 	 * of the transformed rectangle. The rectangle should be in Pango units.
286 	 * This function is useful for example when you want to draw a rotated
287 	 * PangoLayout to an image buffer, and want to know how large the image
288 	 * should be and how much you should shift the layout when rendering.
289 	 * If you have a rectangle in device units (pixels), use
290 	 * pango_matrix_transform_pixel_rectangle().
291 	 * If you have the rectangle in Pango units and want to convert to
292 	 * transformed pixel bounding box, it is more accurate to transform it first
293 	 * (using this function) and pass the result to pango_extents_to_pixels(),
294 	 * first argument, for an inclusive rounded rectangle.
295 	 * However, there are valid reasons that you may want to convert
296 	 * to pixels first and then transform, for example when the transformed
297 	 * coordinates may overflow in Pango units (large matrix translation for
298 	 * example).
299 	 * Since 1.16
300 	 * Params:
301 	 * matrix = a PangoMatrix, or NULL
302 	 * rect = in/out bounding box in Pango units, or NULL. [inout][allow-none]
303 	 */
304 	public void matrixTransformRectangle(PangoRectangle* rect)
305 	{
306 		// void pango_matrix_transform_rectangle (const PangoMatrix *matrix,  PangoRectangle *rect);
307 		pango_matrix_transform_rectangle(pangoMatrix, rect);
308 	}
309 	
310 	/**
311 	 * First transforms the rect using matrix, then calculates the bounding box
312 	 * of the transformed rectangle. The rectangle should be in device units
313 	 * (pixels).
314 	 * This function is useful for example when you want to draw a rotated
315 	 * PangoLayout to an image buffer, and want to know how large the image
316 	 * should be and how much you should shift the layout when rendering.
317 	 * For better accuracy, you should use pango_matrix_transform_rectangle() on
318 	 * original rectangle in Pango units and convert to pixels afterward
319 	 * using pango_extents_to_pixels()'s first argument.
320 	 * Since 1.16
321 	 * Params:
322 	 * matrix = a PangoMatrix, or NULL
323 	 * rect = in/out bounding box in device units, or NULL. [inout][allow-none]
324 	 */
325 	public void matrixTransformPixelRectangle(PangoRectangle* rect)
326 	{
327 		// void pango_matrix_transform_pixel_rectangle  (const PangoMatrix *matrix,  PangoRectangle *rect);
328 		pango_matrix_transform_pixel_rectangle(pangoMatrix, rect);
329 	}
330 	
331 	/**
332 	 * Returns the scale factor of a matrix on the height of the font.
333 	 * That is, the scale factor in the direction perpendicular to the
334 	 * vector that the X coordinate is mapped to.
335 	 * Since 1.12
336 	 * Params:
337 	 * matrix = a PangoMatrix, may be NULL. [allow-none]
338 	 * Returns: the scale factor of matrix on the height of the font, or 1.0 if matrix is NULL.
339 	 */
340 	public double matrixGetFontScaleFactor()
341 	{
342 		// double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix);
343 		return pango_matrix_get_font_scale_factor(pangoMatrix);
344 	}
345 }