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