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