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.PgCairoFontMap;
26 
27 private import cairo.ScaledFont;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 public  import gtkc.pangotypes;
31 private import pango.PgFontMap;
32 private import pango.c.functions;
33 public  import pango.c.types;
34 
35 
36 /**
37  * #PangoCairoFontMap is an interface exported by font maps for
38  * use with Cairo. The actual type of the font map will depend
39  * on the particular font technology Cairo was compiled to use.
40  *
41  * Since: 1.10
42  */
43 public class PgCairoFontMap : PgFontMap
44 {
45 	/** the main Gtk struct */
46 	protected PangoCairoFontMap* pangoCairoFontMap;
47 
48 	/** Get the main Gtk struct */
49 	public PangoCairoFontMap* getPgCairoFontMapStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return pangoCairoFontMap;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)pangoCairoFontMap;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		pangoCairoFontMap = cast(PangoCairoFontMap*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (PangoCairoFontMap* pangoCairoFontMap, bool ownedRef = false)
72 	{
73 		this.pangoCairoFontMap = pangoCairoFontMap;
74 		super(cast(PangoFontMap*)pangoCairoFontMap, ownedRef);
75 	}
76 
77 
78 	/** */
79 	public static GType getType()
80 	{
81 		return pango_cairo_font_get_type();
82 	}
83 
84 	/**
85 	 * Gets a default #PangoCairoFontMap to use with Cairo.
86 	 *
87 	 * Note that the type of the returned object will depend
88 	 * on the particular font backend Cairo was compiled to use;
89 	 * You generally should only use the #PangoFontMap and
90 	 * #PangoCairoFontMap interfaces on the returned object.
91 	 *
92 	 * The default Cairo fontmap can be changed by using
93 	 * pango_cairo_font_map_set_default().  This can be used to
94 	 * change the Cairo font backend that the default fontmap
95 	 * uses for example.
96 	 *
97 	 * Note that since Pango 1.32.6, the default fontmap is per-thread.
98 	 * Each thread gets its own default fontmap.  In this way,
99 	 * PangoCairo can be used safely from multiple threads.
100 	 *
101 	 * Returns: the default PangoCairo fontmap
102 	 *     for the current thread. This object is owned by Pango and must not be freed.
103 	 *
104 	 * Since: 1.10
105 	 */
106 	public static PgFontMap getDefault()
107 	{
108 		auto p = pango_cairo_font_map_get_default();
109 
110 		if(p is null)
111 		{
112 			return null;
113 		}
114 
115 		return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p);
116 	}
117 
118 	/**
119 	 * Creates a new #PangoCairoFontMap object; a fontmap is used
120 	 * to cache information about available fonts, and holds
121 	 * certain global parameters such as the resolution.
122 	 * In most cases, you can use pango_cairo_font_map_get_default()
123 	 * instead.
124 	 *
125 	 * Note that the type of the returned object will depend
126 	 * on the particular font backend Cairo was compiled to use;
127 	 * You generally should only use the #PangoFontMap and
128 	 * #PangoCairoFontMap interfaces on the returned object.
129 	 *
130 	 * You can override the type of backend returned by using an
131 	 * environment variable %PANGOCAIRO_BACKEND.  Supported types,
132 	 * based on your build, are fc (fontconfig), win32, and coretext.
133 	 * If requested type is not available, NULL is returned. Ie.
134 	 * this is only useful for testing, when at least two backends
135 	 * are compiled in.
136 	 *
137 	 * Returns: the newly allocated #PangoFontMap,
138 	 *     which should be freed with g_object_unref().
139 	 *
140 	 * Since: 1.10
141 	 *
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this()
145 	{
146 		auto p = pango_cairo_font_map_new();
147 
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by new");
151 		}
152 
153 		this(cast(PangoCairoFontMap*) p, true);
154 	}
155 
156 	/**
157 	 * Creates a new #PangoCairoFontMap object of the type suitable
158 	 * to be used with cairo font backend of type @fonttype.
159 	 *
160 	 * In most cases one should simply use @pango_cairo_font_map_new(),
161 	 * or in fact in most of those cases, just use
162 	 * @pango_cairo_font_map_get_default().
163 	 *
164 	 * Params:
165 	 *     fonttype = desired #cairo_font_type_t
166 	 *
167 	 * Returns: the newly allocated
168 	 *     #PangoFontMap of suitable type which should be freed
169 	 *     with g_object_unref(), or %NULL if the requested
170 	 *     cairo font backend is not supported / compiled in.
171 	 *
172 	 * Since: 1.18
173 	 *
174 	 * Throws: ConstructionException GTK+ fails to create the object.
175 	 */
176 	public this(cairo_font_type_t fonttype)
177 	{
178 		auto p = pango_cairo_font_map_new_for_font_type(fonttype);
179 
180 		if(p is null)
181 		{
182 			throw new ConstructionException("null returned by new_for_font_type");
183 		}
184 
185 		this(cast(PangoCairoFontMap*) p, true);
186 	}
187 
188 	/**
189 	 * Gets the type of Cairo font backend that @fontmap uses.
190 	 *
191 	 * Returns: the #cairo_font_type_t cairo font backend type
192 	 *
193 	 * Since: 1.18
194 	 */
195 	public cairo_font_type_t getFontType()
196 	{
197 		return pango_cairo_font_map_get_font_type(cast(PangoCairoFontMap*)pangoCairoFontMap);
198 	}
199 
200 	/**
201 	 * Gets the resolution for the fontmap. See pango_cairo_font_map_set_resolution()
202 	 *
203 	 * Returns: the resolution in "dots per inch"
204 	 *
205 	 * Since: 1.10
206 	 */
207 	public double getResolution()
208 	{
209 		return pango_cairo_font_map_get_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap);
210 	}
211 
212 	/**
213 	 * Sets a default #PangoCairoFontMap to use with Cairo.
214 	 *
215 	 * This can be used to change the Cairo font backend that the
216 	 * default fontmap uses for example.  The old default font map
217 	 * is unreffed and the new font map referenced.
218 	 *
219 	 * Note that since Pango 1.32.6, the default fontmap is per-thread.
220 	 * This function only changes the default fontmap for
221 	 * the current thread.   Default fontmaps of exisiting threads
222 	 * are not changed.  Default fontmaps of any new threads will
223 	 * still be created using pango_cairo_font_map_new().
224 	 *
225 	 * A value of %NULL for @fontmap will cause the current default
226 	 * font map to be released and a new default font
227 	 * map to be created on demand, using pango_cairo_font_map_new().
228 	 *
229 	 * Since: 1.22
230 	 */
231 	public void setDefault()
232 	{
233 		pango_cairo_font_map_set_default(cast(PangoCairoFontMap*)pangoCairoFontMap);
234 	}
235 
236 	/**
237 	 * Sets the resolution for the fontmap. This is a scale factor between
238 	 * points specified in a #PangoFontDescription and Cairo units. The
239 	 * default value is 96, meaning that a 10 point font will be 13
240 	 * units high. (10 * 96. / 72. = 13.3).
241 	 *
242 	 * Params:
243 	 *     dpi = the resolution in "dots per inch". (Physical inches aren't actually
244 	 *         involved; the terminology is conventional.)
245 	 *
246 	 * Since: 1.10
247 	 */
248 	public void setResolution(double dpi)
249 	{
250 		pango_cairo_font_map_set_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap, dpi);
251 	}
252 
253 	/**
254 	 * Gets the #cairo_scaled_font_t used by @font.
255 	 * The scaled font can be referenced and kept using
256 	 * cairo_scaled_font_reference().
257 	 *
258 	 * Returns: the #cairo_scaled_font_t used by @font,
259 	 *     or %NULL if @font is %NULL.
260 	 *
261 	 * Since: 1.18
262 	 */
263 	public ScaledFont getScaledFont()
264 	{
265 		auto p = pango_cairo_font_get_scaled_font(cast(PangoCairoFont*)pangoCairoFontMap);
266 
267 		if(p is null)
268 		{
269 			return null;
270 		}
271 
272 		return new ScaledFont(cast(cairo_scaled_font_t*) p);
273 	}
274 }