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