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.PgLayoutIter; 26 27 private import gobject.ObjectG; 28 private import gtkc.pango; 29 public import gtkc.pangotypes; 30 private import pango.PgLayout; 31 private import pango.PgLayoutLine; 32 33 34 /** 35 * A #PangoLayoutIter structure can be used to 36 * iterate over the visual extents of a #PangoLayout. 37 * 38 * The #PangoLayoutIter structure is opaque, and 39 * has no user-visible fields. 40 */ 41 public class PgLayoutIter 42 { 43 /** the main Gtk struct */ 44 protected PangoLayoutIter* pangoLayoutIter; 45 protected bool ownedRef; 46 47 /** Get the main Gtk struct */ 48 public PangoLayoutIter* getPgLayoutIterStruct() 49 { 50 return pangoLayoutIter; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected void* getStruct() 55 { 56 return cast(void*)pangoLayoutIter; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (PangoLayoutIter* pangoLayoutIter, bool ownedRef = false) 63 { 64 this.pangoLayoutIter = pangoLayoutIter; 65 this.ownedRef = ownedRef; 66 } 67 68 69 /** */ 70 public static GType getType() 71 { 72 return pango_layout_iter_get_type(); 73 } 74 75 /** 76 * Determines whether @iter is on the last line of the layout. 77 * 78 * Return: %TRUE if @iter is on the last line. 79 */ 80 public bool atLastLine() 81 { 82 return pango_layout_iter_at_last_line(pangoLayoutIter) != 0; 83 } 84 85 /** 86 * Copies a #PangoLayoutIter. 87 * 88 * Return: the newly allocated #PangoLayoutIter, 89 * which should be freed with pango_layout_iter_free(), 90 * or %NULL if @iter was %NULL. 91 * 92 * Since: 1.20 93 */ 94 public PgLayoutIter copy() 95 { 96 auto p = pango_layout_iter_copy(pangoLayoutIter); 97 98 if(p is null) 99 { 100 return null; 101 } 102 103 return ObjectG.getDObject!(PgLayoutIter)(cast(PangoLayoutIter*) p, true); 104 } 105 106 /** 107 * Frees an iterator that's no longer in use. 108 */ 109 public void free() 110 { 111 pango_layout_iter_free(pangoLayoutIter); 112 } 113 114 /** 115 * Gets the Y position of the current line's baseline, in layout 116 * coordinates (origin at top left of the entire layout). 117 * 118 * Return: baseline of current line. 119 */ 120 public int getBaseline() 121 { 122 return pango_layout_iter_get_baseline(pangoLayoutIter); 123 } 124 125 /** 126 * Gets the extents of the current character, in layout coordinates 127 * (origin is the top left of the entire layout). Only logical extents 128 * can sensibly be obtained for characters; ink extents make sense only 129 * down to the level of clusters. 130 * 131 * Params: 132 * logicalRect = rectangle to fill with 133 * logical extents 134 */ 135 public void getCharExtents(out PangoRectangle logicalRect) 136 { 137 pango_layout_iter_get_char_extents(pangoLayoutIter, &logicalRect); 138 } 139 140 /** 141 * Gets the extents of the current cluster, in layout coordinates 142 * (origin is the top left of the entire layout). 143 * 144 * Params: 145 * inkRect = rectangle to fill with ink extents, or %NULL 146 * logicalRect = rectangle to fill with logical extents, or %NULL 147 */ 148 public void getClusterExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 149 { 150 pango_layout_iter_get_cluster_extents(pangoLayoutIter, &inkRect, &logicalRect); 151 } 152 153 /** 154 * Gets the current byte index. Note that iterating forward by char 155 * moves in visual order, not logical order, so indexes may not be 156 * sequential. Also, the index may be equal to the length of the text 157 * in the layout, if on the %NULL run (see pango_layout_iter_get_run()). 158 * 159 * Return: current byte index. 160 */ 161 public int getIndex() 162 { 163 return pango_layout_iter_get_index(pangoLayoutIter); 164 } 165 166 /** 167 * Gets the layout associated with a #PangoLayoutIter. 168 * 169 * Return: the layout associated with @iter. 170 * 171 * Since: 1.20 172 */ 173 public PgLayout getLayout() 174 { 175 auto p = pango_layout_iter_get_layout(pangoLayoutIter); 176 177 if(p is null) 178 { 179 return null; 180 } 181 182 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p); 183 } 184 185 /** 186 * Obtains the extents of the #PangoLayout being iterated 187 * over. @ink_rect or @logical_rect can be %NULL if you 188 * aren't interested in them. 189 * 190 * Params: 191 * inkRect = rectangle to fill with ink extents, 192 * or %NULL 193 * logicalRect = rectangle to fill with logical 194 * extents, or %NULL 195 */ 196 public void getLayoutExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 197 { 198 pango_layout_iter_get_layout_extents(pangoLayoutIter, &inkRect, &logicalRect); 199 } 200 201 /** 202 * Gets the current line. 203 * 204 * Use the faster pango_layout_iter_get_line_readonly() if you do not plan 205 * to modify the contents of the line (glyphs, glyph widths, etc.). 206 * 207 * Return: the current line. 208 */ 209 public PgLayoutLine getLine() 210 { 211 auto p = pango_layout_iter_get_line(pangoLayoutIter); 212 213 if(p is null) 214 { 215 return null; 216 } 217 218 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p, true); 219 } 220 221 /** 222 * Obtains the extents of the current line. @ink_rect or @logical_rect 223 * can be %NULL if you aren't interested in them. Extents are in layout 224 * coordinates (origin is the top-left corner of the entire 225 * #PangoLayout). Thus the extents returned by this function will be 226 * the same width/height but not at the same x/y as the extents 227 * returned from pango_layout_line_get_extents(). 228 * 229 * Params: 230 * inkRect = rectangle to fill with ink extents, or %NULL 231 * logicalRect = rectangle to fill with logical extents, or %NULL 232 */ 233 public void getLineExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 234 { 235 pango_layout_iter_get_line_extents(pangoLayoutIter, &inkRect, &logicalRect); 236 } 237 238 /** 239 * Gets the current line for read-only access. 240 * 241 * This is a faster alternative to pango_layout_iter_get_line(), 242 * but the user is not expected 243 * to modify the contents of the line (glyphs, glyph widths, etc.). 244 * 245 * Return: the current line, that should not be 246 * modified. 247 * 248 * Since: 1.16 249 */ 250 public PgLayoutLine getLineReadonly() 251 { 252 auto p = pango_layout_iter_get_line_readonly(pangoLayoutIter); 253 254 if(p is null) 255 { 256 return null; 257 } 258 259 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p); 260 } 261 262 /** 263 * Divides the vertical space in the #PangoLayout being iterated over 264 * between the lines in the layout, and returns the space belonging to 265 * the current line. A line's range includes the line's logical 266 * extents, plus half of the spacing above and below the line, if 267 * pango_layout_set_spacing() has been called to set layout spacing. 268 * The Y positions are in layout coordinates (origin at top left of the 269 * entire layout). 270 * 271 * Params: 272 * y0 = start of line, or %NULL 273 * y1 = end of line, or %NULL 274 */ 275 public void getLineYrange(out int y0, out int y1) 276 { 277 pango_layout_iter_get_line_yrange(pangoLayoutIter, &y0, &y1); 278 } 279 280 /** 281 * Gets the current run. When iterating by run, at the end of each 282 * line, there's a position with a %NULL run, so this function can return 283 * %NULL. The %NULL run at the end of each line ensures that all lines have 284 * at least one run, even lines consisting of only a newline. 285 * 286 * Use the faster pango_layout_iter_get_run_readonly() if you do not plan 287 * to modify the contents of the run (glyphs, glyph widths, etc.). 288 * 289 * Return: the current run. 290 */ 291 public PangoLayoutRun* getRun() 292 { 293 return pango_layout_iter_get_run(pangoLayoutIter); 294 } 295 296 /** 297 * Gets the extents of the current run in layout coordinates 298 * (origin is the top left of the entire layout). 299 * 300 * Params: 301 * inkRect = rectangle to fill with ink extents, or %NULL 302 * logicalRect = rectangle to fill with logical extents, or %NULL 303 */ 304 public void getRunExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 305 { 306 pango_layout_iter_get_run_extents(pangoLayoutIter, &inkRect, &logicalRect); 307 } 308 309 /** 310 * Gets the current run. When iterating by run, at the end of each 311 * line, there's a position with a %NULL run, so this function can return 312 * %NULL. The %NULL run at the end of each line ensures that all lines have 313 * at least one run, even lines consisting of only a newline. 314 * 315 * This is a faster alternative to pango_layout_iter_get_run(), 316 * but the user is not expected 317 * to modify the contents of the run (glyphs, glyph widths, etc.). 318 * 319 * Return: the current run, that 320 * should not be modified. 321 * 322 * Since: 1.16 323 */ 324 public PangoLayoutRun* getRunReadonly() 325 { 326 return pango_layout_iter_get_run_readonly(pangoLayoutIter); 327 } 328 329 /** 330 * Moves @iter forward to the next character in visual order. If @iter was already at 331 * the end of the layout, returns %FALSE. 332 * 333 * Return: whether motion was possible. 334 */ 335 public bool nextChar() 336 { 337 return pango_layout_iter_next_char(pangoLayoutIter) != 0; 338 } 339 340 /** 341 * Moves @iter forward to the next cluster in visual order. If @iter 342 * was already at the end of the layout, returns %FALSE. 343 * 344 * Return: whether motion was possible. 345 */ 346 public bool nextCluster() 347 { 348 return pango_layout_iter_next_cluster(pangoLayoutIter) != 0; 349 } 350 351 /** 352 * Moves @iter forward to the start of the next line. If @iter is 353 * already on the last line, returns %FALSE. 354 * 355 * Return: whether motion was possible. 356 */ 357 public bool nextLine() 358 { 359 return pango_layout_iter_next_line(pangoLayoutIter) != 0; 360 } 361 362 /** 363 * Moves @iter forward to the next run in visual order. If @iter was 364 * already at the end of the layout, returns %FALSE. 365 * 366 * Return: whether motion was possible. 367 */ 368 public bool nextRun() 369 { 370 return pango_layout_iter_next_run(pangoLayoutIter) != 0; 371 } 372 }