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 = 27 * outPack = pango 28 * outFile = PgLanguage 29 * strct = PangoLanguage 30 * realStrct= 31 * ctorStrct= 32 * clss = PgLanguage 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_language_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * - PangoLanguage* -> PgLanguage 49 * module aliases: 50 * local aliases: 51 * overrides: 52 * - toString 53 */ 54 55 module pango.PgLanguage; 56 57 public import gtkc.pangotypes; 58 59 private import gtkc.pango; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import glib.Str; 64 65 66 67 /** 68 * The functions in this section are used to identify the writing 69 * system, or script of individual characters 70 * and of ranges within a larger text string. 71 */ 72 public class PgLanguage 73 { 74 75 /** the main Gtk struct */ 76 protected PangoLanguage* pangoLanguage; 77 78 79 /** Get the main Gtk struct */ 80 public PangoLanguage* getPgLanguageStruct() 81 { 82 return pangoLanguage; 83 } 84 85 86 /** the main Gtk struct as a void* */ 87 protected void* getStruct() 88 { 89 return cast(void*)pangoLanguage; 90 } 91 92 /** 93 * Sets our main struct and passes it to the parent class 94 */ 95 public this (PangoLanguage* pangoLanguage) 96 { 97 this.pangoLanguage = pangoLanguage; 98 } 99 100 /** 101 */ 102 103 /** 104 * Take a RFC-3066 format language tag as a string and convert it to a 105 * PangoLanguage pointer that can be efficiently copied (copy the 106 * pointer) and compared with other language tags (compare the 107 * pointer.) 108 * This function first canonicalizes the string by converting it to 109 * lowercase, mapping '_' to '-', and stripping all characters other 110 * than letters and '-'. 111 * Use pango_language_get_default() if you want to get the PangoLanguage for 112 * the current locale of the process. 113 * Params: 114 * language = a string representing a language tag, or NULL. [allow-none] 115 * Returns: an opaque pointer to a PangoLanguage structure, or NULL if language was NULL. The returned pointer will be valid forever after, and should not be freed. [transfer none] 116 */ 117 public static PgLanguage fromString(string language) 118 { 119 // PangoLanguage * pango_language_from_string (const char *language); 120 auto p = pango_language_from_string(Str.toStringz(language)); 121 122 if(p is null) 123 { 124 return null; 125 } 126 127 return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) p); 128 } 129 130 /** 131 * Gets the RFC-3066 format string representing the given language tag. 132 * Returns: a string representing the language tag. This is owned by Pango and should not be freed. 133 */ 134 public override string toString() 135 { 136 // const char * pango_language_to_string (PangoLanguage *language); 137 return Str.toString(pango_language_to_string(pangoLanguage)); 138 } 139 140 /** 141 * Checks if a language tag matches one of the elements in a list of 142 * language ranges. A language tag is considered to match a range 143 * in the list if the range is '*', the range is exactly the tag, 144 * or the range is a prefix of the tag, and the character after it 145 * in the tag is '-'. 146 * Params: 147 * rangeList = a list of language ranges, separated by ';', ':', 148 * ',', or space characters. 149 * Each element must either be '*', or a RFC 3066 language range 150 * canonicalized as by pango_language_from_string() 151 * Returns: TRUE if a match was found. 152 */ 153 public int matches(string rangeList) 154 { 155 // gboolean pango_language_matches (PangoLanguage *language, const char *range_list); 156 return pango_language_matches(pangoLanguage, Str.toStringz(rangeList)); 157 } 158 159 /** 160 * Determines if script is one of the scripts used to 161 * write language. The returned value is conservative; 162 * if nothing is known about the language tag language, 163 * TRUE will be returned, since, as far as Pango knows, 164 * script might be used to write language. 165 * This routine is used in Pango's itemization process when 166 * determining if a supplied language tag is relevant to 167 * a particular section of text. It probably is not useful for 168 * applications in most circumstances. 169 * This function uses pango_language_get_scripts() internally. 170 * Since 1.4 171 * Params: 172 * script = a PangoScript 173 * Returns: TRUE if script is one of the scripts used to write language or if nothing is known about language (including the case that language is NULL), FALSE otherwise. 174 */ 175 public int includesScript(PangoScript script) 176 { 177 // gboolean pango_language_includes_script (PangoLanguage *language, PangoScript script); 178 return pango_language_includes_script(pangoLanguage, script); 179 } 180 181 /** 182 * Determines the scripts used to to write language. 183 * If nothing is known about the language tag language, 184 * or if language is NULL, then NULL is returned. 185 * The list of scripts returned starts with the script that the 186 * language uses most and continues to the one it uses least. 187 * The value num_script points at will be set to the number 188 * of scripts in the returned array (or zero if NULL is returned). 189 * Most languages use only one script for writing, but there are 190 * some that use two (Latin and Cyrillic for example), and a few 191 * use three (Japanese for example). Applications should not make 192 * any assumptions on the maximum number of scripts returned 193 * though, except that it is positive if the return value is not 194 * NULL, and it is a small number. 195 * The pango_language_includes_script() function uses this function 196 * internally. 197 * Since 1.22 198 * Params: 199 * numScripts = location to return number of scripts, 200 * or NULL. [out caller-allocates][allow-none] 201 * Returns: An array of PangoScript values, with the number of entries in the array stored in num_scripts, or NULL if Pango does not have any information about this particular language tag (also the case if language is NULL). The returned array is owned by Pango and should not be modified or freed. [array length=num_scripts] 202 */ 203 public PangoScript* getScripts(int* numScripts) 204 { 205 // const PangoScript * pango_language_get_scripts (PangoLanguage *language, int *num_scripts); 206 return pango_language_get_scripts(pangoLanguage, numScripts); 207 } 208 209 /** 210 * Returns the PangoLanguage for the current locale of the process. 211 * Note that this can change over the life of an application. 212 * On Unix systems, this is the return value is derived from 213 * setlocale(LC_CTYPE, NULL), and the user can 214 * affect this through the environment variables LC_ALL, LC_CTYPE or 215 * LANG (checked in that order). The locale string typically is in 216 * the form lang_COUNTRY, where lang is an ISO-639 language code, and 217 * COUNTRY is an ISO-3166 country code. For instance, sv_FI for 218 * Swedish as written in Finland or pt_BR for Portuguese as written in 219 * Brazil. 220 * On Windows, the C library does not use any such environment 221 * variables, and setting them won't affect the behavior of functions 222 * like ctime(). The user sets the locale through the Regional Options 223 * in the Control Panel. The C library (in the setlocale() function) 224 * does not use country and language codes, but country and language 225 * names spelled out in English. 226 * However, this function does check the above environment 227 * variables, and does return a Unix-style locale string based on 228 * either said environment variables or the thread's current locale. 229 * Your application should call setlocale(LC_ALL, ""); 230 * for the user settings to take effect. Gtk+ does this in its initialization 231 * functions automatically (by calling gtk_set_locale()). 232 * See man setlocale for more details. 233 * Since 1.16 234 * Returns: the default language as a PangoLanguage, must not be freed. [transfer none] 235 */ 236 public static PgLanguage getDefault() 237 { 238 // PangoLanguage * pango_language_get_default (void); 239 auto p = pango_language_get_default(); 240 241 if(p is null) 242 { 243 return null; 244 } 245 246 return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) p); 247 } 248 249 /** 250 * Get a string that is representative of the characters needed to 251 * render a particular language. 252 * The sample text may be a pangram, but is not necessarily. It is chosen to 253 * be demonstrative of normal text in the language, as well as exposing font 254 * feature requirements unique to the language. It is suitable for use 255 * as sample text in a font selection dialog. 256 * If language is NULL, the default language as found by 257 * pango_language_get_default() is used. 258 * If Pango does not have a sample string for language, the classic 259 * "The quick brown fox..." is returned. This can be detected by 260 * comparing the returned pointer value to that returned for (non-existent) 261 * Returns: the sample string. This value is owned by Pango and should not be freed. 262 */ 263 public string getSampleString() 264 { 265 // const char * pango_language_get_sample_string (PangoLanguage *language); 266 return Str.toString(pango_language_get_sample_string(pangoLanguage)); 267 } 268 }