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 private import gtk.c.functions; 36 public import gtk.c.types; 37 public import gtkc.gtktypes; 38 private import std.algorithm; 39 40 41 /** 42 * The #GtkFontButton is a button which displays the currently selected 43 * font an allows to open a font chooser dialog to change the font. 44 * It is suitable widget for selecting a font in a preference dialog. 45 * 46 * # CSS nodes 47 * 48 * GtkFontButton has a single CSS node with name button and style class .font. 49 */ 50 public class FontButton : Button, FontChooserIF 51 { 52 /** the main Gtk struct */ 53 protected GtkFontButton* gtkFontButton; 54 55 /** Get the main Gtk struct */ 56 public GtkFontButton* getFontButtonStruct(bool transferOwnership = false) 57 { 58 if (transferOwnership) 59 ownedRef = false; 60 return gtkFontButton; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)gtkFontButton; 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (GtkFontButton* gtkFontButton, bool ownedRef = false) 73 { 74 this.gtkFontButton = gtkFontButton; 75 super(cast(GtkButton*)gtkFontButton, ownedRef); 76 } 77 78 // add the FontChooser capabilities 79 mixin FontChooserT!(GtkFontButton); 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 * Returns: 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 * Returns: 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 * Deprecated: Use gtk_font_chooser_get_font() instead 142 * 143 * Returns: an internal copy of the font name which must not be freed. 144 * 145 * Since: 2.4 146 */ 147 public string getFontName() 148 { 149 return Str.toString(gtk_font_button_get_font_name(gtkFontButton)); 150 } 151 152 /** 153 * Returns whether the font size will be shown in the label. 154 * 155 * Returns: whether the font size will be shown in the label. 156 * 157 * Since: 2.4 158 */ 159 public bool getShowSize() 160 { 161 return gtk_font_button_get_show_size(gtkFontButton) != 0; 162 } 163 164 /** 165 * Returns whether the name of the font style will be shown in the label. 166 * 167 * Returns: whether the font style will be shown in the label. 168 * 169 * Since: 2.4 170 */ 171 public bool getShowStyle() 172 { 173 return gtk_font_button_get_show_style(gtkFontButton) != 0; 174 } 175 176 /** 177 * Retrieves the title of the font chooser dialog. 178 * 179 * Returns: an internal copy of the title string which must not be freed. 180 * 181 * Since: 2.4 182 */ 183 public string getTitle() 184 { 185 return Str.toString(gtk_font_button_get_title(gtkFontButton)); 186 } 187 188 /** 189 * Returns whether the selected font is used in the label. 190 * 191 * Returns: whether the selected font is used in the label. 192 * 193 * Since: 2.4 194 */ 195 public bool getUseFont() 196 { 197 return gtk_font_button_get_use_font(gtkFontButton) != 0; 198 } 199 200 /** 201 * Returns whether the selected size is used in the label. 202 * 203 * Returns: whether the selected size is used in the label. 204 * 205 * Since: 2.4 206 */ 207 public bool getUseSize() 208 { 209 return gtk_font_button_get_use_size(gtkFontButton) != 0; 210 } 211 212 /** 213 * Sets or updates the currently-displayed font in font picker dialog. 214 * 215 * Deprecated: Use gtk_font_chooser_set_font() instead 216 * 217 * Params: 218 * fontname = Name of font to display in font chooser dialog 219 * 220 * Returns: %TRUE 221 * 222 * Since: 2.4 223 */ 224 public bool setFontName(string fontname) 225 { 226 return gtk_font_button_set_font_name(gtkFontButton, Str.toStringz(fontname)) != 0; 227 } 228 229 /** 230 * If @show_size is %TRUE, the font size will be displayed along with the name of the selected font. 231 * 232 * Params: 233 * showSize = %TRUE if font size should be displayed in dialog. 234 * 235 * Since: 2.4 236 */ 237 public void setShowSize(bool showSize) 238 { 239 gtk_font_button_set_show_size(gtkFontButton, showSize); 240 } 241 242 /** 243 * If @show_style is %TRUE, the font style will be displayed along with name of the selected font. 244 * 245 * Params: 246 * showStyle = %TRUE if font style should be displayed in label. 247 * 248 * Since: 2.4 249 */ 250 public void setShowStyle(bool showStyle) 251 { 252 gtk_font_button_set_show_style(gtkFontButton, showStyle); 253 } 254 255 /** 256 * Sets the title for the font chooser dialog. 257 * 258 * Params: 259 * title = a string containing the font chooser dialog title 260 * 261 * Since: 2.4 262 */ 263 public void setTitle(string title) 264 { 265 gtk_font_button_set_title(gtkFontButton, Str.toStringz(title)); 266 } 267 268 /** 269 * If @use_font is %TRUE, the font name will be written using the selected font. 270 * 271 * Params: 272 * useFont = If %TRUE, font name will be written using font chosen. 273 * 274 * Since: 2.4 275 */ 276 public void setUseFont(bool useFont) 277 { 278 gtk_font_button_set_use_font(gtkFontButton, useFont); 279 } 280 281 /** 282 * If @use_size is %TRUE, the font name will be written using the selected size. 283 * 284 * Params: 285 * useSize = If %TRUE, font name will be written using the selected size. 286 * 287 * Since: 2.4 288 */ 289 public void setUseSize(bool useSize) 290 { 291 gtk_font_button_set_use_size(gtkFontButton, useSize); 292 } 293 294 /** 295 * The ::font-set signal is emitted when the user selects a font. 296 * When handling this signal, use gtk_font_button_get_font_name() 297 * to find out which font was just selected. 298 * 299 * Note that this signal is only emitted when the user 300 * changes the font. If you need to react to programmatic font changes 301 * as well, use the notify::font signal. 302 * 303 * Since: 2.4 304 */ 305 gulong addOnFontSet(void delegate(FontButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 306 { 307 return Signals.connect(this, "font-set", dlg, connectFlags ^ ConnectFlags.SWAPPED); 308 } 309 }