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