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