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