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 = PgGlyphString
29  * strct   = PangoGlyphString
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgGlyphString
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_glyph_string_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- pango.PgFont
48  * structWrap:
49  * 	- PangoFont* -> PgFont
50  * 	- PangoGlyphString* -> PgGlyphString
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module pango.PgGlyphString;
57 
58 public  import gtkc.pangotypes;
59 
60 private import gtkc.pango;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 
65 private import glib.Str;
66 private import pango.PgFont;
67 
68 
69 
70 
71 /**
72  * Description
73  * pango_shape() produces a string of glyphs which
74  * can be measured or drawn to the screen. The following
75  * structures are used to store information about
76  * glyphs.
77  */
78 public class PgGlyphString
79 {
80 	
81 	/** the main Gtk struct */
82 	protected PangoGlyphString* pangoGlyphString;
83 	
84 	
85 	public PangoGlyphString* getPgGlyphStringStruct()
86 	{
87 		return pangoGlyphString;
88 	}
89 	
90 	
91 	/** the main Gtk struct as a void* */
92 	protected void* getStruct()
93 	{
94 		return cast(void*)pangoGlyphString;
95 	}
96 	
97 	/**
98 	 * Sets our main struct and passes it to the parent class
99 	 */
100 	public this (PangoGlyphString* pangoGlyphString)
101 	{
102 		this.pangoGlyphString = pangoGlyphString;
103 	}
104 	
105 	/**
106 	 */
107 	
108 	/**
109 	 * Create a new PangoGlyphString.
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this ()
113 	{
114 		// PangoGlyphString * pango_glyph_string_new (void);
115 		auto p = pango_glyph_string_new();
116 		if(p is null)
117 		{
118 			throw new ConstructionException("null returned by pango_glyph_string_new()");
119 		}
120 		this(cast(PangoGlyphString*) p);
121 	}
122 	
123 	/**
124 	 * Copy a glyph string and associated storage.
125 	 * Returns: the newly allocated PangoGlyphString, which should be freed with pango_glyph_string_free(), or NULL if string was NULL.
126 	 */
127 	public PgGlyphString copy()
128 	{
129 		// PangoGlyphString * pango_glyph_string_copy (PangoGlyphString *string);
130 		auto p = pango_glyph_string_copy(pangoGlyphString);
131 		
132 		if(p is null)
133 		{
134 			return null;
135 		}
136 		
137 		return ObjectG.getDObject!(PgGlyphString)(cast(PangoGlyphString*) p);
138 	}
139 	
140 	/**
141 	 * Resize a glyph string to the given length.
142 	 * Params:
143 	 * newLen = the new length of the string.
144 	 */
145 	public void setSize(int newLen)
146 	{
147 		// void pango_glyph_string_set_size (PangoGlyphString *string,  gint new_len);
148 		pango_glyph_string_set_size(pangoGlyphString, newLen);
149 	}
150 	
151 	/**
152 	 * Free a glyph string and associated storage.
153 	 */
154 	public void free()
155 	{
156 		// void pango_glyph_string_free (PangoGlyphString *string);
157 		pango_glyph_string_free(pangoGlyphString);
158 	}
159 	
160 	/**
161 	 * Compute the logical and ink extents of a glyph string. See the documentation
162 	 * for pango_font_get_glyph_extents() for details about the interpretation
163 	 * of the rectangles.
164 	 * Params:
165 	 * font = a PangoFont
166 	 * inkRect = rectangle used to store the extents of the glyph string as drawn
167 	 *  or NULL to indicate that the result is not needed.
168 	 * logicalRect = rectangle used to store the logical extents of the glyph string
169 	 *  or NULL to indicate that the result is not needed.
170 	 */
171 	public void extents(PgFont font, PangoRectangle* inkRect, PangoRectangle* logicalRect)
172 	{
173 		// void pango_glyph_string_extents (PangoGlyphString *glyphs,  PangoFont *font,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
174 		pango_glyph_string_extents(pangoGlyphString, (font is null) ? null : font.getPgFontStruct(), inkRect, logicalRect);
175 	}
176 	
177 	/**
178 	 * Computes the extents of a sub-portion of a glyph string. The extents are
179 	 * relative to the start of the glyph string range (the origin of their
180 	 * coordinate system is at the start of the range, not at the start of the entire
181 	 * glyph string).
182 	 * Params:
183 	 * start = start index
184 	 * end = end index (the range is the set of bytes with
185 	 * 	 indices such that start <= index < end)
186 	 * font = a PangoFont
187 	 * inkRect = rectangle used to store the extents of the glyph string range as drawn
188 	 *  or NULL to indicate that the result is not needed.
189 	 * logicalRect = rectangle used to store the logical extents of the glyph string range
190 	 *  or NULL to indicate that the result is not needed.
191 	 */
192 	public void extentsRange(int start, int end, PgFont font, PangoRectangle* inkRect, PangoRectangle* logicalRect)
193 	{
194 		// void pango_glyph_string_extents_range (PangoGlyphString *glyphs,  int start,  int end,  PangoFont *font,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
195 		pango_glyph_string_extents_range(pangoGlyphString, start, end, (font is null) ? null : font.getPgFontStruct(), inkRect, logicalRect);
196 	}
197 	
198 	/**
199 	 * Computes the logical width of the glyph string as can also be computed
200 	 * using pango_glyph_string_extents(). However, since this only computes the
201 	 * width, it's much faster. This is in fact only a convenience function that
202 	 * computes the sum of geometry.width for each glyph in the glyphs.
203 	 * Since 1.14
204 	 * Returns: the logical width of the glyph string.
205 	 */
206 	public int getWidth()
207 	{
208 		// int pango_glyph_string_get_width (PangoGlyphString *glyphs);
209 		return pango_glyph_string_get_width(pangoGlyphString);
210 	}
211 	
212 	/**
213 	 * Converts from character position to x position. (X position
214 	 * is measured from the left edge of the run). Character positions
215 	 * are computed by dividing up each cluster into equal portions.
216 	 * Params:
217 	 * text = the text for the run
218 	 * length = the number of bytes (not characters) in text.
219 	 * analysis = the analysis information return from pango_itemize()
220 	 * index = the byte index within text
221 	 * trailing = whether we should compute the result for the beginning (FALSE)
222 	 *  or end (TRUE) of the character.
223 	 * xPos = location to store result
224 	 */
225 	public void indexToX(string text, int length, PangoAnalysis* analysis, int index, int trailing, out int xPos)
226 	{
227 		// void pango_glyph_string_index_to_x (PangoGlyphString *glyphs,  char *text,  int length,  PangoAnalysis *analysis,  int index_,  gboolean trailing,  int *x_pos);
228 		pango_glyph_string_index_to_x(pangoGlyphString, Str.toStringz(text), length, analysis, index, trailing, &xPos);
229 	}
230 	
231 	/**
232 	 * Convert from x offset to character position. Character positions
233 	 * are computed by dividing up each cluster into equal portions.
234 	 * In scripts where positioning within a cluster is not allowed
235 	 * (such as Thai), the returned value may not be a valid cursor
236 	 * position; the caller must combine the result with the logical
237 	 * attributes for the text to compute the valid cursor position.
238 	 * Params:
239 	 * text = the text for the run
240 	 * length = the number of bytes (not characters) in text.
241 	 * analysis = the analysis information return from pango_itemize()
242 	 * xPos = the x offset (in Pango units)
243 	 * index = location to store calculated byte index within text
244 	 * trailing = location to store a boolean indicating
245 	 *  whether the user clicked on the leading or trailing
246 	 *  edge of the character.
247 	 */
248 	public void xToIndex(string text, int length, PangoAnalysis* analysis, int xPos, out int index, out int trailing)
249 	{
250 		// void pango_glyph_string_x_to_index (PangoGlyphString *glyphs,  char *text,  int length,  PangoAnalysis *analysis,  int x_pos,  int *index_,  int *trailing);
251 		pango_glyph_string_x_to_index(pangoGlyphString, Str.toStringz(text), length, analysis, xPos, &index, &trailing);
252 	}
253 	
254 	/**
255 	 * Given a PangoGlyphString resulting from pango_shape() and the corresponding
256 	 * text, determine the screen width corresponding to each character. When
257 	 * multiple characters compose a single cluster, the width of the entire
258 	 * cluster is divided equally among the characters.
259 	 * See also pango_glyph_item_get_logical_widths().
260 	 * Params:
261 	 * text = the text corresponding to the glyphs
262 	 * length = the length of text, in bytes
263 	 * embeddingLevel = the embedding level of the string
264 	 * logicalWidths = an array whose length is the number of characters in
265 	 *  text (equal to g_utf8_strlen (text, length) unless
266 	 *  text has NUL bytes)
267 	 *  to be filled in with the resulting character widths.
268 	 */
269 	public void getLogicalWidths(string text, int length, int embeddingLevel, int* logicalWidths)
270 	{
271 		// void pango_glyph_string_get_logical_widths  (PangoGlyphString *glyphs,  const char *text,  int length,  int embedding_level,  int *logical_widths);
272 		pango_glyph_string_get_logical_widths(pangoGlyphString, Str.toStringz(text), length, embeddingLevel, logicalWidths);
273 	}
274 }