1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module pango.c.renderer; 7 8 import pango.c.layout; 9 import pango.c.font; 10 import pango.c.types; 11 import pango.c.attributes; 12 import pango.c.glyph_item; 13 import pango.c.glyph; 14 15 import glib; 16 import gobject; 17 18 extern(C): 19 20 struct PangoRendererPrivate; 21 22 /** 23 * PangoRenderPart: 24 * @PANGO_RENDER_PART_FOREGROUND: the text itself 25 * @PANGO_RENDER_PART_BACKGROUND: the area behind the text 26 * @PANGO_RENDER_PART_UNDERLINE: underlines 27 * @PANGO_RENDER_PART_STRIKETHROUGH: strikethrough lines 28 * 29 * #PangoRenderPart defines different items to render for such 30 * purposes as setting colors. 31 * 32 * Since: 1.8 33 **/ 34 /* When extending, note N_RENDER_PARTS #define in pango-renderer.c */ 35 enum PangoRenderPart 36 { 37 PANGO_RENDER_PART_FOREGROUND, 38 PANGO_RENDER_PART_BACKGROUND, 39 PANGO_RENDER_PART_UNDERLINE, 40 PANGO_RENDER_PART_STRIKETHROUGH 41 } 42 43 /** 44 * PangoRenderer: 45 * @matrix: the current transformation matrix for the Renderer; may 46 * be %NULL, which should be treated the same as the identity matrix. 47 * 48 * #PangoRenderer is a base class for objects that are used to 49 * render Pango objects such as #PangoGlyphString and 50 * #PangoLayout. 51 * 52 * Since: 1.8 53 **/ 54 struct PangoRenderer 55 { 56 /*< private >*/ 57 GObject parent_instance; 58 59 PangoUnderline underline; 60 gboolean strikethrough; 61 int active_count; 62 63 /*< public >*/ 64 PangoMatrix *matrix; /* May be NULL */ 65 66 /*< private >*/ 67 PangoRendererPrivate *priv; 68 } 69 70 /** 71 * PangoRendererClass: 72 * @draw_glyphs: draws a #PangoGlyphString 73 * @draw_rectangle: draws a rectangle 74 * @draw_error_underline: draws a squiggly line that approximately 75 * covers the given rectangle in the style of an underline used to 76 * indicate a spelling error. 77 * @draw_shape: draw content for a glyph shaped with #PangoAttrShape. 78 * @x, @y are the coordinates of the left edge of the baseline, 79 * in user coordinates. 80 * @draw_trapezoid: draws a trapezoidal filled area 81 * @draw_glyph: draws a single glyph 82 * @part_changed: do renderer specific processing when rendering 83 * attributes change 84 * @begin: Do renderer-specific initialization before drawing 85 * @end: Do renderer-specific cleanup after drawing 86 * @prepare_run: updates the renderer for a new run 87 * @draw_glyph_item: draws a #PangoGlyphItem 88 * 89 * Class structure for #PangoRenderer. 90 * 91 * Since: 1.8 92 **/ 93 struct PangoRendererClass 94 { 95 /*< private >*/ 96 GObjectClass parent_class; 97 98 /* vtable - not signals */ 99 /*< public >*/ 100 101 /* All of the following have default implementations 102 * and take as coordinates user coordinates in Pango units 103 */ 104 void function (PangoRenderer *renderer, 105 PangoFont *font, 106 PangoGlyphString *glyphs, 107 int x, 108 int y) draw_glyphs; 109 void function (PangoRenderer *renderer, 110 PangoRenderPart part, 111 int x, 112 int y, 113 int width, 114 int height) draw_rectangle; 115 void function (PangoRenderer *renderer, 116 int x, 117 int y, 118 int width, 119 int height) draw_error_underline; 120 121 /* Nothing is drawn for shaped glyphs unless this is implemented */ 122 void function (PangoRenderer *renderer, 123 PangoAttrShape *attr, 124 int x, 125 int y) draw_shape; 126 127 /* These two must be implemented and take coordinates in 128 * device space as doubles. 129 */ 130 void function (PangoRenderer *renderer, 131 PangoRenderPart part, 132 double y1_, 133 double x11, 134 double x21, 135 double y2, 136 double x12, 137 double x22) draw_trapezoid; 138 void function (PangoRenderer *renderer, 139 PangoFont *font, 140 PangoGlyph glyph, 141 double x, 142 double y) draw_glyph; 143 144 /* Notification of change in rendering attributes 145 */ 146 void function (PangoRenderer *renderer, 147 PangoRenderPart part) part_changed; 148 149 /* Paired around drawing operations 150 */ 151 void function (PangoRenderer *renderer) begin; 152 void function (PangoRenderer *renderer) end; 153 154 /* Hooks into the details of layout rendering 155 */ 156 void function (PangoRenderer *renderer, 157 PangoLayoutRun *run) prepare_run; 158 159 /* All of the following have default implementations 160 * and take as coordinates user coordinates in Pango units 161 */ 162 void function (PangoRenderer *renderer, 163 const(char) *text, 164 PangoGlyphItem *glyph_item, 165 int x, 166 int y) draw_glyph_item; 167 168 /*< private >*/ 169 170 /* Padding for future expansion */ 171 void function() _pango_reserved2; 172 void function() _pango_reserved3; 173 void function() _pango_reserved4; 174 } 175 176 pure GType pango_renderer_get_type (); 177 178 void pango_renderer_draw_layout (PangoRenderer *renderer, 179 PangoLayout *layout, 180 int x, 181 int y); 182 void pango_renderer_draw_layout_line (PangoRenderer *renderer, 183 PangoLayoutLine *line, 184 int x, 185 int y); 186 void pango_renderer_draw_glyphs (PangoRenderer *renderer, 187 PangoFont *font, 188 PangoGlyphString *glyphs, 189 int x, 190 int y); 191 void pango_renderer_draw_glyph_item (PangoRenderer *renderer, 192 const(char) *text, 193 PangoGlyphItem *glyph_item, 194 int x, 195 int y); 196 void pango_renderer_draw_rectangle (PangoRenderer *renderer, 197 PangoRenderPart part, 198 int x, 199 int y, 200 int width, 201 int height); 202 void pango_renderer_draw_error_underline (PangoRenderer *renderer, 203 int x, 204 int y, 205 int width, 206 int height); 207 void pango_renderer_draw_trapezoid (PangoRenderer *renderer, 208 PangoRenderPart part, 209 double y1_, 210 double x11, 211 double x21, 212 double y2, 213 double x12, 214 double x22); 215 void pango_renderer_draw_glyph (PangoRenderer *renderer, 216 PangoFont *font, 217 PangoGlyph glyph, 218 double x, 219 double y); 220 221 void pango_renderer_activate (PangoRenderer *renderer); 222 void pango_renderer_deactivate (PangoRenderer *renderer); 223 224 void pango_renderer_part_changed (PangoRenderer *renderer, 225 PangoRenderPart part); 226 227 void pango_renderer_set_color (PangoRenderer *renderer, 228 PangoRenderPart part, 229 const(PangoColor) *color); 230 PangoColor *pango_renderer_get_color (PangoRenderer *renderer, 231 PangoRenderPart part); 232 233 void pango_renderer_set_matrix (PangoRenderer *renderer, 234 const(PangoMatrix) *matrix); 235 const(PangoMatrix) *pango_renderer_get_matrix (PangoRenderer *renderer); 236 237 PangoLayout *pango_renderer_get_layout (PangoRenderer *renderer); 238 PangoLayoutLine *pango_renderer_get_layout_line (PangoRenderer *renderer); 239