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