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