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