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