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.FontButton;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.Button;
32 private import gtk.FontChooserIF;
33 private import gtk.FontChooserT;
34 private import gtk.Widget;
35 public  import gtkc.gdktypes;
36 private import gtkc.gtk;
37 public  import gtkc.gtktypes;
38 
39 
40 /**
41  * The #GtkFontButton is a button which displays the currently selected
42  * font an allows to open a font chooser dialog to change the font.
43  * It is suitable widget for selecting a font in a preference dialog.
44  */
45 public class FontButton : Button, FontChooserIF
46 {
47 	/** the main Gtk struct */
48 	protected GtkFontButton* gtkFontButton;
49 
50 	/** Get the main Gtk struct */
51 	public GtkFontButton* getFontButtonStruct()
52 	{
53 		return gtkFontButton;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gtkFontButton;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		gtkFontButton = cast(GtkFontButton*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GtkFontButton* gtkFontButton, bool ownedRef = false)
72 	{
73 		this.gtkFontButton = gtkFontButton;
74 		super(cast(GtkButton*)gtkFontButton, ownedRef);
75 	}
76 
77 	// add the FontChooser capabilities
78 	mixin FontChooserT!(GtkFontButton);
79 
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return gtk_font_button_get_type();
85 	}
86 
87 	/**
88 	 * Creates a new font picker widget.
89 	 *
90 	 * Return: a new font picker widget.
91 	 *
92 	 * Since: 2.4
93 	 *
94 	 * Throws: ConstructionException GTK+ fails to create the object.
95 	 */
96 	public this()
97 	{
98 		auto p = gtk_font_button_new();
99 		
100 		if(p is null)
101 		{
102 			throw new ConstructionException("null returned by new");
103 		}
104 		
105 		this(cast(GtkFontButton*) p);
106 	}
107 
108 	/**
109 	 * Creates a new font picker widget.
110 	 *
111 	 * Params:
112 	 *     fontname = Name of font to display in font chooser dialog
113 	 *
114 	 * Return: a new font picker widget.
115 	 *
116 	 * Since: 2.4
117 	 *
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this(string fontname)
121 	{
122 		auto p = gtk_font_button_new_with_font(Str.toStringz(fontname));
123 		
124 		if(p is null)
125 		{
126 			throw new ConstructionException("null returned by new_with_font");
127 		}
128 		
129 		this(cast(GtkFontButton*) p);
130 	}
131 
132 	/**
133 	 * Retrieves the name of the currently selected font. This name includes
134 	 * style and size information as well. If you want to render something
135 	 * with the font, use this string with pango_font_description_from_string() .
136 	 * If you’re interested in peeking certain values (family name,
137 	 * style, size, weight) just query these properties from the
138 	 * #PangoFontDescription object.
139 	 *
140 	 * Return: an internal copy of the font name which must not be freed.
141 	 *
142 	 * Since: 2.4
143 	 */
144 	public string getFontName()
145 	{
146 		return Str.toString(gtk_font_button_get_font_name(gtkFontButton));
147 	}
148 
149 	/**
150 	 * Returns whether the font size will be shown in the label.
151 	 *
152 	 * Return: whether the font size will be shown in the label.
153 	 *
154 	 * Since: 2.4
155 	 */
156 	public bool getShowSize()
157 	{
158 		return gtk_font_button_get_show_size(gtkFontButton) != 0;
159 	}
160 
161 	/**
162 	 * Returns whether the name of the font style will be shown in the label.
163 	 *
164 	 * Return: whether the font style will be shown in the label.
165 	 *
166 	 * Since: 2.4
167 	 */
168 	public bool getShowStyle()
169 	{
170 		return gtk_font_button_get_show_style(gtkFontButton) != 0;
171 	}
172 
173 	/**
174 	 * Retrieves the title of the font chooser dialog.
175 	 *
176 	 * Return: an internal copy of the title string which must not be freed.
177 	 *
178 	 * Since: 2.4
179 	 */
180 	public string getTitle()
181 	{
182 		return Str.toString(gtk_font_button_get_title(gtkFontButton));
183 	}
184 
185 	/**
186 	 * Returns whether the selected font is used in the label.
187 	 *
188 	 * Return: whether the selected font is used in the label.
189 	 *
190 	 * Since: 2.4
191 	 */
192 	public bool getUseFont()
193 	{
194 		return gtk_font_button_get_use_font(gtkFontButton) != 0;
195 	}
196 
197 	/**
198 	 * Returns whether the selected size is used in the label.
199 	 *
200 	 * Return: whether the selected size is used in the label.
201 	 *
202 	 * Since: 2.4
203 	 */
204 	public bool getUseSize()
205 	{
206 		return gtk_font_button_get_use_size(gtkFontButton) != 0;
207 	}
208 
209 	/**
210 	 * Sets or updates the currently-displayed font in font picker dialog.
211 	 *
212 	 * Params:
213 	 *     fontname = Name of font to display in font chooser dialog
214 	 *
215 	 * Return: %TRUE
216 	 *
217 	 * Since: 2.4
218 	 */
219 	public bool setFontName(string fontname)
220 	{
221 		return gtk_font_button_set_font_name(gtkFontButton, Str.toStringz(fontname)) != 0;
222 	}
223 
224 	/**
225 	 * If @show_size is %TRUE, the font size will be displayed along with the name of the selected font.
226 	 *
227 	 * Params:
228 	 *     showSize = %TRUE if font size should be displayed in dialog.
229 	 *
230 	 * Since: 2.4
231 	 */
232 	public void setShowSize(bool showSize)
233 	{
234 		gtk_font_button_set_show_size(gtkFontButton, showSize);
235 	}
236 
237 	/**
238 	 * If @show_style is %TRUE, the font style will be displayed along with name of the selected font.
239 	 *
240 	 * Params:
241 	 *     showStyle = %TRUE if font style should be displayed in label.
242 	 *
243 	 * Since: 2.4
244 	 */
245 	public void setShowStyle(bool showStyle)
246 	{
247 		gtk_font_button_set_show_style(gtkFontButton, showStyle);
248 	}
249 
250 	/**
251 	 * Sets the title for the font chooser dialog.
252 	 *
253 	 * Params:
254 	 *     title = a string containing the font chooser dialog title
255 	 *
256 	 * Since: 2.4
257 	 */
258 	public void setTitle(string title)
259 	{
260 		gtk_font_button_set_title(gtkFontButton, Str.toStringz(title));
261 	}
262 
263 	/**
264 	 * If @use_font is %TRUE, the font name will be written using the selected font.
265 	 *
266 	 * Params:
267 	 *     useFont = If %TRUE, font name will be written using font chosen.
268 	 *
269 	 * Since: 2.4
270 	 */
271 	public void setUseFont(bool useFont)
272 	{
273 		gtk_font_button_set_use_font(gtkFontButton, useFont);
274 	}
275 
276 	/**
277 	 * If @use_size is %TRUE, the font name will be written using the selected size.
278 	 *
279 	 * Params:
280 	 *     useSize = If %TRUE, font name will be written using the selected size.
281 	 *
282 	 * Since: 2.4
283 	 */
284 	public void setUseSize(bool useSize)
285 	{
286 		gtk_font_button_set_use_size(gtkFontButton, useSize);
287 	}
288 
289 	int[string] connectedSignals;
290 
291 	void delegate(FontButton)[] onFontSetListeners;
292 	/**
293 	 * The ::font-set signal is emitted when the user selects a font.
294 	 * When handling this signal, use gtk_font_button_get_font_name()
295 	 * to find out which font was just selected.
296 	 *
297 	 * Note that this signal is only emitted when the user
298 	 * changes the font. If you need to react to programmatic font changes
299 	 * as well, use the notify::font-name signal.
300 	 *
301 	 * Since: 2.4
302 	 */
303 	void addOnFontSet(void delegate(FontButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
304 	{
305 		if ( "font-set" !in connectedSignals )
306 		{
307 			Signals.connectData(
308 				this,
309 				"font-set",
310 				cast(GCallback)&callBackFontSet,
311 				cast(void*)this,
312 				null,
313 				connectFlags);
314 			connectedSignals["font-set"] = 1;
315 		}
316 		onFontSetListeners ~= dlg;
317 	}
318 	extern(C) static void callBackFontSet(GtkFontButton* fontbuttonStruct, FontButton _fontbutton)
319 	{
320 		foreach ( void delegate(FontButton) dlg; _fontbutton.onFontSetListeners )
321 		{
322 			dlg(_fontbutton);
323 		}
324 	}
325 }