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