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 gtk.FontSelection;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Box;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 public  import gtkc.gtktypes;
35 private import pango.PgFontFace;
36 private import pango.PgFontFamily;
37 
38 
39 /** */
40 public class FontSelection : Box
41 {
42 	/** the main Gtk struct */
43 	protected GtkFontSelection* gtkFontSelection;
44 
45 	/** Get the main Gtk struct */
46 	public GtkFontSelection* getFontSelectionStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return gtkFontSelection;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected override void* getStruct()
55 	{
56 		return cast(void*)gtkFontSelection;
57 	}
58 
59 	protected override void setStruct(GObject* obj)
60 	{
61 		gtkFontSelection = cast(GtkFontSelection*)obj;
62 		super.setStruct(obj);
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GtkFontSelection* gtkFontSelection, bool ownedRef = false)
69 	{
70 		this.gtkFontSelection = gtkFontSelection;
71 		super(cast(GtkBox*)gtkFontSelection, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return gtk_font_selection_get_type();
79 	}
80 
81 	/**
82 	 * Creates a new #GtkFontSelection.
83 	 *
84 	 * Deprecated: Use #GtkFontChooserWidget instead
85 	 *
86 	 * Returns: a new #GtkFontSelection
87 	 *
88 	 * Throws: ConstructionException GTK+ fails to create the object.
89 	 */
90 	public this()
91 	{
92 		auto p = gtk_font_selection_new();
93 
94 		if(p is null)
95 		{
96 			throw new ConstructionException("null returned by new");
97 		}
98 
99 		this(cast(GtkFontSelection*) p);
100 	}
101 
102 	/**
103 	 * Gets the #PangoFontFace representing the selected font group
104 	 * details (i.e. family, slant, weight, width, etc).
105 	 *
106 	 * Deprecated: Use #GtkFontChooser
107 	 *
108 	 * Returns: A #PangoFontFace representing the
109 	 *     selected font group details. The returned object is owned by
110 	 *     @fontsel and must not be modified or freed.
111 	 *
112 	 * Since: 2.14
113 	 */
114 	public PgFontFace getFace()
115 	{
116 		auto p = gtk_font_selection_get_face(gtkFontSelection);
117 
118 		if(p is null)
119 		{
120 			return null;
121 		}
122 
123 		return ObjectG.getDObject!(PgFontFace)(cast(PangoFontFace*) p);
124 	}
125 
126 	/**
127 	 * This returns the #GtkTreeView which lists all styles available for
128 	 * the selected font. For example, “Regular”, “Bold”, etc.
129 	 *
130 	 * Deprecated: Use #GtkFontChooser
131 	 *
132 	 * Returns: A #GtkWidget that is part of @fontsel
133 	 *
134 	 * Since: 2.14
135 	 */
136 	public Widget getFaceList()
137 	{
138 		auto p = gtk_font_selection_get_face_list(gtkFontSelection);
139 
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 
145 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
146 	}
147 
148 	/**
149 	 * Gets the #PangoFontFamily representing the selected font family.
150 	 *
151 	 * Deprecated: Use #GtkFontChooser
152 	 *
153 	 * Returns: A #PangoFontFamily representing the
154 	 *     selected font family. Font families are a collection of font
155 	 *     faces. The returned object is owned by @fontsel and must not
156 	 *     be modified or freed.
157 	 *
158 	 * Since: 2.14
159 	 */
160 	public PgFontFamily getFamily()
161 	{
162 		auto p = gtk_font_selection_get_family(gtkFontSelection);
163 
164 		if(p is null)
165 		{
166 			return null;
167 		}
168 
169 		return ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) p);
170 	}
171 
172 	/**
173 	 * This returns the #GtkTreeView that lists font families, for
174 	 * example, “Sans”, “Serif”, etc.
175 	 *
176 	 * Deprecated: Use #GtkFontChooser
177 	 *
178 	 * Returns: A #GtkWidget that is part of @fontsel
179 	 *
180 	 * Since: 2.14
181 	 */
182 	public Widget getFamilyList()
183 	{
184 		auto p = gtk_font_selection_get_family_list(gtkFontSelection);
185 
186 		if(p is null)
187 		{
188 			return null;
189 		}
190 
191 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
192 	}
193 
194 	/**
195 	 * Gets the currently-selected font name.
196 	 *
197 	 * Note that this can be a different string than what you set with
198 	 * gtk_font_selection_set_font_name(), as the font selection widget may
199 	 * normalize font names and thus return a string with a different structure.
200 	 * For example, “Helvetica Italic Bold 12” could be normalized to
201 	 * “Helvetica Bold Italic 12”. Use pango_font_description_equal()
202 	 * if you want to compare two font descriptions.
203 	 *
204 	 * Deprecated: Use #GtkFontChooser
205 	 *
206 	 * Returns: A string with the name of the current font, or %NULL if
207 	 *     no font is selected. You must free this string with g_free().
208 	 */
209 	public string getFontName()
210 	{
211 		auto retStr = gtk_font_selection_get_font_name(gtkFontSelection);
212 
213 		scope(exit) Str.freeString(retStr);
214 		return Str.toString(retStr);
215 	}
216 
217 	/**
218 	 * This returns the #GtkEntry used to display the font as a preview.
219 	 *
220 	 * Deprecated: Use #GtkFontChooser
221 	 *
222 	 * Returns: A #GtkWidget that is part of @fontsel
223 	 *
224 	 * Since: 2.14
225 	 */
226 	public Widget getPreviewEntry()
227 	{
228 		auto p = gtk_font_selection_get_preview_entry(gtkFontSelection);
229 
230 		if(p is null)
231 		{
232 			return null;
233 		}
234 
235 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
236 	}
237 
238 	/**
239 	 * Gets the text displayed in the preview area.
240 	 *
241 	 * Deprecated: Use #GtkFontChooser
242 	 *
243 	 * Returns: the text displayed in the preview area.
244 	 *     This string is owned by the widget and should not be
245 	 *     modified or freed
246 	 */
247 	public string getPreviewText()
248 	{
249 		return Str.toString(gtk_font_selection_get_preview_text(gtkFontSelection));
250 	}
251 
252 	/**
253 	 * The selected font size.
254 	 *
255 	 * Deprecated: Use #GtkFontChooser
256 	 *
257 	 * Returns: A n integer representing the selected font size,
258 	 *     or -1 if no font size is selected.
259 	 *
260 	 * Since: 2.14
261 	 */
262 	public int getSize()
263 	{
264 		return gtk_font_selection_get_size(gtkFontSelection);
265 	}
266 
267 	/**
268 	 * This returns the #GtkEntry used to allow the user to edit the font
269 	 * number manually instead of selecting it from the list of font sizes.
270 	 *
271 	 * Deprecated: Use #GtkFontChooser
272 	 *
273 	 * Returns: A #GtkWidget that is part of @fontsel
274 	 *
275 	 * Since: 2.14
276 	 */
277 	public Widget getSizeEntry()
278 	{
279 		auto p = gtk_font_selection_get_size_entry(gtkFontSelection);
280 
281 		if(p is null)
282 		{
283 			return null;
284 		}
285 
286 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
287 	}
288 
289 	/**
290 	 * This returns the #GtkTreeView used to list font sizes.
291 	 *
292 	 * Deprecated: Use #GtkFontChooser
293 	 *
294 	 * Returns: A #GtkWidget that is part of @fontsel
295 	 *
296 	 * Since: 2.14
297 	 */
298 	public Widget getSizeList()
299 	{
300 		auto p = gtk_font_selection_get_size_list(gtkFontSelection);
301 
302 		if(p is null)
303 		{
304 			return null;
305 		}
306 
307 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
308 	}
309 
310 	/**
311 	 * Sets the currently-selected font.
312 	 *
313 	 * Note that the @fontsel needs to know the screen in which it will appear
314 	 * for this to work; this can be guaranteed by simply making sure that the
315 	 * @fontsel is inserted in a toplevel window before you call this function.
316 	 *
317 	 * Deprecated: Use #GtkFontChooser
318 	 *
319 	 * Params:
320 	 *     fontname = a font name like “Helvetica 12” or “Times Bold 18”
321 	 *
322 	 * Returns: %TRUE if the font could be set successfully; %FALSE if no
323 	 *     such font exists or if the @fontsel doesn’t belong to a particular
324 	 *     screen yet.
325 	 */
326 	public bool setFontName(string fontname)
327 	{
328 		return gtk_font_selection_set_font_name(gtkFontSelection, Str.toStringz(fontname)) != 0;
329 	}
330 
331 	/**
332 	 * Sets the text displayed in the preview area.
333 	 * The @text is used to show how the selected font looks.
334 	 *
335 	 * Deprecated: Use #GtkFontChooser
336 	 *
337 	 * Params:
338 	 *     text = the text to display in the preview area
339 	 */
340 	public void setPreviewText(string text)
341 	{
342 		gtk_font_selection_set_preview_text(gtkFontSelection, Str.toStringz(text));
343 	}
344 }