1 | /* Pango |
2 | * pango-renderer.h: Base class for rendering |
3 | * |
4 | * Copyright (C) 2004, Red Hat, Inc. |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public |
17 | * License along with this library; if not, write to the |
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | * Boston, MA 02111-1307, USA. |
20 | */ |
21 | #ifndef __PANGO_RENDERER_H_ |
22 | #define __PANGO_RENDERER_H_ |
23 | |
24 | #include <pango/pango-layout.h> |
25 | |
26 | G_BEGIN_DECLS |
27 | |
28 | #define PANGO_TYPE_RENDERER (pango_renderer_get_type()) |
29 | #define PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_RENDERER, PangoRenderer)) |
30 | #define PANGO_IS_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_RENDERER)) |
31 | #define PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_RENDERER, PangoRendererClass)) |
32 | #define PANGO_IS_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_RENDERER)) |
33 | #define PANGO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_RENDERER, PangoRendererClass)) |
34 | |
35 | typedef struct _PangoRenderer PangoRenderer; |
36 | typedef struct _PangoRendererClass PangoRendererClass; |
37 | typedef struct _PangoRendererPrivate PangoRendererPrivate; |
38 | |
39 | /** |
40 | * PangoRenderPart: |
41 | * @PANGO_RENDER_PART_FOREGROUND: the text itself |
42 | * @PANGO_RENDER_PART_BACKGROUND: the area behind the text |
43 | * @PANGO_RENDER_PART_UNDERLINE: underlines |
44 | * @PANGO_RENDER_PART_STRIKETHROUGH: strikethrough lines |
45 | * |
46 | * #PangoRenderPart defines different items to render for such |
47 | * purposes as setting colors. |
48 | * |
49 | * Since: 1.8 |
50 | **/ |
51 | /* When extending, note N_RENDER_PARTS #define in pango-renderer.c */ |
52 | typedef enum |
53 | { |
54 | PANGO_RENDER_PART_FOREGROUND, |
55 | PANGO_RENDER_PART_BACKGROUND, |
56 | PANGO_RENDER_PART_UNDERLINE, |
57 | PANGO_RENDER_PART_STRIKETHROUGH |
58 | } PangoRenderPart; |
59 | |
60 | /** |
61 | * PangoRenderer: |
62 | * @matrix: (nullable): the current transformation matrix for |
63 | * the Renderer; may be %NULL, which should be treated the |
64 | * same as the identity matrix. |
65 | * |
66 | * #PangoRenderer is a base class for objects that are used to |
67 | * render Pango objects such as #PangoGlyphString and |
68 | * #PangoLayout. |
69 | * |
70 | * Since: 1.8 |
71 | **/ |
72 | struct _PangoRenderer |
73 | { |
74 | /*< private >*/ |
75 | GObject parent_instance; |
76 | |
77 | PangoUnderline underline; |
78 | gboolean strikethrough; |
79 | int active_count; |
80 | |
81 | /*< public >*/ |
82 | PangoMatrix *matrix; /* May be NULL */ |
83 | |
84 | /*< private >*/ |
85 | PangoRendererPrivate *priv; |
86 | }; |
87 | |
88 | /** |
89 | * PangoRendererClass: |
90 | * @draw_glyphs: draws a #PangoGlyphString |
91 | * @draw_rectangle: draws a rectangle |
92 | * @draw_error_underline: draws a squiggly line that approximately |
93 | * covers the given rectangle in the style of an underline used to |
94 | * indicate a spelling error. |
95 | * @draw_shape: draw content for a glyph shaped with #PangoAttrShape. |
96 | * @x, @y are the coordinates of the left edge of the baseline, |
97 | * in user coordinates. |
98 | * @draw_trapezoid: draws a trapezoidal filled area |
99 | * @draw_glyph: draws a single glyph |
100 | * @part_changed: do renderer specific processing when rendering |
101 | * attributes change |
102 | * @begin: Do renderer-specific initialization before drawing |
103 | * @end: Do renderer-specific cleanup after drawing |
104 | * @prepare_run: updates the renderer for a new run |
105 | * @draw_glyph_item: draws a #PangoGlyphItem |
106 | * |
107 | * Class structure for #PangoRenderer. |
108 | * |
109 | * Since: 1.8 |
110 | **/ |
111 | struct _PangoRendererClass |
112 | { |
113 | /*< private >*/ |
114 | GObjectClass parent_class; |
115 | |
116 | /* vtable - not signals */ |
117 | /*< public >*/ |
118 | |
119 | /* All of the following have default implementations |
120 | * and take as coordinates user coordinates in Pango units |
121 | */ |
122 | void (*draw_glyphs) (PangoRenderer *renderer, |
123 | PangoFont *font, |
124 | PangoGlyphString *glyphs, |
125 | int x, |
126 | int y); |
127 | void (*draw_rectangle) (PangoRenderer *renderer, |
128 | PangoRenderPart part, |
129 | int x, |
130 | int y, |
131 | int width, |
132 | int height); |
133 | void (*draw_error_underline) (PangoRenderer *renderer, |
134 | int x, |
135 | int y, |
136 | int width, |
137 | int height); |
138 | |
139 | /* Nothing is drawn for shaped glyphs unless this is implemented */ |
140 | void (*draw_shape) (PangoRenderer *renderer, |
141 | PangoAttrShape *attr, |
142 | int x, |
143 | int y); |
144 | |
145 | /* These two must be implemented and take coordinates in |
146 | * device space as doubles. |
147 | */ |
148 | void (*draw_trapezoid) (PangoRenderer *renderer, |
149 | PangoRenderPart part, |
150 | double y1_, |
151 | double x11, |
152 | double x21, |
153 | double y2, |
154 | double x12, |
155 | double x22); |
156 | void (*draw_glyph) (PangoRenderer *renderer, |
157 | PangoFont *font, |
158 | PangoGlyph glyph, |
159 | double x, |
160 | double y); |
161 | |
162 | /* Notification of change in rendering attributes |
163 | */ |
164 | void (*part_changed) (PangoRenderer *renderer, |
165 | PangoRenderPart part); |
166 | |
167 | /* Paired around drawing operations |
168 | */ |
169 | void (*begin) (PangoRenderer *renderer); |
170 | void (*end) (PangoRenderer *renderer); |
171 | |
172 | /* Hooks into the details of layout rendering |
173 | */ |
174 | void (*prepare_run) (PangoRenderer *renderer, |
175 | PangoLayoutRun *run); |
176 | |
177 | /* All of the following have default implementations |
178 | * and take as coordinates user coordinates in Pango units |
179 | */ |
180 | void (*draw_glyph_item) (PangoRenderer *renderer, |
181 | const char *text, |
182 | PangoGlyphItem *glyph_item, |
183 | int x, |
184 | int y); |
185 | |
186 | /*< private >*/ |
187 | |
188 | /* Padding for future expansion */ |
189 | void (*_pango_reserved2) (void); |
190 | void (*_pango_reserved3) (void); |
191 | void (*_pango_reserved4) (void); |
192 | }; |
193 | |
194 | PANGO_AVAILABLE_IN_1_8 |
195 | GType pango_renderer_get_type (void) G_GNUC_CONST; |
196 | |
197 | PANGO_AVAILABLE_IN_1_8 |
198 | void pango_renderer_draw_layout (PangoRenderer *renderer, |
199 | PangoLayout *layout, |
200 | int x, |
201 | int y); |
202 | PANGO_AVAILABLE_IN_1_8 |
203 | void pango_renderer_draw_layout_line (PangoRenderer *renderer, |
204 | PangoLayoutLine *line, |
205 | int x, |
206 | int y); |
207 | PANGO_AVAILABLE_IN_1_8 |
208 | void pango_renderer_draw_glyphs (PangoRenderer *renderer, |
209 | PangoFont *font, |
210 | PangoGlyphString *glyphs, |
211 | int x, |
212 | int y); |
213 | PANGO_AVAILABLE_IN_1_22 |
214 | void pango_renderer_draw_glyph_item (PangoRenderer *renderer, |
215 | const char *text, |
216 | PangoGlyphItem *glyph_item, |
217 | int x, |
218 | int y); |
219 | PANGO_AVAILABLE_IN_1_8 |
220 | void pango_renderer_draw_rectangle (PangoRenderer *renderer, |
221 | PangoRenderPart part, |
222 | int x, |
223 | int y, |
224 | int width, |
225 | int height); |
226 | PANGO_AVAILABLE_IN_1_8 |
227 | void pango_renderer_draw_error_underline (PangoRenderer *renderer, |
228 | int x, |
229 | int y, |
230 | int width, |
231 | int height); |
232 | PANGO_AVAILABLE_IN_1_8 |
233 | void pango_renderer_draw_trapezoid (PangoRenderer *renderer, |
234 | PangoRenderPart part, |
235 | double y1_, |
236 | double x11, |
237 | double x21, |
238 | double y2, |
239 | double x12, |
240 | double x22); |
241 | PANGO_AVAILABLE_IN_1_8 |
242 | void pango_renderer_draw_glyph (PangoRenderer *renderer, |
243 | PangoFont *font, |
244 | PangoGlyph glyph, |
245 | double x, |
246 | double y); |
247 | |
248 | PANGO_AVAILABLE_IN_1_8 |
249 | void pango_renderer_activate (PangoRenderer *renderer); |
250 | PANGO_AVAILABLE_IN_1_8 |
251 | void pango_renderer_deactivate (PangoRenderer *renderer); |
252 | |
253 | PANGO_AVAILABLE_IN_1_8 |
254 | void pango_renderer_part_changed (PangoRenderer *renderer, |
255 | PangoRenderPart part); |
256 | |
257 | PANGO_AVAILABLE_IN_1_8 |
258 | void pango_renderer_set_color (PangoRenderer *renderer, |
259 | PangoRenderPart part, |
260 | const PangoColor *color); |
261 | PANGO_AVAILABLE_IN_1_8 |
262 | PangoColor *pango_renderer_get_color (PangoRenderer *renderer, |
263 | PangoRenderPart part); |
264 | |
265 | PANGO_AVAILABLE_IN_1_38 |
266 | void pango_renderer_set_alpha (PangoRenderer *renderer, |
267 | PangoRenderPart part, |
268 | guint16 alpha); |
269 | PANGO_AVAILABLE_IN_1_38 |
270 | guint16 pango_renderer_get_alpha (PangoRenderer *renderer, |
271 | PangoRenderPart part); |
272 | |
273 | PANGO_AVAILABLE_IN_1_8 |
274 | void pango_renderer_set_matrix (PangoRenderer *renderer, |
275 | const PangoMatrix *matrix); |
276 | PANGO_AVAILABLE_IN_1_8 |
277 | const PangoMatrix *pango_renderer_get_matrix (PangoRenderer *renderer); |
278 | |
279 | PANGO_AVAILABLE_IN_1_20 |
280 | PangoLayout *pango_renderer_get_layout (PangoRenderer *renderer); |
281 | PANGO_AVAILABLE_IN_1_20 |
282 | PangoLayoutLine *pango_renderer_get_layout_line (PangoRenderer *renderer); |
283 | |
284 | G_END_DECLS |
285 | |
286 | #endif /* __PANGO_RENDERER_H_ */ |
287 | |
288 | |