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.FontSelection; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.Box; 31 private import gtk.Widget; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 public import gtkc.gtktypes; 35 private import pango.PgFontFace; 36 private import pango.PgFontFamily; 37 38 39 /** */ 40 public class FontSelection : Box 41 { 42 /** the main Gtk struct */ 43 protected GtkFontSelection* gtkFontSelection; 44 45 /** Get the main Gtk struct */ 46 public GtkFontSelection* getFontSelectionStruct(bool transferOwnership = false) 47 { 48 if (transferOwnership) 49 ownedRef = false; 50 return gtkFontSelection; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected override void* getStruct() 55 { 56 return cast(void*)gtkFontSelection; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (GtkFontSelection* gtkFontSelection, bool ownedRef = false) 63 { 64 this.gtkFontSelection = gtkFontSelection; 65 super(cast(GtkBox*)gtkFontSelection, ownedRef); 66 } 67 68 69 /** */ 70 public static GType getType() 71 { 72 return gtk_font_selection_get_type(); 73 } 74 75 /** 76 * Creates a new #GtkFontSelection. 77 * 78 * Deprecated: Use #GtkFontChooserWidget instead 79 * 80 * Returns: a new #GtkFontSelection 81 * 82 * Throws: ConstructionException GTK+ fails to create the object. 83 */ 84 public this() 85 { 86 auto p = gtk_font_selection_new(); 87 88 if(p is null) 89 { 90 throw new ConstructionException("null returned by new"); 91 } 92 93 this(cast(GtkFontSelection*) p); 94 } 95 96 /** 97 * Gets the #PangoFontFace representing the selected font group 98 * details (i.e. family, slant, weight, width, etc). 99 * 100 * Deprecated: Use #GtkFontChooser 101 * 102 * Returns: A #PangoFontFace representing the 103 * selected font group details. The returned object is owned by 104 * @fontsel and must not be modified or freed. 105 * 106 * Since: 2.14 107 */ 108 public PgFontFace getFace() 109 { 110 auto p = gtk_font_selection_get_face(gtkFontSelection); 111 112 if(p is null) 113 { 114 return null; 115 } 116 117 return ObjectG.getDObject!(PgFontFace)(cast(PangoFontFace*) p); 118 } 119 120 /** 121 * This returns the #GtkTreeView which lists all styles available for 122 * the selected font. For example, “Regular”, “Bold”, etc. 123 * 124 * Deprecated: Use #GtkFontChooser 125 * 126 * Returns: A #GtkWidget that is part of @fontsel 127 * 128 * Since: 2.14 129 */ 130 public Widget getFaceList() 131 { 132 auto p = gtk_font_selection_get_face_list(gtkFontSelection); 133 134 if(p is null) 135 { 136 return null; 137 } 138 139 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 140 } 141 142 /** 143 * Gets the #PangoFontFamily representing the selected font family. 144 * 145 * Deprecated: Use #GtkFontChooser 146 * 147 * Returns: A #PangoFontFamily representing the 148 * selected font family. Font families are a collection of font 149 * faces. The returned object is owned by @fontsel and must not 150 * be modified or freed. 151 * 152 * Since: 2.14 153 */ 154 public PgFontFamily getFamily() 155 { 156 auto p = gtk_font_selection_get_family(gtkFontSelection); 157 158 if(p is null) 159 { 160 return null; 161 } 162 163 return ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) p); 164 } 165 166 /** 167 * This returns the #GtkTreeView that lists font families, for 168 * example, “Sans”, “Serif”, etc. 169 * 170 * Deprecated: Use #GtkFontChooser 171 * 172 * Returns: A #GtkWidget that is part of @fontsel 173 * 174 * Since: 2.14 175 */ 176 public Widget getFamilyList() 177 { 178 auto p = gtk_font_selection_get_family_list(gtkFontSelection); 179 180 if(p is null) 181 { 182 return null; 183 } 184 185 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 186 } 187 188 /** 189 * Gets the currently-selected font name. 190 * 191 * Note that this can be a different string than what you set with 192 * gtk_font_selection_set_font_name(), as the font selection widget may 193 * normalize font names and thus return a string with a different structure. 194 * For example, “Helvetica Italic Bold 12” could be normalized to 195 * “Helvetica Bold Italic 12”. Use pango_font_description_equal() 196 * if you want to compare two font descriptions. 197 * 198 * Deprecated: Use #GtkFontChooser 199 * 200 * Returns: A string with the name of the current font, or %NULL if 201 * no font is selected. You must free this string with g_free(). 202 */ 203 public string getFontName() 204 { 205 auto retStr = gtk_font_selection_get_font_name(gtkFontSelection); 206 207 scope(exit) Str.freeString(retStr); 208 return Str.toString(retStr); 209 } 210 211 /** 212 * This returns the #GtkEntry used to display the font as a preview. 213 * 214 * Deprecated: Use #GtkFontChooser 215 * 216 * Returns: A #GtkWidget that is part of @fontsel 217 * 218 * Since: 2.14 219 */ 220 public Widget getPreviewEntry() 221 { 222 auto p = gtk_font_selection_get_preview_entry(gtkFontSelection); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 230 } 231 232 /** 233 * Gets the text displayed in the preview area. 234 * 235 * Deprecated: Use #GtkFontChooser 236 * 237 * Returns: the text displayed in the preview area. 238 * This string is owned by the widget and should not be 239 * modified or freed 240 */ 241 public string getPreviewText() 242 { 243 return Str.toString(gtk_font_selection_get_preview_text(gtkFontSelection)); 244 } 245 246 /** 247 * The selected font size. 248 * 249 * Deprecated: Use #GtkFontChooser 250 * 251 * Returns: A n integer representing the selected font size, 252 * or -1 if no font size is selected. 253 * 254 * Since: 2.14 255 */ 256 public int getSize() 257 { 258 return gtk_font_selection_get_size(gtkFontSelection); 259 } 260 261 /** 262 * This returns the #GtkEntry used to allow the user to edit the font 263 * number manually instead of selecting it from the list of font sizes. 264 * 265 * Deprecated: Use #GtkFontChooser 266 * 267 * Returns: A #GtkWidget that is part of @fontsel 268 * 269 * Since: 2.14 270 */ 271 public Widget getSizeEntry() 272 { 273 auto p = gtk_font_selection_get_size_entry(gtkFontSelection); 274 275 if(p is null) 276 { 277 return null; 278 } 279 280 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 281 } 282 283 /** 284 * This returns the #GtkTreeView used to list font sizes. 285 * 286 * Deprecated: Use #GtkFontChooser 287 * 288 * Returns: A #GtkWidget that is part of @fontsel 289 * 290 * Since: 2.14 291 */ 292 public Widget getSizeList() 293 { 294 auto p = gtk_font_selection_get_size_list(gtkFontSelection); 295 296 if(p is null) 297 { 298 return null; 299 } 300 301 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 302 } 303 304 /** 305 * Sets the currently-selected font. 306 * 307 * Note that the @fontsel needs to know the screen in which it will appear 308 * for this to work; this can be guaranteed by simply making sure that the 309 * @fontsel is inserted in a toplevel window before you call this function. 310 * 311 * Deprecated: Use #GtkFontChooser 312 * 313 * Params: 314 * fontname = a font name like “Helvetica 12” or “Times Bold 18” 315 * 316 * Returns: %TRUE if the font could be set successfully; %FALSE if no 317 * such font exists or if the @fontsel doesn’t belong to a particular 318 * screen yet. 319 */ 320 public bool setFontName(string fontname) 321 { 322 return gtk_font_selection_set_font_name(gtkFontSelection, Str.toStringz(fontname)) != 0; 323 } 324 325 /** 326 * Sets the text displayed in the preview area. 327 * The @text is used to show how the selected font looks. 328 * 329 * Deprecated: Use #GtkFontChooser 330 * 331 * Params: 332 * text = the text to display in the preview area 333 */ 334 public void setPreviewText(string text) 335 { 336 gtk_font_selection_set_preview_text(gtkFontSelection, Str.toStringz(text)); 337 } 338 }