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.PgLayoutLine; 26 27 private import glib.ListSG; 28 private import glib.MemorySlice; 29 private import gobject.ObjectG; 30 private import gtkd.Loader; 31 private import pango.PgLayout; 32 private import pango.c.functions; 33 public import pango.c.types; 34 35 36 /** 37 * A `PangoLayoutLine` represents one of the lines resulting from laying 38 * out a paragraph via `PangoLayout`. 39 * 40 * `PangoLayoutLine` structures are obtained by calling 41 * [method@Pango.Layout.get_line] and are only valid until the text, 42 * attributes, or settings of the parent `PangoLayout` are modified. 43 */ 44 public final class PgLayoutLine 45 { 46 /** the main Gtk struct */ 47 protected PangoLayoutLine* pangoLayoutLine; 48 protected bool ownedRef; 49 50 /** Get the main Gtk struct */ 51 public PangoLayoutLine* getPgLayoutLineStruct(bool transferOwnership = false) 52 { 53 if (transferOwnership) 54 ownedRef = false; 55 return pangoLayoutLine; 56 } 57 58 /** the main Gtk struct as a void* */ 59 protected void* getStruct() 60 { 61 return cast(void*)pangoLayoutLine; 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (PangoLayoutLine* pangoLayoutLine, bool ownedRef = false) 68 { 69 this.pangoLayoutLine = pangoLayoutLine; 70 this.ownedRef = ownedRef; 71 } 72 73 ~this () 74 { 75 if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef ) 76 pango_layout_line_unref(pangoLayoutLine); 77 } 78 79 80 /** 81 * the layout this line belongs to, might be %NULL 82 */ 83 public @property PgLayout layout() 84 { 85 return ObjectG.getDObject!(PgLayout)(pangoLayoutLine.layout, false); 86 } 87 88 /** Ditto */ 89 public @property void layout(PgLayout value) 90 { 91 pangoLayoutLine.layout = value.getPgLayoutStruct(); 92 } 93 94 /** 95 * start of line as byte index into layout->text 96 */ 97 public @property int startIndex() 98 { 99 return pangoLayoutLine.startIndex; 100 } 101 102 /** Ditto */ 103 public @property void startIndex(int value) 104 { 105 pangoLayoutLine.startIndex = value; 106 } 107 108 /** 109 * length of line in bytes 110 */ 111 public @property int length() 112 { 113 return pangoLayoutLine.length; 114 } 115 116 /** Ditto */ 117 public @property void length(int value) 118 { 119 pangoLayoutLine.length = value; 120 } 121 122 /** 123 * list of runs in the 124 * line, from left to right 125 */ 126 public @property ListSG runs() 127 { 128 return new ListSG(pangoLayoutLine.runs, false); 129 } 130 131 /** Ditto */ 132 public @property void runs(ListSG value) 133 { 134 pangoLayoutLine.runs = value.getListSGStruct(); 135 } 136 137 /** 138 * #TRUE if this is the first line of the paragraph 139 */ 140 public @property uint isParagraphStart() 141 { 142 return pangoLayoutLine.isParagraphStart; 143 } 144 145 /** Ditto */ 146 public @property void isParagraphStart(uint value) 147 { 148 pangoLayoutLine.isParagraphStart = value; 149 } 150 151 /** 152 * #Resolved PangoDirection of line 153 */ 154 public @property uint resolvedDir() 155 { 156 return pangoLayoutLine.resolvedDir; 157 } 158 159 /** Ditto */ 160 public @property void resolvedDir(uint value) 161 { 162 pangoLayoutLine.resolvedDir = value; 163 } 164 165 /** */ 166 public static GType getType() 167 { 168 return pango_layout_line_get_type(); 169 } 170 171 /** 172 * Computes the logical and ink extents of a layout line. See 173 * [method@Pango.Font.get_glyph_extents] for details about the 174 * interpretation of the rectangles. 175 * 176 * Params: 177 * inkRect = rectangle used to store the extents of 178 * the glyph string as drawn, or %NULL 179 * logicalRect = rectangle used to store the logical 180 * extents of the glyph string, or %NULL 181 */ 182 public void getExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 183 { 184 pango_layout_line_get_extents(pangoLayoutLine, &inkRect, &logicalRect); 185 } 186 187 /** 188 * Computes the height of the line, i.e. the distance between 189 * this and the previous lines baseline. 190 * 191 * Params: 192 * height = return location for the line height 193 * 194 * Since: 1.44 195 */ 196 public void getHeight(out int height) 197 { 198 pango_layout_line_get_height(pangoLayoutLine, &height); 199 } 200 201 /** 202 * Computes the logical and ink extents of @layout_line in device units. 203 * 204 * This function just calls [method@Pango.LayoutLine.get_extents] followed by 205 * two [func@extents_to_pixels] calls, rounding @ink_rect and @logical_rect 206 * such that the rounded rectangles fully contain the unrounded one (that is, 207 * passes them as first argument to [func@extents_to_pixels]). 208 * 209 * Params: 210 * inkRect = rectangle used to store the extents of 211 * the glyph string as drawn, or %NULL 212 * logicalRect = rectangle used to store the logical 213 * extents of the glyph string, or %NULL 214 */ 215 public void getPixelExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 216 { 217 pango_layout_line_get_pixel_extents(pangoLayoutLine, &inkRect, &logicalRect); 218 } 219 220 /** 221 * Gets a list of visual ranges corresponding to a given logical range. 222 * This list is not necessarily minimal - there may be consecutive 223 * ranges which are adjacent. The ranges will be sorted from left to 224 * right. The ranges are with respect to the left edge of the entire 225 * layout, not with respect to the line. 226 * 227 * Params: 228 * startIndex = Start byte index of the logical range. If this value 229 * is less than the start index for the line, then the first range 230 * will extend all the way to the leading edge of the layout. Otherwise, 231 * it will start at the leading edge of the first character. 232 * endIndex = Ending byte index of the logical range. If this value is 233 * greater than the end index for the line, then the last range will 234 * extend all the way to the trailing edge of the layout. Otherwise, 235 * it will end at the trailing edge of the last character. 236 * ranges = location to 237 * store a pointer to an array of ranges. The array will be of length 238 * `2*n_ranges`, with each range starting at `(*ranges)[2*n]` and of 239 * width `(*ranges)[2*n + 1] - (*ranges)[2*n]`. This array must be freed 240 * with g_free(). The coordinates are relative to the layout and are in 241 * Pango units. 242 */ 243 public void getXRanges(int startIndex, int endIndex, out int[] ranges) 244 { 245 int* outranges; 246 int nRanges; 247 248 pango_layout_line_get_x_ranges(pangoLayoutLine, startIndex, endIndex, &outranges, &nRanges); 249 250 ranges = outranges[0 .. nRanges]; 251 } 252 253 /** 254 * Converts an index within a line to a X position. 255 * 256 * Params: 257 * index = byte offset of a grapheme within the layout 258 * trailing = an integer indicating the edge of the grapheme to retrieve 259 * the position of. If > 0, the trailing edge of the grapheme, 260 * if 0, the leading of the grapheme. 261 * xPos = location to store the x_offset (in Pango units) 262 */ 263 public void indexToX(int index, bool trailing, out int xPos) 264 { 265 pango_layout_line_index_to_x(pangoLayoutLine, index, trailing, &xPos); 266 } 267 268 alias doref = ref_; 269 /** 270 * Increase the reference count of a `PangoLayoutLine` by one. 271 * 272 * Returns: the line passed in. 273 * 274 * Since: 1.10 275 */ 276 public PgLayoutLine ref_() 277 { 278 auto __p = pango_layout_line_ref(pangoLayoutLine); 279 280 if(__p is null) 281 { 282 return null; 283 } 284 285 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) __p, true); 286 } 287 288 /** 289 * Decrease the reference count of a `PangoLayoutLine` by one. 290 * If the result is zero, the line and all associated memory 291 * will be freed. 292 */ 293 public void unref() 294 { 295 pango_layout_line_unref(pangoLayoutLine); 296 } 297 298 /** 299 * Converts from x offset to the byte index of the corresponding character 300 * within the text of the layout. If @x_pos is outside the line, @index_ and 301 * @trailing will point to the very first or very last position in the line. 302 * This determination is based on the resolved direction of the paragraph; 303 * for example, if the resolved direction is right-to-left, then an X position 304 * to the right of the line (after it) results in 0 being stored in @index_ 305 * and @trailing. An X position to the left of the line results in @index_ 306 * pointing to the (logical) last grapheme in the line and @trailing being 307 * set to the number of characters in that grapheme. The reverse is true for 308 * a left-to-right line. 309 * 310 * Params: 311 * xPos = the X offset (in Pango units) from the left edge of the line. 312 * index = location to store calculated byte index for the grapheme 313 * in which the user clicked. 314 * trailing = location to store an integer indicating where in the 315 * grapheme the user clicked. It will either be zero, or the number of 316 * characters in the grapheme. 0 represents the leading edge of the grapheme. 317 * 318 * Returns: %FALSE if @x_pos was outside the line, %TRUE if inside 319 */ 320 public bool xToIndex(int xPos, out int index, out int trailing) 321 { 322 return pango_layout_line_x_to_index(pangoLayoutLine, xPos, &index, &trailing) != 0; 323 } 324 }