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