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.PgFontMetrics;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 public  import gtkc.pangotypes;
30 private import gtkd.Loader;
31 private import pango.c.functions;
32 public  import pango.c.types;
33 
34 
35 /**
36  * A #PangoFontMetrics structure holds the overall metric information
37  * for a font (possibly restricted to a script). The fields of this
38  * structure are private to implementations of a font backend. See
39  * the documentation of the corresponding getters for documentation
40  * of their meaning.
41  */
42 public class PgFontMetrics
43 {
44 	/** the main Gtk struct */
45 	protected PangoFontMetrics* pangoFontMetrics;
46 	protected bool ownedRef;
47 
48 	/** Get the main Gtk struct */
49 	public PangoFontMetrics* getPgFontMetricsStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return pangoFontMetrics;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected void* getStruct()
58 	{
59 		return cast(void*)pangoFontMetrics;
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (PangoFontMetrics* pangoFontMetrics, bool ownedRef = false)
66 	{
67 		this.pangoFontMetrics = pangoFontMetrics;
68 		this.ownedRef = ownedRef;
69 	}
70 
71 	~this ()
72 	{
73 		if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef )
74 			pango_font_metrics_unref(pangoFontMetrics);
75 	}
76 
77 
78 	/** */
79 	public static GType getType()
80 	{
81 		return pango_font_metrics_get_type();
82 	}
83 
84 	/**
85 	 * Creates a new #PangoFontMetrics structure. This is only for
86 	 * internal use by Pango backends and there is no public way
87 	 * to set the fields of the structure.
88 	 *
89 	 * Returns: a newly-created #PangoFontMetrics structure
90 	 *     with a reference count of 1.
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 */
94 	public this()
95 	{
96 		auto p = pango_font_metrics_new();
97 
98 		if(p is null)
99 		{
100 			throw new ConstructionException("null returned by new");
101 		}
102 
103 		this(cast(PangoFontMetrics*) p);
104 	}
105 
106 	/**
107 	 * Gets the approximate character width for a font metrics structure.
108 	 * This is merely a representative value useful, for example, for
109 	 * determining the initial size for a window. Actual characters in
110 	 * text will be wider and narrower than this.
111 	 *
112 	 * Returns: the character width, in Pango units.
113 	 */
114 	public int getApproximateCharWidth()
115 	{
116 		return pango_font_metrics_get_approximate_char_width(pangoFontMetrics);
117 	}
118 
119 	/**
120 	 * Gets the approximate digit width for a font metrics structure.
121 	 * This is merely a representative value useful, for example, for
122 	 * determining the initial size for a window. Actual digits in
123 	 * text can be wider or narrower than this, though this value
124 	 * is generally somewhat more accurate than the result of
125 	 * pango_font_metrics_get_approximate_char_width() for digits.
126 	 *
127 	 * Returns: the digit width, in Pango units.
128 	 */
129 	public int getApproximateDigitWidth()
130 	{
131 		return pango_font_metrics_get_approximate_digit_width(pangoFontMetrics);
132 	}
133 
134 	/**
135 	 * Gets the ascent from a font metrics structure. The ascent is
136 	 * the distance from the baseline to the logical top of a line
137 	 * of text. (The logical top may be above or below the top of the
138 	 * actual drawn ink. It is necessary to lay out the text to figure
139 	 * where the ink will be.)
140 	 *
141 	 * Returns: the ascent, in Pango units.
142 	 */
143 	public int getAscent()
144 	{
145 		return pango_font_metrics_get_ascent(pangoFontMetrics);
146 	}
147 
148 	/**
149 	 * Gets the descent from a font metrics structure. The descent is
150 	 * the distance from the baseline to the logical bottom of a line
151 	 * of text. (The logical bottom may be above or below the bottom of the
152 	 * actual drawn ink. It is necessary to lay out the text to figure
153 	 * where the ink will be.)
154 	 *
155 	 * Returns: the descent, in Pango units.
156 	 */
157 	public int getDescent()
158 	{
159 		return pango_font_metrics_get_descent(pangoFontMetrics);
160 	}
161 
162 	/**
163 	 * Gets the suggested position to draw the strikethrough.
164 	 * The value returned is the distance <emphasis>above</emphasis> the
165 	 * baseline of the top of the strikethrough.
166 	 *
167 	 * Returns: the suggested strikethrough position, in Pango units.
168 	 *
169 	 * Since: 1.6
170 	 */
171 	public int getStrikethroughPosition()
172 	{
173 		return pango_font_metrics_get_strikethrough_position(pangoFontMetrics);
174 	}
175 
176 	/**
177 	 * Gets the suggested thickness to draw for the strikethrough.
178 	 *
179 	 * Returns: the suggested strikethrough thickness, in Pango units.
180 	 *
181 	 * Since: 1.6
182 	 */
183 	public int getStrikethroughThickness()
184 	{
185 		return pango_font_metrics_get_strikethrough_thickness(pangoFontMetrics);
186 	}
187 
188 	/**
189 	 * Gets the suggested position to draw the underline.
190 	 * The value returned is the distance <emphasis>above</emphasis> the
191 	 * baseline of the top of the underline. Since most fonts have
192 	 * underline positions beneath the baseline, this value is typically
193 	 * negative.
194 	 *
195 	 * Returns: the suggested underline position, in Pango units.
196 	 *
197 	 * Since: 1.6
198 	 */
199 	public int getUnderlinePosition()
200 	{
201 		return pango_font_metrics_get_underline_position(pangoFontMetrics);
202 	}
203 
204 	/**
205 	 * Gets the suggested thickness to draw for the underline.
206 	 *
207 	 * Returns: the suggested underline thickness, in Pango units.
208 	 *
209 	 * Since: 1.6
210 	 */
211 	public int getUnderlineThickness()
212 	{
213 		return pango_font_metrics_get_underline_thickness(pangoFontMetrics);
214 	}
215 
216 	/**
217 	 * Increase the reference count of a font metrics structure by one.
218 	 *
219 	 * Returns: @metrics
220 	 */
221 	public PgFontMetrics doref()
222 	{
223 		auto p = pango_font_metrics_ref(pangoFontMetrics);
224 
225 		if(p is null)
226 		{
227 			return null;
228 		}
229 
230 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true);
231 	}
232 
233 	/**
234 	 * Decrease the reference count of a font metrics structure by one. If
235 	 * the result is zero, frees the structure and any associated
236 	 * memory.
237 	 */
238 	public void unref()
239 	{
240 		pango_font_metrics_unref(pangoFontMetrics);
241 	}
242 }