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