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