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  * Description
71  * The functions in this section are used to identify the writing
72  * system, or script of individual characters
73  * and of ranges within a larger text string.
74  */
75 public class PgLanguage
76 {
77 	
78 	/** the main Gtk struct */
79 	protected PangoLanguage* pangoLanguage;
80 	
81 	
82 	public PangoLanguage* getPgLanguageStruct()
83 	{
84 		return pangoLanguage;
85 	}
86 	
87 	
88 	/** the main Gtk struct as a void* */
89 	protected void* getStruct()
90 	{
91 		return cast(void*)pangoLanguage;
92 	}
93 	
94 	/**
95 	 * Sets our main struct and passes it to the parent class
96 	 */
97 	public this (PangoLanguage* pangoLanguage)
98 	{
99 		this.pangoLanguage = pangoLanguage;
100 	}
101 	
102 	/**
103 	 */
104 	
105 	/**
106 	 * Take a RFC-3066 format language tag as a string and convert it to a
107 	 * PangoLanguage pointer that can be efficiently copied (copy the
108 	 * pointer) and compared with other language tags (compare the
109 	 * pointer.)
110 	 * This function first canonicalizes the string by converting it to
111 	 * lowercase, mapping '_' to '-', and stripping all characters other
112 	 * than letters and '-'.
113 	 * Use pango_language_get_default() if you want to get the PangoLanguage for
114 	 * the current locale of the process.
115 	 * Params:
116 	 * language = a string representing a language tag, or NULL
117 	 * 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.
118 	 */
119 	public static PgLanguage fromString(string language)
120 	{
121 		// PangoLanguage * pango_language_from_string (const char *language);
122 		auto p = pango_language_from_string(Str.toStringz(language));
123 		
124 		if(p is null)
125 		{
126 			return null;
127 		}
128 		
129 		return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) p);
130 	}
131 	
132 	/**
133 	 * Gets the RFC-3066 format string representing the given language tag.
134 	 * Returns: a string representing the language tag. This is owned by Pango and should not be freed.
135 	 */
136 	public override string toString()
137 	{
138 		// const char * pango_language_to_string (PangoLanguage *language);
139 		return Str.toString(pango_language_to_string(pangoLanguage));
140 	}
141 	
142 	/**
143 	 * Checks if a language tag matches one of the elements in a list of
144 	 * language ranges. A language tag is considered to match a range
145 	 * in the list if the range is '*', the range is exactly the tag,
146 	 * or the range is a prefix of the tag, and the character after it
147 	 * in the tag is '-'.
148 	 * Params:
149 	 * rangeList = a list of language ranges, separated by ';', ':',
150 	 *  ',', or space characters.
151 	 *  Each element must either be '*', or a RFC 3066 language range
152 	 *  canonicalized as by pango_language_from_string()
153 	 * Returns: TRUE if a match was found.
154 	 */
155 	public int matches(string rangeList)
156 	{
157 		// gboolean pango_language_matches (PangoLanguage *language,  const char *range_list);
158 		return pango_language_matches(pangoLanguage, Str.toStringz(rangeList));
159 	}
160 	
161 	/**
162 	 * Determines if script is one of the scripts used to
163 	 * write language. The returned value is conservative;
164 	 * if nothing is known about the language tag language,
165 	 * TRUE will be returned, since, as far as Pango knows,
166 	 * script might be used to write language.
167 	 * This routine is used in Pango's itemization process when
168 	 * determining if a supplied language tag is relevant to
169 	 * a particular section of text. It probably is not useful for
170 	 * applications in most circumstances.
171 	 * This function uses pango_language_get_scripts() internally.
172 	 * Since 1.4
173 	 * Params:
174 	 * script = a PangoScript
175 	 * 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.
176 	 */
177 	public int includesScript(PangoScript script)
178 	{
179 		// gboolean pango_language_includes_script (PangoLanguage *language,  PangoScript script);
180 		return pango_language_includes_script(pangoLanguage, script);
181 	}
182 	
183 	/**
184 	 * Determines the scripts used to to write language.
185 	 * If nothing is known about the language tag language,
186 	 * or if language is NULL, then NULL is returned.
187 	 * The list of scripts returned starts with the script that the
188 	 * language uses most and continues to the one it uses least.
189 	 * The value num_script points at will be set to the number
190 	 * of scripts in the returned array (or zero if NULL is returned).
191 	 * Most languages use only one script for writing, but there are
192 	 * some that use two (Latin and Cyrillic for example), and a few
193 	 * use three (Japanese for example). Applications should not make
194 	 * any assumptions on the maximum number of scripts returned
195 	 * though, except that it is positive if the return value is not
196 	 * NULL, and it is a small number.
197 	 * The pango_language_includes_script() function uses this function
198 	 * internally.
199 	 * Since 1.22
200 	 * Params:
201 	 * numScripts = location to return number of scripts, or NULL
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.
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.
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 }