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