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