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