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 = GtkFontChooser.html 27 * outPack = gtk 28 * outFile = FontChooserT 29 * strct = GtkFontChooser 30 * realStrct= 31 * ctorStrct= 32 * clss = FontChooserT 33 * interf = FontChooserIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - gtk_font_chooser_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - pango.PgFontDescription 49 * - pango.PgFontFace 50 * - pango.PgFontFamily 51 * structWrap: 52 * - PangoFontDescription* -> PgFontDescription 53 * - PangoFontFace* -> PgFontFace 54 * - PangoFontFamily* -> PgFontFamily 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.FontChooserT; 61 62 public import gtkc.gtktypes; 63 64 public import gtkc.gtk; 65 public import glib.ConstructionException; 66 public import gobject.ObjectG; 67 68 public import gobject.Signals; 69 public import gtkc.gdktypes; 70 71 public import glib.Str; 72 public import pango.PgFontDescription; 73 public import pango.PgFontFace; 74 public import pango.PgFontFamily; 75 76 77 78 79 /** 80 * GtkFontChooser is an interface that can be implemented by widgets 81 * displaying the list of fonts. In GTK+, the main objects 82 * that implement this interface are GtkFontChooserWidget, 83 * GtkFontChooserDialog and GtkFontButton. 84 */ 85 public template FontChooserT(TStruct) 86 { 87 88 /** the main Gtk struct */ 89 protected GtkFontChooser* gtkFontChooser; 90 91 92 public GtkFontChooser* getFontChooserTStruct() 93 { 94 return cast(GtkFontChooser*)getStruct(); 95 } 96 97 98 /** 99 */ 100 int[string] connectedSignals; 101 102 void delegate(string, FontChooserIF)[] _onFontActivatedListeners; 103 @property void delegate(string, FontChooserIF)[] onFontActivatedListeners() 104 { 105 return _onFontActivatedListeners; 106 } 107 /** 108 * Emitted when a font is activated. 109 * This usually happens when the user double clicks an item, 110 * or an item is selected and the user presses one of the keys 111 * Space, Shift+Space, Return or Enter. 112 * See Also 113 * GtkFontChooserDialog, GtkFontChooserWidget, GtkFontButton 114 */ 115 void addOnFontActivated(void delegate(string, FontChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 116 { 117 if ( !("font-activated" in connectedSignals) ) 118 { 119 Signals.connectData( 120 getStruct(), 121 "font-activated", 122 cast(GCallback)&callBackFontActivated, 123 cast(void*)cast(FontChooserIF)this, 124 null, 125 connectFlags); 126 connectedSignals["font-activated"] = 1; 127 } 128 _onFontActivatedListeners ~= dlg; 129 } 130 extern(C) static void callBackFontActivated(GtkFontChooser* selfStruct, gchar* fontname, FontChooserIF _fontChooserIF) 131 { 132 foreach ( void delegate(string, FontChooserIF) dlg ; _fontChooserIF.onFontActivatedListeners ) 133 { 134 dlg(Str.toString(fontname), _fontChooserIF); 135 } 136 } 137 138 139 /** 140 * Gets the PangoFontFamily representing the selected font family. 141 * Font families are a collection of font faces. 142 * If the selected font is not installed, returns NULL. 143 * Returns: A PangoFontFamily representing the selected font family, or NULL. The returned object is owned by fontchooser and must not be modified or freed. [transfer none] Since 3.2 144 */ 145 public PgFontFamily getFontFamily() 146 { 147 // PangoFontFamily * gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser); 148 auto p = gtk_font_chooser_get_font_family(getFontChooserTStruct()); 149 150 if(p is null) 151 { 152 return null; 153 } 154 155 return ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) p); 156 } 157 158 /** 159 * Gets the PangoFontFace representing the selected font group 160 * details (i.e. family, slant, weight, width, etc). 161 * If the selected font is not installed, returns NULL. 162 * Returns: A PangoFontFace representing the selected font group details, or NULL. The returned object is owned by fontchooser and must not be modified or freed. [transfer none] Since 3.2 163 */ 164 public PgFontFace getFontFace() 165 { 166 // PangoFontFace * gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser); 167 auto p = gtk_font_chooser_get_font_face(getFontChooserTStruct()); 168 169 if(p is null) 170 { 171 return null; 172 } 173 174 return ObjectG.getDObject!(PgFontFace)(cast(PangoFontFace*) p); 175 } 176 177 /** 178 * The selected font size. 179 * Returns: A n integer representing the selected font size, or -1 if no font size is selected. Since 3.2 180 */ 181 public int getFontSize() 182 { 183 // gint gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser); 184 return gtk_font_chooser_get_font_size(getFontChooserTStruct()); 185 } 186 187 /** 188 * Gets the currently-selected font name. 189 * Note that this can be a different string than what you set with 190 * gtk_font_chooser_set_font(), as the font chooser widget may 191 * normalize font names and thus return a string with a different 192 * structure. For example, "Helvetica Italic Bold 12" could be 193 * normalized to "Helvetica Bold Italic 12". 194 * Use pango_font_description_equal() if you want to compare two 195 * font descriptions. 196 * Returns: A string with the name of the current font, or NULL if no font is selected. You must free this string with g_free(). [transfer full][allow-none] Since 3.2 197 */ 198 public string getFont() 199 { 200 // gchar * gtk_font_chooser_get_font (GtkFontChooser *fontchooser); 201 return Str.toString(gtk_font_chooser_get_font(getFontChooserTStruct())); 202 } 203 204 /** 205 * Sets the currently-selected font. 206 * Params: 207 * fontname = a font name like "Helvetica 12" or "Times Bold 18" 208 * Since 3.2 209 */ 210 public void setFont(string fontname) 211 { 212 // void gtk_font_chooser_set_font (GtkFontChooser *fontchooser, const gchar *fontname); 213 gtk_font_chooser_set_font(getFontChooserTStruct(), Str.toStringz(fontname)); 214 } 215 216 /** 217 * Gets the currently-selected font. 218 * Note that this can be a different string than what you set with 219 * gtk_font_chooser_set_font(), as the font chooser widget may 220 * normalize font names and thus return a string with a different 221 * structure. For example, "Helvetica Italic Bold 12" could be 222 * normalized to "Helvetica Bold Italic 12". 223 * Use pango_font_description_equal() if you want to compare two 224 * font descriptions. 225 * Returns: A PangoFontDescription for the current font, or NULL if no font is selected. [transfer full][allow-none] Since 3.2 226 */ 227 public PgFontDescription getFontDesc() 228 { 229 // PangoFontDescription * gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser); 230 auto p = gtk_font_chooser_get_font_desc(getFontChooserTStruct()); 231 232 if(p is null) 233 { 234 return null; 235 } 236 237 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 238 } 239 240 /** 241 * Sets the currently-selected font from font_desc. 242 * Params: 243 * fontDesc = a PangoFontDescription 244 * Since 3.2 245 */ 246 public void setFontDesc(PgFontDescription fontDesc) 247 { 248 // void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser, const PangoFontDescription *font_desc); 249 gtk_font_chooser_set_font_desc(getFontChooserTStruct(), (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 250 } 251 252 /** 253 * Gets the text displayed in the preview area. 254 * Returns: the text displayed in the preview area. [transfer full] Since 3.2 255 */ 256 public string getPreviewText() 257 { 258 // gchar * gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser); 259 return Str.toString(gtk_font_chooser_get_preview_text(getFontChooserTStruct())); 260 } 261 262 /** 263 * Sets the text displayed in the preview area. 264 * The text is used to show how the selected font looks. 265 * Params: 266 * text = the text to display in the preview area. [transfer none] 267 * Since 3.2 268 */ 269 public void setPreviewText(string text) 270 { 271 // void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser, const gchar *text); 272 gtk_font_chooser_set_preview_text(getFontChooserTStruct(), Str.toStringz(text)); 273 } 274 275 /** 276 * Returns whether the preview entry is shown or not. 277 * Returns: TRUE if the preview entry is shown or FALSE if it is hidden. Since 3.2 278 */ 279 public int getShowPreviewEntry() 280 { 281 // gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser); 282 return gtk_font_chooser_get_show_preview_entry(getFontChooserTStruct()); 283 } 284 285 /** 286 * Shows or hides the editable preview entry. 287 * Params: 288 * showPreviewEntry = whether to show the editable preview entry or not 289 * Since 3.2 290 */ 291 public void setShowPreviewEntry(int showPreviewEntry) 292 { 293 // void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser, gboolean show_preview_entry); 294 gtk_font_chooser_set_show_preview_entry(getFontChooserTStruct(), showPreviewEntry); 295 } 296 297 /** 298 * Adds a filter function that decides which fonts to display 299 * in the font chooser. 300 * Params: 301 * filter = a GtkFontFilterFunc, or NULL. [allow-none] 302 * userData = data to pass to filter 303 * destroy = function to call to free data when it is no longer needed 304 * Since 3.2 305 */ 306 public void setFilterFunc(GtkFontFilterFunc filter, void* userData, GDestroyNotify destroy) 307 { 308 // void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser, GtkFontFilterFunc filter, gpointer user_data, GDestroyNotify destroy); 309 gtk_font_chooser_set_filter_func(getFontChooserTStruct(), filter, userData, destroy); 310 } 311 }