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