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  = 
27  * outPack = pango
28  * outFile = PgCairo
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgCairo
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_cairo_
41  * omit structs:
42  * omit prefixes:
43  * 	- pango_cairo_font_map_
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- cairo.Context
49  * 	- cairo.ScaledFont
50  * 	- cairo.FontOption
51  * 	- pango.PgContext
52  * 	- pango.PgFont
53  * 	- pango.PgGlyphItem
54  * 	- pango.PgGlyphString
55  * 	- pango.PgLayout
56  * 	- pango.PgLayoutLine
57  * structWrap:
58  * 	- PangoContext* -> PgContext
59  * 	- PangoFont* -> PgFont
60  * 	- PangoGlyphItem* -> PgGlyphItem
61  * 	- PangoGlyphString* -> PgGlyphString
62  * 	- PangoLayout* -> PgLayout
63  * 	- PangoLayoutLine* -> PgLayoutLine
64  * 	- cairo_font_options_t* -> FontOption
65  * 	- cairo_scaled_font_t* -> ScaledFont
66  * 	- cairo_t* -> Context
67  * module aliases:
68  * local aliases:
69  * overrides:
70  */
71 
72 module pango.PgCairo;
73 
74 public  import gtkc.pangotypes;
75 
76 private import gtkc.pango;
77 private import glib.ConstructionException;
78 private import gobject.ObjectG;
79 
80 
81 private import glib.Str;
82 private import cairo.Context;
83 private import cairo.ScaledFont;
84 private import cairo.FontOption;
85 private import pango.PgContext;
86 private import pango.PgFont;
87 private import pango.PgGlyphItem;
88 private import pango.PgGlyphString;
89 private import pango.PgLayout;
90 private import pango.PgLayoutLine;
91 
92 
93 
94 
95 /**
96  * Description
97  * The Cairo library is a
98  * vector graphics library with a powerful rendering model. It has such
99  * features as anti-aliased primitives, alpha-compositing, and
100  * gradients. Multiple backends for Cairo are available, to allow
101  * rendering to images, to PDF files, and to the screen on X and on other
102  * windowing systems. The functions in this section allow using Pango
103  * to render to Cairo surfaces.
104  * Using Pango with Cairo is straightforward. A PangoContext created
105  * with pango_cairo_font_map_create_context() can be used on any
106  * Cairo context (cairo_t), but needs to be updated to match the
107  * current transformation matrix and target surface of the Cairo context
108  * using pango_cairo_update_context(). The convenience functions
109  * pango_cairo_create_layout() and pango_cairo_update_layout() handle
110  * the common case where the program doesn't need to manipulate the
111  * properties of the PangoContext.
112  * When you get the metrics of a layout or of a piece of a layout using
113  * functions such as pango_layout_get_extents(), the reported metrics
114  * are in user-space coordinates. If a piece of text is 10 units long,
115  * and you call cairo_scale (cr, 2.0), it still is more-or-less 10
116  * units long. However, the results will be affected by hinting
117  * (that is, the process of adjusting the text to look good on the
118  * pixel grid), so you shouldn't assume they are completely independent
119  * of the current transformation matrix. Note that the basic metrics
120  * functions in Pango report results in integer Pango units. To get
121  * to the floating point units used in Cairo divide by PANGO_SCALE.
122  * $(DDOC_COMMENT example)
123  * Figure 2. Output of Example 1, “Using Pango with Cairo”
124  */
125 public class PgCairo
126 {
127 	
128 	/**
129 	 */
130 	
131 	/**
132 	 * Gets the cairo_scaled_font_t used by font.
133 	 * The scaled font can be referenced and kept using
134 	 * cairo_scaled_font_reference().
135 	 * Since 1.18
136 	 * Params:
137 	 * font = a PangoFont from a PangoCairoFontMap
138 	 * Returns: the cairo_scaled_font_t used by font, or NULL if font is NULL.
139 	 */
140 	public static ScaledFont fontGetScaledFont(PangoCairoFont* font)
141 	{
142 		// cairo_scaled_font_t * pango_cairo_font_get_scaled_font (PangoCairoFont *font);
143 		auto p = pango_cairo_font_get_scaled_font(font);
144 		
145 		if(p is null)
146 		{
147 			return null;
148 		}
149 		
150 		return ObjectG.getDObject!(ScaledFont)(cast(cairo_scaled_font_t*) p);
151 	}
152 	
153 	/**
154 	 * Sets the resolution for the context. This is a scale factor between
155 	 * points specified in a PangoFontDescription and Cairo units. The
156 	 * default value is 96, meaning that a 10 point font will be 13
157 	 * units high. (10 * 96. / 72. = 13.3).
158 	 * Since 1.10
159 	 * Params:
160 	 * context = a PangoContext, from a pangocairo font map
161 	 * dpi = the resolution in "dots per inch". (Physical inches aren't actually
162 	 *  involved; the terminology is conventional.) A 0 or negative value
163 	 *  means to use the resolution from the font map.
164 	 */
165 	public static void contextSetResolution(PgContext context, double dpi)
166 	{
167 		// void pango_cairo_context_set_resolution (PangoContext *context,  double dpi);
168 		pango_cairo_context_set_resolution((context is null) ? null : context.getPgContextStruct(), dpi);
169 	}
170 	
171 	/**
172 	 * Gets the resolution for the context. See pango_cairo_context_set_resolution()
173 	 * Since 1.10
174 	 * Params:
175 	 * context = a PangoContext, from a pangocairo font map
176 	 * Returns: the resolution in "dots per inch". A negative value will be returned if no resolution has previously been set.
177 	 */
178 	public static double contextGetResolution(PgContext context)
179 	{
180 		// double pango_cairo_context_get_resolution (PangoContext *context);
181 		return pango_cairo_context_get_resolution((context is null) ? null : context.getPgContextStruct());
182 	}
183 	
184 	/**
185 	 * Sets the font options used when rendering text with this context.
186 	 * These options override any options that pango_cairo_update_context()
187 	 * derives from the target surface.
188 	 * Since 1.10
189 	 * Params:
190 	 * context = a PangoContext, from a pangocairo font map
191 	 * options = a cairo_font_options_t, or NULL to unset any previously set
192 	 *  options. A copy is made.
193 	 */
194 	public static void contextSetFontOptions(PgContext context, FontOption options)
195 	{
196 		// void pango_cairo_context_set_font_options  (PangoContext *context,  const cairo_font_options_t *options);
197 		pango_cairo_context_set_font_options((context is null) ? null : context.getPgContextStruct(), (options is null) ? null : options.getFontOptionStruct());
198 	}
199 	
200 	/**
201 	 * Retrieves any font rendering options previously set with
202 	 * pango_cairo_font_map_set_font_options(). This function does not report options
203 	 * that are derived from the target surface by pango_cairo_update_context()
204 	 * Since 1.10
205 	 * Params:
206 	 * context = a PangoContext, from a pangocairo font map
207 	 * Returns: the font options previously set on the context, or NULL if no options have been set. This value is owned by the context and must not be modified or freed.
208 	 */
209 	public static FontOption contextGetFontOptions(PgContext context)
210 	{
211 		// const cairo_font_options_t * pango_cairo_context_get_font_options  (PangoContext *context);
212 		auto p = pango_cairo_context_get_font_options((context is null) ? null : context.getPgContextStruct());
213 		
214 		if(p is null)
215 		{
216 			return null;
217 		}
218 		
219 		return ObjectG.getDObject!(FontOption)(cast(cairo_font_options_t*) p);
220 	}
221 	
222 	/**
223 	 * Sets callback function for context to use for rendering attributes
224 	 * of type PANGO_ATTR_SHAPE. See PangoCairoShapeRendererFunc for
225 	 * details.
226 	 * Since 1.18
227 	 * Params:
228 	 * context = a PangoContext, from a pangocairo font map
229 	 * func = Callback function for rendering attributes of type
230 	 * PANGO_ATTR_SHAPE, or NULL to disable shape rendering.
231 	 * data = User data that will be passed to func.
232 	 * dnotify = Callback that will be called when the
233 	 *  context is freed to release data, or NULL.
234 	 */
235 	public static void contextSetShapeRenderer(PgContext context, PangoCairoShapeRendererFunc func, void* data, GDestroyNotify dnotify)
236 	{
237 		// void pango_cairo_context_set_shape_renderer  (PangoContext *context,  PangoCairoShapeRendererFunc func,  gpointer data,  GDestroyNotify dnotify);
238 		pango_cairo_context_set_shape_renderer((context is null) ? null : context.getPgContextStruct(), func, data, dnotify);
239 	}
240 	
241 	/**
242 	 * Sets callback function for context to use for rendering attributes
243 	 * of type PANGO_ATTR_SHAPE. See PangoCairoShapeRendererFunc for
244 	 * details.
245 	 * Retrieves callback function and associated user data for rendering
246 	 * attributes of type PANGO_ATTR_SHAPE as set by
247 	 * pango_cairo_context_set_shape_renderer(), if any.
248 	 * Since 1.18
249 	 * Params:
250 	 * context = a PangoContext, from a pangocairo font map
251 	 * data = Pointer to gpointer to return user data
252 	 * Returns: the shape rendering callback previously set on the context, or NULL if no shape rendering callback have been set.
253 	 */
254 	public static PangoCairoShapeRendererFunc contextGetShapeRenderer(PgContext context, void** data)
255 	{
256 		// PangoCairoShapeRendererFunc pango_cairo_context_get_shape_renderer  (PangoContext *context,  gpointer *data);
257 		return pango_cairo_context_get_shape_renderer((context is null) ? null : context.getPgContextStruct(), data);
258 	}
259 	
260 	/**
261 	 * Creates a context object set up to match the current transformation
262 	 * and target surface of the Cairo context. This context can then be
263 	 * used to create a layout using pango_layout_new().
264 	 * This function is a convenience function that creates a context using
265 	 * the default font map, then updates it to cr. If you just need to
266 	 * create a layout for use with cr and do not need to access PangoContext
267 	 * directly, you can use pango_cairo_create_layout() instead.
268 	 * Since 1.22
269 	 * Params:
270 	 * cr = a Cairo context
271 	 * Returns: the newly created PangoContext. Free with g_object_unref().
272 	 */
273 	public static PgContext createContext(Context cr)
274 	{
275 		// PangoContext * pango_cairo_create_context (cairo_t *cr);
276 		auto p = pango_cairo_create_context((cr is null) ? null : cr.getContextStruct());
277 		
278 		if(p is null)
279 		{
280 			return null;
281 		}
282 		
283 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p);
284 	}
285 	
286 	/**
287 	 * Updates a PangoContext previously created for use with Cairo to
288 	 * match the current transformation and target surface of a Cairo
289 	 * context. If any layouts have been created for the context,
290 	 * it's necessary to call pango_layout_context_changed() on those
291 	 * layouts.
292 	 * Since 1.10
293 	 * Params:
294 	 * cr = a Cairo context
295 	 * context = a PangoContext, from a pangocairo font map
296 	 */
297 	public static void updateContext(Context cr, PgContext context)
298 	{
299 		// void pango_cairo_update_context (cairo_t *cr,  PangoContext *context);
300 		pango_cairo_update_context((cr is null) ? null : cr.getContextStruct(), (context is null) ? null : context.getPgContextStruct());
301 	}
302 	
303 	/**
304 	 * Creates a layout object set up to match the current transformation
305 	 * and target surface of the Cairo context. This layout can then be
306 	 * used for text measurement with functions like
307 	 * pango_layout_get_size() or drawing with functions like
308 	 * pango_cairo_show_layout(). If you change the transformation
309 	 * or target surface for cr, you need to call pango_cairo_update_layout()
310 	 * This function is the most convenient way to use Cairo with Pango,
311 	 * however it is slightly inefficient since it creates a separate
312 	 * PangoContext object for each layout. This might matter in an
313 	 * application that was laying out large amounts of text.
314 	 * Since 1.10
315 	 * Params:
316 	 * cr = a Cairo context
317 	 * Returns: the newly created PangoLayout. Free with g_object_unref().
318 	 */
319 	public static PgLayout createLayout(Context cr)
320 	{
321 		// PangoLayout * pango_cairo_create_layout (cairo_t *cr);
322 		auto p = pango_cairo_create_layout((cr is null) ? null : cr.getContextStruct());
323 		
324 		if(p is null)
325 		{
326 			return null;
327 		}
328 		
329 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
330 	}
331 	
332 	/**
333 	 * Updates the private PangoContext of a PangoLayout created with
334 	 * pango_cairo_create_layout() to match the current transformation
335 	 * and target surface of a Cairo context.
336 	 * Since 1.10
337 	 * Params:
338 	 * cr = a Cairo context
339 	 * layout = a PangoLayout, from pango_cairo_create_layout()
340 	 */
341 	public static void updateLayout(Context cr, PgLayout layout)
342 	{
343 		// void pango_cairo_update_layout (cairo_t *cr,  PangoLayout *layout);
344 		pango_cairo_update_layout((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
345 	}
346 	
347 	/**
348 	 * Draws the glyphs in glyphs in the specified cairo context.
349 	 * The origin of the glyphs (the left edge of the baseline) will
350 	 * be drawn at the current point of the cairo context.
351 	 * Since 1.10
352 	 * Params:
353 	 * cr = a Cairo context
354 	 * font = a PangoFont from a PangoCairoFontMap
355 	 * glyphs = a PangoGlyphString
356 	 */
357 	public static void showGlyphString(Context cr, PgFont font, PgGlyphString glyphs)
358 	{
359 		// void pango_cairo_show_glyph_string (cairo_t *cr,  PangoFont *font,  PangoGlyphString *glyphs);
360 		pango_cairo_show_glyph_string((cr is null) ? null : cr.getContextStruct(), (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
361 	}
362 	
363 	/**
364 	 * Draws the glyphs in glyph_item in the specified cairo context,
365 	 * embedding the text associated with the glyphs in the output if the
366 	 * output format supports it (PDF for example), otherwise it acts
367 	 * similar to pango_cairo_show_glyph_string().
368 	 * The origin of the glyphs (the left edge of the baseline) will
369 	 * be drawn at the current point of the cairo context.
370 	 * Note that text is the start of the text for layout, which is then
371 	 * indexed by glyph_item->item->offset.
372 	 * Since 1.22
373 	 * Params:
374 	 * cr = a Cairo context
375 	 * text = the UTF-8 text that glyph_item refers to
376 	 * glyphItem = a PangoGlyphItem
377 	 */
378 	public static void showGlyphItem(Context cr, string text, PgGlyphItem glyphItem)
379 	{
380 		// void pango_cairo_show_glyph_item (cairo_t *cr,  const char *text,  PangoGlyphItem *glyph_item);
381 		pango_cairo_show_glyph_item((cr is null) ? null : cr.getContextStruct(), Str.toStringz(text), (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct());
382 	}
383 	
384 	/**
385 	 * Draws a PangoLayoutLine in the specified cairo context.
386 	 * The origin of the glyphs (the left edge of the line) will
387 	 * be drawn at the current point of the cairo context.
388 	 * Since 1.10
389 	 * Params:
390 	 * cr = a Cairo context
391 	 * line = a PangoLayoutLine
392 	 */
393 	public static void showLayoutLine(Context cr, PgLayoutLine line)
394 	{
395 		// void pango_cairo_show_layout_line (cairo_t *cr,  PangoLayoutLine *line);
396 		pango_cairo_show_layout_line((cr is null) ? null : cr.getContextStruct(), (line is null) ? null : line.getPgLayoutLineStruct());
397 	}
398 	
399 	/**
400 	 * Draws a PangoLayout in the specified cairo context.
401 	 * The top-left corner of the PangoLayout will be drawn
402 	 * at the current point of the cairo context.
403 	 * Since 1.10
404 	 * Params:
405 	 * cr = a Cairo context
406 	 * layout = a Pango layout
407 	 */
408 	public static void showLayout(Context cr, PgLayout layout)
409 	{
410 		// void pango_cairo_show_layout (cairo_t *cr,  PangoLayout *layout);
411 		pango_cairo_show_layout((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
412 	}
413 	
414 	/**
415 	 * Draw a squiggly line in the specified cairo context that approximately
416 	 * covers the given rectangle in the style of an underline used to indicate a
417 	 * spelling error. (The width of the underline is rounded to an integer
418 	 * number of up/down segments and the resulting rectangle is centered in the
419 	 * original rectangle)
420 	 * Since 1.14
421 	 * Params:
422 	 * cr = a Cairo context
423 	 * x = The X coordinate of one corner of the rectangle
424 	 * y = The Y coordinate of one corner of the rectangle
425 	 * width = Non-negative width of the rectangle
426 	 * height = Non-negative height of the rectangle
427 	 */
428 	public static void showErrorUnderline(Context cr, double x, double y, double width, double height)
429 	{
430 		// void pango_cairo_show_error_underline (cairo_t *cr,  double x,  double y,  double width,  double height);
431 		pango_cairo_show_error_underline((cr is null) ? null : cr.getContextStruct(), x, y, width, height);
432 	}
433 	
434 	/**
435 	 * Adds the glyphs in glyphs to the current path in the specified
436 	 * cairo context. The origin of the glyphs (the left edge of the baseline)
437 	 * will be at the current point of the cairo context.
438 	 * Since 1.10
439 	 * Params:
440 	 * cr = a Cairo context
441 	 * font = a PangoFont from a PangoCairoFontMap
442 	 * glyphs = a PangoGlyphString
443 	 */
444 	public static void glyphStringPath(Context cr, PgFont font, PgGlyphString glyphs)
445 	{
446 		// void pango_cairo_glyph_string_path (cairo_t *cr,  PangoFont *font,  PangoGlyphString *glyphs);
447 		pango_cairo_glyph_string_path((cr is null) ? null : cr.getContextStruct(), (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
448 	}
449 	
450 	/**
451 	 * Adds the text in PangoLayoutLine to the current path in the
452 	 * specified cairo context. The origin of the glyphs (the left edge
453 	 * of the line) will be at the current point of the cairo context.
454 	 * Since 1.10
455 	 * Params:
456 	 * cr = a Cairo context
457 	 * line = a PangoLayoutLine
458 	 */
459 	public static void layoutLinePath(Context cr, PgLayoutLine line)
460 	{
461 		// void pango_cairo_layout_line_path (cairo_t *cr,  PangoLayoutLine *line);
462 		pango_cairo_layout_line_path((cr is null) ? null : cr.getContextStruct(), (line is null) ? null : line.getPgLayoutLineStruct());
463 	}
464 	
465 	/**
466 	 * Adds the text in a PangoLayout to the current path in the
467 	 * specified cairo context. The top-left corner of the PangoLayout
468 	 * will be at the current point of the cairo context.
469 	 * Since 1.10
470 	 * Params:
471 	 * cr = a Cairo context
472 	 * layout = a Pango layout
473 	 */
474 	public static void layoutPath(Context cr, PgLayout layout)
475 	{
476 		// void pango_cairo_layout_path (cairo_t *cr,  PangoLayout *layout);
477 		pango_cairo_layout_path((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
478 	}
479 	
480 	/**
481 	 * Add a squiggly line to the current path in the specified cairo context that
482 	 * approximately covers the given rectangle in the style of an underline used
483 	 * to indicate a spelling error. (The width of the underline is rounded to an
484 	 * integer number of up/down segments and the resulting rectangle is centered
485 	 * in the original rectangle)
486 	 * Since 1.14
487 	 * Params:
488 	 * cr = a Cairo context
489 	 * x = The X coordinate of one corner of the rectangle
490 	 * y = The Y coordinate of one corner of the rectangle
491 	 * width = Non-negative width of the rectangle
492 	 * height = Non-negative height of the rectangle
493 	 */
494 	public static void errorUnderlinePath(Context cr, double x, double y, double width, double height)
495 	{
496 		// void pango_cairo_error_underline_path (cairo_t *cr,  double x,  double y,  double width,  double height);
497 		pango_cairo_error_underline_path((cr is null) ? null : cr.getContextStruct(), x, y, width, height);
498 	}
499 }