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