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