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 * Conversion parameters: 26 * inFile = 27 * outPack = pango 28 * outFile = PgLayoutLine 29 * strct = PangoLayoutLine 30 * realStrct= 31 * ctorStrct= 32 * clss = PgLayoutLine 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_layout_line_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * structWrap: 47 * - PangoLayoutLine* -> PgLayoutLine 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module pango.PgLayoutLine; 54 55 public import gtkc.pangotypes; 56 57 private import gtkc.pango; 58 private import glib.ConstructionException; 59 private import gobject.ObjectG; 60 61 62 63 64 65 66 /** 67 * While complete access to the layout capabilities of Pango is provided 68 * using the detailed interfaces for itemization and shaping, using 69 * that functionality directly involves writing a fairly large amount 70 * of code. The objects and functions in this section provide a 71 * high-level driver for formatting entire paragraphs of text 72 * at once. 73 */ 74 public class PgLayoutLine 75 { 76 77 /** the main Gtk struct */ 78 protected PangoLayoutLine* pangoLayoutLine; 79 80 81 public PangoLayoutLine* getPgLayoutLineStruct() 82 { 83 return pangoLayoutLine; 84 } 85 86 87 /** the main Gtk struct as a void* */ 88 protected void* getStruct() 89 { 90 return cast(void*)pangoLayoutLine; 91 } 92 93 /** 94 * Sets our main struct and passes it to the parent class 95 */ 96 public this (PangoLayoutLine* pangoLayoutLine) 97 { 98 this.pangoLayoutLine = pangoLayoutLine; 99 } 100 101 /** 102 */ 103 104 /** 105 * Increase the reference count of a PangoLayoutLine by one. 106 * Since 1.10 107 * Returns: the line passed in. 108 */ 109 public PgLayoutLine doref() 110 { 111 // PangoLayoutLine * pango_layout_line_ref (PangoLayoutLine *line); 112 auto p = pango_layout_line_ref(pangoLayoutLine); 113 114 if(p is null) 115 { 116 return null; 117 } 118 119 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p); 120 } 121 122 /** 123 * Decrease the reference count of a PangoLayoutLine by one. 124 * If the result is zero, the line and all associated memory 125 * will be freed. 126 */ 127 public void unref() 128 { 129 // void pango_layout_line_unref (PangoLayoutLine *line); 130 pango_layout_line_unref(pangoLayoutLine); 131 } 132 133 /** 134 * Computes the logical and ink extents of a layout line. See 135 * pango_font_get_glyph_extents() for details about the interpretation 136 * of the rectangles. 137 * Params: 138 * inkRect = rectangle used to store the extents of 139 * the glyph string as drawn, or NULL. [out][allow-none] 140 * logicalRect = rectangle used to store the logical 141 * extents of the glyph string, or NULL. [out][allow-none] 142 */ 143 public void getExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect) 144 { 145 // void pango_layout_line_get_extents (PangoLayoutLine *line, PangoRectangle *ink_rect, PangoRectangle *logical_rect); 146 pango_layout_line_get_extents(pangoLayoutLine, inkRect, logicalRect); 147 } 148 149 /** 150 * Computes the logical and ink extents of layout_line in device units. 151 * This function just calls pango_layout_line_get_extents() followed by 152 * two pango_extents_to_pixels() calls, rounding ink_rect and logical_rect 153 * such that the rounded rectangles fully contain the unrounded one (that is, 154 * passes them as first argument to pango_extents_to_pixels()). 155 * Params: 156 * inkRect = rectangle used to store the extents of 157 * the glyph string as drawn, or NULL. [out][allow-none] 158 * logicalRect = rectangle used to store the logical 159 * extents of the glyph string, or NULL. [out][allow-none] 160 */ 161 public void getPixelExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect) 162 { 163 // void pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line, PangoRectangle *ink_rect, PangoRectangle *logical_rect); 164 pango_layout_line_get_pixel_extents(pangoLayoutLine, inkRect, logicalRect); 165 } 166 167 /** 168 * Converts an index within a line to a X position. 169 * Params: 170 * index = byte offset of a grapheme within the layout 171 * trailing = an integer indicating the edge of the grapheme to retrieve 172 * the position of. If > 0, the trailing edge of the grapheme, 173 * if 0, the leading of the grapheme. 174 * xPos = location to store the x_offset (in Pango unit). [out] 175 */ 176 public void indexToX(int index, int trailing, out int xPos) 177 { 178 // void pango_layout_line_index_to_x (PangoLayoutLine *line, int index_, gboolean trailing, int *x_pos); 179 pango_layout_line_index_to_x(pangoLayoutLine, index, trailing, &xPos); 180 } 181 182 /** 183 * Converts from x offset to the byte index of the corresponding 184 * character within the text of the layout. If x_pos is outside the line, 185 * index_ and trailing will point to the very first or very last position 186 * in the line. This determination is based on the resolved direction 187 * of the paragraph; for example, if the resolved direction is 188 * right-to-left, then an X position to the right of the line (after it) 189 * results in 0 being stored in index_ and trailing. An X position to the 190 * left of the line results in index_ pointing to the (logical) last 191 * grapheme in the line and trailing being set to the number of characters 192 * in that grapheme. The reverse is true for a left-to-right line. 193 * Params: 194 * xPos = the X offset (in Pango units) 195 * from the left edge of the line. 196 * index = location to store calculated byte index for 197 * the grapheme in which the user clicked. [out] 198 * trailing = location to store an integer indicating where 199 * in the grapheme the user clicked. It will either 200 * be zero, or the number of characters in the 201 * grapheme. 0 represents the leading edge of the grapheme. [out] 202 * Returns: FALSE if x_pos was outside the line, TRUE if inside 203 */ 204 public int xToIndex(int xPos, out int index, out int trailing) 205 { 206 // gboolean pango_layout_line_x_to_index (PangoLayoutLine *line, int x_pos, int *index_, int *trailing); 207 return pango_layout_line_x_to_index(pangoLayoutLine, xPos, &index, &trailing); 208 } 209 210 /** 211 * Gets a list of visual ranges corresponding to a given logical range. 212 * This list is not necessarily minimal - there may be consecutive 213 * ranges which are adjacent. The ranges will be sorted from left to 214 * right. The ranges are with respect to the left edge of the entire 215 * layout, not with respect to the line. 216 * Params: 217 * startIndex = Start byte index of the logical range. If this value 218 * is less than the start index for the line, then 219 * the first range will extend all the way to the leading 220 * edge of the layout. Otherwise it will start at the 221 * leading edge of the first character. 222 * endIndex = Ending byte index of the logical range. If this value 223 * is greater than the end index for the line, then 224 * the last range will extend all the way to the trailing 225 * edge of the layout. Otherwise, it will end at the 226 * trailing edge of the last character. 227 * ranges = location to store a pointer to an array of ranges. 228 * The array will be of length 2*n_ranges, 229 * with each range starting at (*ranges)[2*n] 230 * and of width (*ranges)[2*n + 1] - (*ranges)[2*n]. 231 * This array must be freed with g_free(). The coordinates are relative 232 * to the layout and are in Pango units. [out][array length=n_ranges][transfer full] 233 */ 234 public void getXRanges(int startIndex, int endIndex, out int[] ranges) 235 { 236 // void pango_layout_line_get_x_ranges (PangoLayoutLine *line, int start_index, int end_index, int **ranges, int *n_ranges); 237 int* outranges = null; 238 int nRanges; 239 240 pango_layout_line_get_x_ranges(pangoLayoutLine, startIndex, endIndex, &outranges, &nRanges); 241 242 ranges = outranges[0 .. nRanges]; 243 } 244 }