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.PgCairo;
26 
27 private import cairo.Context;
28 private import cairo.FontOption;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 public  import gtkc.pangotypes;
32 private import pango.PgContext;
33 private import pango.PgFont;
34 private import pango.PgGlyphItem;
35 private import pango.PgGlyphString;
36 private import pango.PgLayout;
37 private import pango.PgLayoutLine;
38 private import pango.c.functions;
39 public  import pango.c.types;
40 
41 
42 /** */
43 public struct PgCairo
44 {
45 
46 	/**
47 	 * Retrieves any font rendering options previously set with
48 	 * pango_cairo_context_set_font_options(). This function does not report options
49 	 * that are derived from the target surface by pango_cairo_update_context()
50 	 *
51 	 * Params:
52 	 *     context = a #PangoContext, from a pangocairo font map
53 	 *
54 	 * Returns: the font options previously set on the
55 	 *     context, or %NULL if no options have been set. This value is
56 	 *     owned by the context and must not be modified or freed.
57 	 *
58 	 * Since: 1.10
59 	 */
60 	public static FontOption contextGetFontOptions(PgContext context)
61 	{
62 		auto p = pango_cairo_context_get_font_options((context is null) ? null : context.getPgContextStruct());
63 
64 		if(p is null)
65 		{
66 			return null;
67 		}
68 
69 		return new FontOption(cast(cairo_font_options_t*) p);
70 	}
71 
72 	/**
73 	 * Gets the resolution for the context. See pango_cairo_context_set_resolution()
74 	 *
75 	 * Params:
76 	 *     context = a #PangoContext, from a pangocairo font map
77 	 *
78 	 * Returns: the resolution in "dots per inch". A negative value will
79 	 *     be returned if no resolution has previously been set.
80 	 *
81 	 * Since: 1.10
82 	 */
83 	public static double contextGetResolution(PgContext context)
84 	{
85 		return pango_cairo_context_get_resolution((context is null) ? null : context.getPgContextStruct());
86 	}
87 
88 	/**
89 	 * Sets callback function for context to use for rendering attributes
90 	 * of type %PANGO_ATTR_SHAPE.  See #PangoCairoShapeRendererFunc for
91 	 * details.
92 	 *
93 	 * Retrieves callback function and associated user data for rendering
94 	 * attributes of type %PANGO_ATTR_SHAPE as set by
95 	 * pango_cairo_context_set_shape_renderer(), if any.
96 	 *
97 	 * Params:
98 	 *     context = a #PangoContext, from a pangocairo font map
99 	 *     data = Pointer to #gpointer to return user data
100 	 *
101 	 * Returns: the shape rendering callback previously
102 	 *     set on the context, or %NULL if no shape rendering callback have
103 	 *     been set.
104 	 *
105 	 * Since: 1.18
106 	 */
107 	public static PangoCairoShapeRendererFunc contextGetShapeRenderer(PgContext context, void** data)
108 	{
109 		return pango_cairo_context_get_shape_renderer((context is null) ? null : context.getPgContextStruct(), data);
110 	}
111 
112 	/**
113 	 * Sets the font options used when rendering text with this context.
114 	 * These options override any options that pango_cairo_update_context()
115 	 * derives from the target surface.
116 	 *
117 	 * Params:
118 	 *     context = a #PangoContext, from a pangocairo font map
119 	 *     options = a #cairo_font_options_t, or %NULL to unset
120 	 *         any previously set options. A copy is made.
121 	 *
122 	 * Since: 1.10
123 	 */
124 	public static void contextSetFontOptions(PgContext context, FontOption options)
125 	{
126 		pango_cairo_context_set_font_options((context is null) ? null : context.getPgContextStruct(), (options is null) ? null : options.getFontOptionStruct());
127 	}
128 
129 	/**
130 	 * Sets the resolution for the context. This is a scale factor between
131 	 * points specified in a #PangoFontDescription and Cairo units. The
132 	 * default value is 96, meaning that a 10 point font will be 13
133 	 * units high. (10 * 96. / 72. = 13.3).
134 	 *
135 	 * Params:
136 	 *     context = a #PangoContext, from a pangocairo font map
137 	 *     dpi = the resolution in "dots per inch". (Physical inches aren't actually
138 	 *         involved; the terminology is conventional.) A 0 or negative value
139 	 *         means to use the resolution from the font map.
140 	 *
141 	 * Since: 1.10
142 	 */
143 	public static void contextSetResolution(PgContext context, double dpi)
144 	{
145 		pango_cairo_context_set_resolution((context is null) ? null : context.getPgContextStruct(), dpi);
146 	}
147 
148 	/**
149 	 * Sets callback function for context to use for rendering attributes
150 	 * of type %PANGO_ATTR_SHAPE.  See #PangoCairoShapeRendererFunc for
151 	 * details.
152 	 *
153 	 * Params:
154 	 *     context = a #PangoContext, from a pangocairo font map
155 	 *     func = Callback function for rendering attributes of
156 	 *         type %PANGO_ATTR_SHAPE, or %NULL to disable shape rendering.
157 	 *     data = User data that will be passed to @func.
158 	 *     dnotify = Callback that will be called when the
159 	 *         context is freed to release @data, or %NULL.
160 	 *
161 	 * Since: 1.18
162 	 */
163 	public static void contextSetShapeRenderer(PgContext context, PangoCairoShapeRendererFunc func, void* data, GDestroyNotify dnotify)
164 	{
165 		pango_cairo_context_set_shape_renderer((context is null) ? null : context.getPgContextStruct(), func, data, dnotify);
166 	}
167 
168 	/**
169 	 * Creates a context object set up to match the current transformation
170 	 * and target surface of the Cairo context.  This context can then be
171 	 * used to create a layout using pango_layout_new().
172 	 *
173 	 * This function is a convenience function that creates a context using
174 	 * the default font map, then updates it to @cr.  If you just need to
175 	 * create a layout for use with @cr and do not need to access #PangoContext
176 	 * directly, you can use pango_cairo_create_layout() instead.
177 	 *
178 	 * Params:
179 	 *     cr = a Cairo context
180 	 *
181 	 * Returns: the newly created #PangoContext. Free with
182 	 *     g_object_unref().
183 	 *
184 	 * Since: 1.22
185 	 */
186 	public static PgContext createContext(Context cr)
187 	{
188 		auto p = pango_cairo_create_context((cr is null) ? null : cr.getContextStruct());
189 
190 		if(p is null)
191 		{
192 			return null;
193 		}
194 
195 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true);
196 	}
197 
198 	/**
199 	 * Creates a layout object set up to match the current transformation
200 	 * and target surface of the Cairo context.  This layout can then be
201 	 * used for text measurement with functions like
202 	 * pango_layout_get_size() or drawing with functions like
203 	 * pango_cairo_show_layout(). If you change the transformation
204 	 * or target surface for @cr, you need to call pango_cairo_update_layout()
205 	 *
206 	 * This function is the most convenient way to use Cairo with Pango,
207 	 * however it is slightly inefficient since it creates a separate
208 	 * #PangoContext object for each layout. This might matter in an
209 	 * application that was laying out large amounts of text.
210 	 *
211 	 * Params:
212 	 *     cr = a Cairo context
213 	 *
214 	 * Returns: the newly created #PangoLayout. Free with
215 	 *     g_object_unref().
216 	 *
217 	 * Since: 1.10
218 	 */
219 	public static PgLayout createLayout(Context cr)
220 	{
221 		auto p = pango_cairo_create_layout((cr is null) ? null : cr.getContextStruct());
222 
223 		if(p is null)
224 		{
225 			return null;
226 		}
227 
228 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p, true);
229 	}
230 
231 	/**
232 	 * Add a squiggly line to the current path in the specified cairo context that
233 	 * approximately covers the given rectangle in the style of an underline used
234 	 * to indicate a spelling error.  (The width of the underline is rounded to an
235 	 * integer number of up/down segments and the resulting rectangle is centered
236 	 * in the original rectangle)
237 	 *
238 	 * Params:
239 	 *     cr = a Cairo context
240 	 *     x = The X coordinate of one corner of the rectangle
241 	 *     y = The Y coordinate of one corner of the rectangle
242 	 *     width = Non-negative width of the rectangle
243 	 *     height = Non-negative height of the rectangle
244 	 *
245 	 * Since: 1.14
246 	 */
247 	public static void errorUnderlinePath(Context cr, double x, double y, double width, double height)
248 	{
249 		pango_cairo_error_underline_path((cr is null) ? null : cr.getContextStruct(), x, y, width, height);
250 	}
251 
252 	/**
253 	 * Adds the glyphs in @glyphs to the current path in the specified
254 	 * cairo context. The origin of the glyphs (the left edge of the baseline)
255 	 * will be at the current point of the cairo context.
256 	 *
257 	 * Params:
258 	 *     cr = a Cairo context
259 	 *     font = a #PangoFont from a #PangoCairoFontMap
260 	 *     glyphs = a #PangoGlyphString
261 	 *
262 	 * Since: 1.10
263 	 */
264 	public static void glyphStringPath(Context cr, PgFont font, PgGlyphString glyphs)
265 	{
266 		pango_cairo_glyph_string_path((cr is null) ? null : cr.getContextStruct(), (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
267 	}
268 
269 	/**
270 	 * Adds the text in #PangoLayoutLine to the current path in the
271 	 * specified cairo context.  The origin of the glyphs (the left edge
272 	 * of the line) will be at the current point of the cairo context.
273 	 *
274 	 * Params:
275 	 *     cr = a Cairo context
276 	 *     line = a #PangoLayoutLine
277 	 *
278 	 * Since: 1.10
279 	 */
280 	public static void layoutLinePath(Context cr, PgLayoutLine line)
281 	{
282 		pango_cairo_layout_line_path((cr is null) ? null : cr.getContextStruct(), (line is null) ? null : line.getPgLayoutLineStruct());
283 	}
284 
285 	/**
286 	 * Adds the text in a #PangoLayout to the current path in the
287 	 * specified cairo context.  The top-left corner of the #PangoLayout
288 	 * will be at the current point of the cairo context.
289 	 *
290 	 * Params:
291 	 *     cr = a Cairo context
292 	 *     layout = a Pango layout
293 	 *
294 	 * Since: 1.10
295 	 */
296 	public static void layoutPath(Context cr, PgLayout layout)
297 	{
298 		pango_cairo_layout_path((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
299 	}
300 
301 	/**
302 	 * Draw a squiggly line in the specified cairo context that approximately
303 	 * covers the given rectangle in the style of an underline used to indicate a
304 	 * spelling error.  (The width of the underline is rounded to an integer
305 	 * number of up/down segments and the resulting rectangle is centered in the
306 	 * original rectangle)
307 	 *
308 	 * Params:
309 	 *     cr = a Cairo context
310 	 *     x = The X coordinate of one corner of the rectangle
311 	 *     y = The Y coordinate of one corner of the rectangle
312 	 *     width = Non-negative width of the rectangle
313 	 *     height = Non-negative height of the rectangle
314 	 *
315 	 * Since: 1.14
316 	 */
317 	public static void showErrorUnderline(Context cr, double x, double y, double width, double height)
318 	{
319 		pango_cairo_show_error_underline((cr is null) ? null : cr.getContextStruct(), x, y, width, height);
320 	}
321 
322 	/**
323 	 * Draws the glyphs in @glyph_item in the specified cairo context,
324 	 * embedding the text associated with the glyphs in the output if the
325 	 * output format supports it (PDF for example), otherwise it acts
326 	 * similar to pango_cairo_show_glyph_string().
327 	 *
328 	 * The origin of the glyphs (the left edge of the baseline) will
329 	 * be drawn at the current point of the cairo context.
330 	 *
331 	 * Note that @text is the start of the text for layout, which is then
332 	 * indexed by <literal>@glyph_item->item->offset</literal>.
333 	 *
334 	 * Params:
335 	 *     cr = a Cairo context
336 	 *     text = the UTF-8 text that @glyph_item refers to
337 	 *     glyphItem = a #PangoGlyphItem
338 	 *
339 	 * Since: 1.22
340 	 */
341 	public static void showGlyphItem(Context cr, string text, PgGlyphItem glyphItem)
342 	{
343 		pango_cairo_show_glyph_item((cr is null) ? null : cr.getContextStruct(), Str.toStringz(text), (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct());
344 	}
345 
346 	/**
347 	 * Draws the glyphs in @glyphs in the specified cairo context.
348 	 * The origin of the glyphs (the left edge of the baseline) will
349 	 * be drawn at the current point of the cairo context.
350 	 *
351 	 * Params:
352 	 *     cr = a Cairo context
353 	 *     font = a #PangoFont from a #PangoCairoFontMap
354 	 *     glyphs = a #PangoGlyphString
355 	 *
356 	 * Since: 1.10
357 	 */
358 	public static void showGlyphString(Context cr, PgFont font, PgGlyphString glyphs)
359 	{
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 a #PangoLayout in the specified cairo context.
365 	 * The top-left corner of the #PangoLayout will be drawn
366 	 * at the current point of the cairo context.
367 	 *
368 	 * Params:
369 	 *     cr = a Cairo context
370 	 *     layout = a Pango layout
371 	 *
372 	 * Since: 1.10
373 	 */
374 	public static void showLayout(Context cr, PgLayout layout)
375 	{
376 		pango_cairo_show_layout((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
377 	}
378 
379 	/**
380 	 * Draws a #PangoLayoutLine in the specified cairo context.
381 	 * The origin of the glyphs (the left edge of the line) will
382 	 * be drawn at the current point of the cairo context.
383 	 *
384 	 * Params:
385 	 *     cr = a Cairo context
386 	 *     line = a #PangoLayoutLine
387 	 *
388 	 * Since: 1.10
389 	 */
390 	public static void showLayoutLine(Context cr, PgLayoutLine line)
391 	{
392 		pango_cairo_show_layout_line((cr is null) ? null : cr.getContextStruct(), (line is null) ? null : line.getPgLayoutLineStruct());
393 	}
394 
395 	/**
396 	 * Updates a #PangoContext previously created for use with Cairo to
397 	 * match the current transformation and target surface of a Cairo
398 	 * context. If any layouts have been created for the context,
399 	 * it's necessary to call pango_layout_context_changed() on those
400 	 * layouts.
401 	 *
402 	 * Params:
403 	 *     cr = a Cairo context
404 	 *     context = a #PangoContext, from a pangocairo font map
405 	 *
406 	 * Since: 1.10
407 	 */
408 	public static void updateContext(Context cr, PgContext context)
409 	{
410 		pango_cairo_update_context((cr is null) ? null : cr.getContextStruct(), (context is null) ? null : context.getPgContextStruct());
411 	}
412 
413 	/**
414 	 * Updates the private #PangoContext of a #PangoLayout created with
415 	 * pango_cairo_create_layout() to match the current transformation
416 	 * and target surface of a Cairo context.
417 	 *
418 	 * Params:
419 	 *     cr = a Cairo context
420 	 *     layout = a #PangoLayout, from pango_cairo_create_layout()
421 	 *
422 	 * Since: 1.10
423 	 */
424 	public static void updateLayout(Context cr, PgLayout layout)
425 	{
426 		pango_cairo_update_layout((cr is null) ? null : cr.getContextStruct(), (layout is null) ? null : layout.getPgLayoutStruct());
427 	}
428 }