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