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