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