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