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.PgRenderer; 26 27 private import glib.Str; 28 private import gobject.ObjectG; 29 private import pango.PgColor; 30 private import pango.PgFont; 31 private import pango.PgGlyphItem; 32 private import pango.PgGlyphString; 33 private import pango.PgLayout; 34 private import pango.PgLayoutLine; 35 private import pango.PgMatrix; 36 private import pango.c.functions; 37 public import pango.c.types; 38 39 40 /** 41 * `PangoRenderer` is a base class for objects that can render text 42 * provided as `PangoGlyphString` or `PangoLayout`. 43 * 44 * By subclassing `PangoRenderer` and overriding operations such as 45 * @draw_glyphs and @draw_rectangle, renderers for particular font 46 * backends and destinations can be created. 47 * 48 * Since: 1.8 49 */ 50 public class PgRenderer : ObjectG 51 { 52 /** the main Gtk struct */ 53 protected PangoRenderer* pangoRenderer; 54 55 /** Get the main Gtk struct */ 56 public PangoRenderer* getPgRendererStruct(bool transferOwnership = false) 57 { 58 if (transferOwnership) 59 ownedRef = false; 60 return pangoRenderer; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)pangoRenderer; 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (PangoRenderer* pangoRenderer, bool ownedRef = false) 73 { 74 this.pangoRenderer = pangoRenderer; 75 super(cast(GObject*)pangoRenderer, ownedRef); 76 } 77 78 79 /** */ 80 public static GType getType() 81 { 82 return pango_renderer_get_type(); 83 } 84 85 /** 86 * Does initial setup before rendering operations on @renderer. 87 * 88 * [method@Pango.Renderer.deactivate] should be called when done drawing. 89 * Calls such as [method@Pango.Renderer.draw_layout] automatically 90 * activate the layout before drawing on it. Calls to 91 * `pango_renderer_activate()` and `pango_renderer_deactivate()` 92 * can be nested and the renderer will only be initialized and 93 * deinitialized once. 94 * 95 * Since: 1.8 96 */ 97 public void activate() 98 { 99 pango_renderer_activate(pangoRenderer); 100 } 101 102 /** 103 * Cleans up after rendering operations on @renderer. 104 * 105 * See docs for [method@Pango.Renderer.activate]. 106 * 107 * Since: 1.8 108 */ 109 public void deactivate() 110 { 111 pango_renderer_deactivate(pangoRenderer); 112 } 113 114 /** 115 * Draw a squiggly line that approximately covers the given rectangle 116 * in the style of an underline used to indicate a spelling error. 117 * 118 * The width of the underline is rounded to an integer number 119 * of up/down segments and the resulting rectangle is centered 120 * in the original rectangle. 121 * 122 * This should be called while @renderer is already active. 123 * Use [method@Pango.Renderer.activate] to activate a renderer. 124 * 125 * Params: 126 * x = X coordinate of underline, in Pango units in user coordinate system 127 * y = Y coordinate of underline, in Pango units in user coordinate system 128 * width = width of underline, in Pango units in user coordinate system 129 * height = height of underline, in Pango units in user coordinate system 130 * 131 * Since: 1.8 132 */ 133 public void drawErrorUnderline(int x, int y, int width, int height) 134 { 135 pango_renderer_draw_error_underline(pangoRenderer, x, y, width, height); 136 } 137 138 /** 139 * Draws a single glyph with coordinates in device space. 140 * 141 * Params: 142 * font = a #PangoFont 143 * glyph = the glyph index of a single glyph 144 * x = X coordinate of left edge of baseline of glyph 145 * y = Y coordinate of left edge of baseline of glyph 146 * 147 * Since: 1.8 148 */ 149 public void drawGlyph(PgFont font, PangoGlyph glyph, double x, double y) 150 { 151 pango_renderer_draw_glyph(pangoRenderer, (font is null) ? null : font.getPgFontStruct(), glyph, x, y); 152 } 153 154 /** 155 * Draws the glyphs in @glyph_item with the specified `PangoRenderer`, 156 * embedding the text associated with the glyphs in the output if the 157 * output format supports it. 158 * 159 * This is useful for rendering text in PDF. 160 * 161 * Note that this method does not handle attributes in @glyph_item. 162 * If you want colors, shapes and lines handled automatically according 163 * to those attributes, you need to use pango_renderer_draw_layout_line() 164 * or pango_renderer_draw_layout(). 165 * 166 * Note that @text is the start of the text for layout, which is then 167 * indexed by `glyph_item->item->offset`. 168 * 169 * If @text is %NULL, this simply calls [method@Pango.Renderer.draw_glyphs]. 170 * 171 * The default implementation of this method simply falls back to 172 * [method@Pango.Renderer.draw_glyphs]. 173 * 174 * Params: 175 * text = the UTF-8 text that @glyph_item refers to, or %NULL 176 * glyphItem = a `PangoGlyphItem` 177 * x = X position of left edge of baseline, in user space coordinates 178 * in Pango units. 179 * y = Y position of left edge of baseline, in user space coordinates 180 * in Pango units. 181 * 182 * Since: 1.22 183 */ 184 public void drawGlyphItem(string text, PgGlyphItem glyphItem, int x, int y) 185 { 186 pango_renderer_draw_glyph_item(pangoRenderer, Str.toStringz(text), (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), x, y); 187 } 188 189 /** 190 * Draws the glyphs in @glyphs with the specified `PangoRenderer`. 191 * 192 * Params: 193 * font = a `PangoFont` 194 * glyphs = a `PangoGlyphString` 195 * x = X position of left edge of baseline, in user space coordinates 196 * in Pango units. 197 * y = Y position of left edge of baseline, in user space coordinates 198 * in Pango units. 199 * 200 * Since: 1.8 201 */ 202 public void drawGlyphs(PgFont font, PgGlyphString glyphs, int x, int y) 203 { 204 pango_renderer_draw_glyphs(pangoRenderer, (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct(), x, y); 205 } 206 207 /** 208 * Draws @layout with the specified `PangoRenderer`. 209 * 210 * This is equivalent to drawing the lines of the layout, at their 211 * respective positions relative to @x, @y. 212 * 213 * Params: 214 * layout = a `PangoLayout` 215 * x = X position of left edge of baseline, in user space coordinates 216 * in Pango units. 217 * y = Y position of left edge of baseline, in user space coordinates 218 * in Pango units. 219 * 220 * Since: 1.8 221 */ 222 public void drawLayout(PgLayout layout, int x, int y) 223 { 224 pango_renderer_draw_layout(pangoRenderer, (layout is null) ? null : layout.getPgLayoutStruct(), x, y); 225 } 226 227 /** 228 * Draws @line with the specified `PangoRenderer`. 229 * 230 * This draws the glyph items that make up the line, as well as 231 * shapes, backgrounds and lines that are specified by the attributes 232 * of those items. 233 * 234 * Params: 235 * line = a `PangoLayoutLine` 236 * x = X position of left edge of baseline, in user space coordinates 237 * in Pango units. 238 * y = Y position of left edge of baseline, in user space coordinates 239 * in Pango units. 240 * 241 * Since: 1.8 242 */ 243 public void drawLayoutLine(PgLayoutLine line, int x, int y) 244 { 245 pango_renderer_draw_layout_line(pangoRenderer, (line is null) ? null : line.getPgLayoutLineStruct(), x, y); 246 } 247 248 /** 249 * Draws an axis-aligned rectangle in user space coordinates with the 250 * specified `PangoRenderer`. 251 * 252 * This should be called while @renderer is already active. 253 * Use [method@Pango.Renderer.activate] to activate a renderer. 254 * 255 * Params: 256 * part = type of object this rectangle is part of 257 * x = X position at which to draw rectangle, in user space coordinates 258 * in Pango units 259 * y = Y position at which to draw rectangle, in user space coordinates 260 * in Pango units 261 * width = width of rectangle in Pango units 262 * height = height of rectangle in Pango units 263 * 264 * Since: 1.8 265 */ 266 public void drawRectangle(PangoRenderPart part, int x, int y, int width, int height) 267 { 268 pango_renderer_draw_rectangle(pangoRenderer, part, x, y, width, height); 269 } 270 271 /** 272 * Draws a trapezoid with the parallel sides aligned with the X axis 273 * using the given `PangoRenderer`; coordinates are in device space. 274 * 275 * Params: 276 * part = type of object this trapezoid is part of 277 * y1 = Y coordinate of top of trapezoid 278 * x11 = X coordinate of left end of top of trapezoid 279 * x21 = X coordinate of right end of top of trapezoid 280 * y2 = Y coordinate of bottom of trapezoid 281 * x12 = X coordinate of left end of bottom of trapezoid 282 * x22 = X coordinate of right end of bottom of trapezoid 283 * 284 * Since: 1.8 285 */ 286 public void drawTrapezoid(PangoRenderPart part, double y1, double x11, double x21, double y2, double x12, double x22) 287 { 288 pango_renderer_draw_trapezoid(pangoRenderer, part, y1, x11, x21, y2, x12, x22); 289 } 290 291 /** 292 * Gets the current alpha for the specified part. 293 * 294 * Params: 295 * part = the part to get the alpha for 296 * 297 * Returns: the alpha for the specified part, 298 * or 0 if it hasn't been set and should be 299 * inherited from the environment. 300 * 301 * Since: 1.38 302 */ 303 public ushort getAlpha(PangoRenderPart part) 304 { 305 return pango_renderer_get_alpha(pangoRenderer, part); 306 } 307 308 /** 309 * Gets the current rendering color for the specified part. 310 * 311 * Params: 312 * part = the part to get the color for 313 * 314 * Returns: the color for the 315 * specified part, or %NULL if it hasn't been set and should be 316 * inherited from the environment. 317 * 318 * Since: 1.8 319 */ 320 public PgColor getColor(PangoRenderPart part) 321 { 322 auto __p = pango_renderer_get_color(pangoRenderer, part); 323 324 if(__p is null) 325 { 326 return null; 327 } 328 329 return ObjectG.getDObject!(PgColor)(cast(PangoColor*) __p); 330 } 331 332 /** 333 * Gets the layout currently being rendered using @renderer. 334 * 335 * Calling this function only makes sense from inside a subclass's 336 * methods, like in its draw_shape vfunc, for example. 337 * 338 * The returned layout should not be modified while still being 339 * rendered. 340 * 341 * Returns: the layout, or %NULL if 342 * no layout is being rendered using @renderer at this time. 343 * 344 * Since: 1.20 345 */ 346 public PgLayout getLayout() 347 { 348 auto __p = pango_renderer_get_layout(pangoRenderer); 349 350 if(__p is null) 351 { 352 return null; 353 } 354 355 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) __p); 356 } 357 358 /** 359 * Gets the layout line currently being rendered using @renderer. 360 * 361 * Calling this function only makes sense from inside a subclass's 362 * methods, like in its draw_shape vfunc, for example. 363 * 364 * The returned layout line should not be modified while still being 365 * rendered. 366 * 367 * Returns: the layout line, or %NULL 368 * if no layout line is being rendered using @renderer at this time. 369 * 370 * Since: 1.20 371 */ 372 public PgLayoutLine getLayoutLine() 373 { 374 auto __p = pango_renderer_get_layout_line(pangoRenderer); 375 376 if(__p is null) 377 { 378 return null; 379 } 380 381 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) __p); 382 } 383 384 /** 385 * Gets the transformation matrix that will be applied when 386 * rendering. 387 * 388 * See [method@Pango.Renderer.set_matrix]. 389 * 390 * Returns: the matrix, or %NULL if no matrix has 391 * been set (which is the same as the identity matrix). The returned 392 * matrix is owned by Pango and must not be modified or freed. 393 * 394 * Since: 1.8 395 */ 396 public PgMatrix getMatrix() 397 { 398 auto __p = pango_renderer_get_matrix(pangoRenderer); 399 400 if(__p is null) 401 { 402 return null; 403 } 404 405 return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) __p); 406 } 407 408 /** 409 * Informs Pango that the way that the rendering is done 410 * for @part has changed. 411 * 412 * This should be called if the rendering changes in a way that would 413 * prevent multiple pieces being joined together into one drawing call. 414 * For instance, if a subclass of `PangoRenderer` was to add a stipple 415 * option for drawing underlines, it needs to call 416 * 417 * ``` 418 * pango_renderer_part_changed (render, PANGO_RENDER_PART_UNDERLINE); 419 * ``` 420 * 421 * When the stipple changes or underlines with different stipples 422 * might be joined together. Pango automatically calls this for 423 * changes to colors. (See [method@Pango.Renderer.set_color]) 424 * 425 * Params: 426 * part = the part for which rendering has changed. 427 * 428 * Since: 1.8 429 */ 430 public void partChanged(PangoRenderPart part) 431 { 432 pango_renderer_part_changed(pangoRenderer, part); 433 } 434 435 /** 436 * Sets the alpha for part of the rendering. 437 * 438 * Note that the alpha may only be used if a color is 439 * specified for @part as well. 440 * 441 * Params: 442 * part = the part to set the alpha for 443 * alpha = an alpha value between 1 and 65536, or 0 to unset the alpha 444 * 445 * Since: 1.38 446 */ 447 public void setAlpha(PangoRenderPart part, ushort alpha) 448 { 449 pango_renderer_set_alpha(pangoRenderer, part, alpha); 450 } 451 452 /** 453 * Sets the color for part of the rendering. 454 * 455 * Also see [method@Pango.Renderer.set_alpha]. 456 * 457 * Params: 458 * part = the part to change the color of 459 * color = the new color or %NULL to unset the current color 460 * 461 * Since: 1.8 462 */ 463 public void setColor(PangoRenderPart part, PgColor color) 464 { 465 pango_renderer_set_color(pangoRenderer, part, (color is null) ? null : color.getPgColorStruct()); 466 } 467 468 /** 469 * Sets the transformation matrix that will be applied when rendering. 470 * 471 * Params: 472 * matrix = a `PangoMatrix`, or %NULL to unset any existing matrix. 473 * (No matrix set is the same as setting the identity matrix.) 474 * 475 * Since: 1.8 476 */ 477 public void setMatrix(PgMatrix matrix) 478 { 479 pango_renderer_set_matrix(pangoRenderer, (matrix is null) ? null : matrix.getPgMatrixStruct()); 480 } 481 }