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