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