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