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
26G_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
35typedef struct _PangoRenderer PangoRenderer;
36typedef struct _PangoRendererClass PangoRendererClass;
37typedef 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 */
52typedef 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 **/
72struct _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 **/
111struct _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
194PANGO_AVAILABLE_IN_1_8
195GType pango_renderer_get_type (void) G_GNUC_CONST;
196
197PANGO_AVAILABLE_IN_1_8
198void pango_renderer_draw_layout (PangoRenderer *renderer,
199 PangoLayout *layout,
200 int x,
201 int y);
202PANGO_AVAILABLE_IN_1_8
203void pango_renderer_draw_layout_line (PangoRenderer *renderer,
204 PangoLayoutLine *line,
205 int x,
206 int y);
207PANGO_AVAILABLE_IN_1_8
208void pango_renderer_draw_glyphs (PangoRenderer *renderer,
209 PangoFont *font,
210 PangoGlyphString *glyphs,
211 int x,
212 int y);
213PANGO_AVAILABLE_IN_1_22
214void pango_renderer_draw_glyph_item (PangoRenderer *renderer,
215 const char *text,
216 PangoGlyphItem *glyph_item,
217 int x,
218 int y);
219PANGO_AVAILABLE_IN_1_8
220void pango_renderer_draw_rectangle (PangoRenderer *renderer,
221 PangoRenderPart part,
222 int x,
223 int y,
224 int width,
225 int height);
226PANGO_AVAILABLE_IN_1_8
227void pango_renderer_draw_error_underline (PangoRenderer *renderer,
228 int x,
229 int y,
230 int width,
231 int height);
232PANGO_AVAILABLE_IN_1_8
233void 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);
241PANGO_AVAILABLE_IN_1_8
242void pango_renderer_draw_glyph (PangoRenderer *renderer,
243 PangoFont *font,
244 PangoGlyph glyph,
245 double x,
246 double y);
247
248PANGO_AVAILABLE_IN_1_8
249void pango_renderer_activate (PangoRenderer *renderer);
250PANGO_AVAILABLE_IN_1_8
251void pango_renderer_deactivate (PangoRenderer *renderer);
252
253PANGO_AVAILABLE_IN_1_8
254void pango_renderer_part_changed (PangoRenderer *renderer,
255 PangoRenderPart part);
256
257PANGO_AVAILABLE_IN_1_8
258void pango_renderer_set_color (PangoRenderer *renderer,
259 PangoRenderPart part,
260 const PangoColor *color);
261PANGO_AVAILABLE_IN_1_8
262PangoColor *pango_renderer_get_color (PangoRenderer *renderer,
263 PangoRenderPart part);
264
265PANGO_AVAILABLE_IN_1_38
266void pango_renderer_set_alpha (PangoRenderer *renderer,
267 PangoRenderPart part,
268 guint16 alpha);
269PANGO_AVAILABLE_IN_1_38
270guint16 pango_renderer_get_alpha (PangoRenderer *renderer,
271 PangoRenderPart part);
272
273PANGO_AVAILABLE_IN_1_8
274void pango_renderer_set_matrix (PangoRenderer *renderer,
275 const PangoMatrix *matrix);
276PANGO_AVAILABLE_IN_1_8
277const PangoMatrix *pango_renderer_get_matrix (PangoRenderer *renderer);
278
279PANGO_AVAILABLE_IN_1_20
280PangoLayout *pango_renderer_get_layout (PangoRenderer *renderer);
281PANGO_AVAILABLE_IN_1_20
282PangoLayoutLine *pango_renderer_get_layout_line (PangoRenderer *renderer);
283
284G_END_DECLS
285
286#endif /* __PANGO_RENDERER_H_ */
287
288