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 66 /** 67 * Frees a #PangoScriptIter created with pango_script_iter_new(). 68 * 69 * Since: 1.4 70 */ 71 public void free() 72 { 73 pango_script_iter_free(pangoScriptIter); 74 } 75 76 /** 77 * Gets information about the range to which @iter currently points. 78 * The range is the set of locations p where *start <= p < *end. 79 * (That is, it doesn't include the character stored at *end) 80 * 81 * Params: 82 * start = location to store start position of the range, or %NULL 83 * end = location to store end position of the range, or %NULL 84 * script = location to store script for range, or %NULL 85 * 86 * Since: 1.4 87 */ 88 public void getRange(out string start, out string end, out PangoScript script) 89 { 90 char* outstart = null; 91 char* outend = null; 92 93 pango_script_iter_get_range(pangoScriptIter, &outstart, &outend, &script); 94 95 start = Str.toString(outstart); 96 end = Str.toString(outend); 97 } 98 99 /** 100 * Advances a #PangoScriptIter to the next range. If @iter 101 * is already at the end, it is left unchanged and %FALSE 102 * is returned. 103 * 104 * Return: %TRUE if @iter was successfully advanced. 105 * 106 * Since: 1.4 107 */ 108 public bool next() 109 { 110 return pango_script_iter_next(pangoScriptIter) != 0; 111 } 112 113 /** 114 * Create a new #PangoScriptIter, used to break a string of 115 * Unicode text into runs by Unicode script. No copy is made of 116 * @text, so the caller needs to make sure it remains valid until 117 * the iterator is freed with pango_script_iter_free(). 118 * 119 * Params: 120 * text = a UTF-8 string 121 * length = length of @text, or -1 if @text is nul-terminated. 122 * 123 * Return: the new script iterator, initialized 124 * to point at the first range in the text, which should be 125 * freed with pango_script_iter_free(). If the string is 126 * empty, it will point at an empty range. 127 * 128 * Since: 1.4 129 * 130 * Throws: ConstructionException GTK+ fails to create the object. 131 */ 132 public this(string text, int length) 133 { 134 auto p = pango_script_iter_new(Str.toStringz(text), length); 135 136 if(p is null) 137 { 138 throw new ConstructionException("null returned by new"); 139 } 140 141 this(cast(PangoScriptIter*) p); 142 } 143 }