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.PgScriptIter; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtkc.pango; 31 public import gtkc.pangotypes; 32 33 34 /** 35 * A #PangoScriptIter is used to iterate through a string 36 * and identify ranges in different scripts. 37 */ 38 public class PgScriptIter 39 { 40 /** the main Gtk struct */ 41 protected PangoScriptIter* pangoScriptIter; 42 43 /** Get the main Gtk struct */ 44 public PangoScriptIter* getPgScriptIterStruct() 45 { 46 return pangoScriptIter; 47 } 48 49 /** the main Gtk struct as a void* */ 50 protected void* getStruct() 51 { 52 return cast(void*)pangoScriptIter; 53 } 54 55 /** 56 * Sets our main struct and passes it to the parent class. 57 */ 58 public this (PangoScriptIter* pangoScriptIter) 59 { 60 this.pangoScriptIter = pangoScriptIter; 61 } 62 63 64 /** 65 * Frees a #PangoScriptIter created with pango_script_iter_new(). 66 * 67 * Since: 1.4 68 */ 69 public void free() 70 { 71 pango_script_iter_free(pangoScriptIter); 72 } 73 74 /** 75 * Gets information about the range to which @iter currently points. 76 * The range is the set of locations p where *start <= p < *end. 77 * (That is, it doesn't include the character stored at *end) 78 * 79 * Params: 80 * start = location to store start position of the range, or %NULL 81 * end = location to store end position of the range, or %NULL 82 * script = location to store script for range, or %NULL 83 * 84 * Since: 1.4 85 */ 86 public void getRange(out string start, out string end, out PangoScript script) 87 { 88 char* outstart = null; 89 char* outend = null; 90 91 pango_script_iter_get_range(pangoScriptIter, &outstart, &outend, &script); 92 93 start = Str.toString(outstart); 94 end = Str.toString(outend); 95 } 96 97 /** 98 * Advances a #PangoScriptIter to the next range. If @iter 99 * is already at the end, it is left unchanged and %FALSE 100 * is returned. 101 * 102 * Return: %TRUE if @iter was successfully advanced. 103 * 104 * Since: 1.4 105 */ 106 public bool next() 107 { 108 return pango_script_iter_next(pangoScriptIter) != 0; 109 } 110 111 /** 112 * Create a new #PangoScriptIter, used to break a string of 113 * Unicode text into runs by Unicode script. No copy is made of 114 * @text, so the caller needs to make sure it remains valid until 115 * the iterator is freed with pango_script_iter_free(). 116 * 117 * Params: 118 * text = a UTF-8 string 119 * length = length of @text, or -1 if @text is nul-terminated. 120 * 121 * Return: the new script iterator, initialized 122 * to point at the first range in the text, which should be 123 * freed with pango_script_iter_free(). If the string is 124 * empty, it will point at an empty range. 125 * 126 * Since: 1.4 127 * 128 * Throws: ConstructionException GTK+ fails to create the object. 129 */ 130 public this(string text, int length) 131 { 132 auto p = pango_script_iter_new(Str.toStringz(text), length); 133 134 if(p is null) 135 { 136 throw new ConstructionException("null returned by new"); 137 } 138 139 this(cast(PangoScriptIter*) p); 140 } 141 }