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