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