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 rendering color for the specified part.
276 	 *
277 	 * Params:
278 	 *     part = the part to get the color for
279 	 *
280 	 * Return: the color for the specified part, or
281 	 *     %NULL if it hasn't been set and should be inherited from the
282 	 *     environment.
283 	 *
284 	 * Since: 1.8
285 	 */
286 	public PgColor getColor(PangoRenderPart part)
287 	{
288 		auto p = pango_renderer_get_color(pangoRenderer, part);
289 		
290 		if(p is null)
291 		{
292 			return null;
293 		}
294 		
295 		return ObjectG.getDObject!(PgColor)(cast(PangoColor*) p);
296 	}
297 
298 	/**
299 	 * Gets the layout currently being rendered using @renderer.
300 	 * Calling this function only makes sense from inside a subclass's
301 	 * methods, like in its draw_shape<!---->() for example.
302 	 *
303 	 * The returned layout should not be modified while still being
304 	 * rendered.
305 	 *
306 	 * Return: the layout, or %NULL if no layout is being
307 	 *     rendered using @renderer at this time.
308 	 *
309 	 * Since: 1.20
310 	 */
311 	public PgLayout getLayout()
312 	{
313 		auto p = pango_renderer_get_layout(pangoRenderer);
314 		
315 		if(p is null)
316 		{
317 			return null;
318 		}
319 		
320 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
321 	}
322 
323 	/**
324 	 * Gets the layout line currently being rendered using @renderer.
325 	 * Calling this function only makes sense from inside a subclass's
326 	 * methods, like in its draw_shape<!---->() for example.
327 	 *
328 	 * The returned layout line should not be modified while still being
329 	 * rendered.
330 	 *
331 	 * Return: the layout line, or %NULL if no
332 	 *     layout line is being rendered using @renderer at this time.
333 	 *
334 	 * Since: 1.20
335 	 */
336 	public PgLayoutLine getLayoutLine()
337 	{
338 		auto p = pango_renderer_get_layout_line(pangoRenderer);
339 		
340 		if(p is null)
341 		{
342 			return null;
343 		}
344 		
345 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
346 	}
347 
348 	/**
349 	 * Gets the transformation matrix that will be applied when
350 	 * rendering. See pango_renderer_set_matrix().
351 	 *
352 	 * Return: the matrix, or %NULL if no matrix has been set
353 	 *     (which is the same as the identity matrix). The returned
354 	 *     matrix is owned by Pango and must not be modified or
355 	 *     freed.
356 	 *
357 	 * Since: 1.8
358 	 */
359 	public PgMatrix getMatrix()
360 	{
361 		auto p = pango_renderer_get_matrix(pangoRenderer);
362 		
363 		if(p is null)
364 		{
365 			return null;
366 		}
367 		
368 		return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) p);
369 	}
370 
371 	/**
372 	 * Informs Pango that the way that the rendering is done
373 	 * for @part has changed in a way that would prevent multiple
374 	 * pieces being joined together into one drawing call. For
375 	 * instance, if a subclass of #PangoRenderer was to add a stipple
376 	 * option for drawing underlines, it needs to call
377 	 *
378 	 * <informalexample><programlisting>
379 	 * pango_renderer_part_changed (render, PANGO_RENDER_PART_UNDERLINE);
380 	 * </programlisting></informalexample>
381 	 *
382 	 * When the stipple changes or underlines with different stipples
383 	 * might be joined together. Pango automatically calls this for
384 	 * changes to colors. (See pango_renderer_set_color())
385 	 *
386 	 * Params:
387 	 *     part = the part for which rendering has changed.
388 	 *
389 	 * Since: 1.8
390 	 */
391 	public void partChanged(PangoRenderPart part)
392 	{
393 		pango_renderer_part_changed(pangoRenderer, part);
394 	}
395 
396 	/**
397 	 * Sets the color for part of the rendering.
398 	 *
399 	 * Params:
400 	 *     part = the part to change the color of
401 	 *     color = the new color or %NULL to unset the current color
402 	 *
403 	 * Since: 1.8
404 	 */
405 	public void setColor(PangoRenderPart part, PgColor color)
406 	{
407 		pango_renderer_set_color(pangoRenderer, part, (color is null) ? null : color.getPgColorStruct());
408 	}
409 
410 	/**
411 	 * Sets the transformation matrix that will be applied when rendering.
412 	 *
413 	 * Params:
414 	 *     matrix = a #PangoMatrix, or %NULL to unset any existing matrix.
415 	 *         (No matrix set is the same as setting the identity matrix.)
416 	 *
417 	 * Since: 1.8
418 	 */
419 	public void setMatrix(PgMatrix matrix)
420 	{
421 		pango_renderer_set_matrix(pangoRenderer, (matrix is null) ? null : matrix.getPgMatrixStruct());
422 	}
423 }