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 = PgGlyphItem
29  * strct   = PangoGlyphItem
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgGlyphItem
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_glyph_item_
41  * omit structs:
42  * omit prefixes:
43  * 	- pango_glyph_item_iter_
44  * omit code:
45  * 	- pango_glyph_item_get_logical_widths
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- pango.PgAttributeList
50  * 	- glib.ListSG
51  * structWrap:
52  * 	- GSList* -> ListSG
53  * 	- PangoAttrList* -> PgAttributeList
54  * 	- PangoGlyphItem* -> PgGlyphItem
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module pango.PgGlyphItem;
61 
62 public  import gtkc.pangotypes;
63 
64 private import gtkc.pango;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 
69 private import glib.Str;
70 private import pango.PgAttributeList;
71 private import glib.ListSG;
72 
73 
74 
75 
76 /**
77  * Description
78  * pango_shape() produces a string of glyphs which
79  * can be measured or drawn to the screen. The following
80  * structures are used to store information about
81  * glyphs.
82  */
83 public class PgGlyphItem
84 {
85 	
86 	/** the main Gtk struct */
87 	protected PangoGlyphItem* pangoGlyphItem;
88 	
89 	
90 	public PangoGlyphItem* getPgGlyphItemStruct()
91 	{
92 		return pangoGlyphItem;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected void* getStruct()
98 	{
99 		return cast(void*)pangoGlyphItem;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (PangoGlyphItem* pangoGlyphItem)
106 	{
107 		this.pangoGlyphItem = pangoGlyphItem;
108 	}
109 	
110 	/**
111 	 * Given a PangoGlyphItem and the corresponding
112 	 * text, determine the screen width corresponding to each character. When
113 	 * multiple characters compose a single cluster, the width of the entire
114 	 * cluster is divided equally among the characters.
115 	 * See also pango_glyph_string_get_logical_widths().
116 	 * Since 1.26
117 	 * Params:
118 	 * text =  text that glyph_item corresponds to
119 	 *  (glyph_item->item->offset is an offset from the
120 	 *  start of text)
121 	 * logicalWidths =  an array whose length is the number of characters in
122 	 *  glyph_item (equal to glyph_item->item->num_chars)
123 	 *  to be filled in with the resulting character widths.
124 	 */
125 	public void getLogicalWidths(string text, out int[] logicalWidths)
126 	{
127 		logicalWidths = new int[pangoGlyphItem.item.numChars];
128 		
129 		// void pango_glyph_item_get_logical_widths (PangoGlyphItem *glyph_item,  const char *text,  int *logical_widths);
130 		pango_glyph_item_get_logical_widths(pangoGlyphItem, Str.toStringz(text), logicalWidths.ptr);
131 	}
132 	
133 	/**
134 	 */
135 	
136 	/**
137 	 * Make a deep copy of an existing PangoGlyphItem structure.
138 	 * Since 1.20
139 	 * Returns: the newly allocated PangoGlyphItem, which should be freed with pango_glyph_item_free(), or NULL if orig was NULL.
140 	 */
141 	public PgGlyphItem copy()
142 	{
143 		// PangoGlyphItem * pango_glyph_item_copy (PangoGlyphItem *orig);
144 		auto p = pango_glyph_item_copy(pangoGlyphItem);
145 		
146 		if(p is null)
147 		{
148 			return null;
149 		}
150 		
151 		return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) p);
152 	}
153 	
154 	/**
155 	 * Frees a PangoGlyphItem and resources to which it points.
156 	 * Since 1.6
157 	 */
158 	public void free()
159 	{
160 		// void pango_glyph_item_free (PangoGlyphItem *glyph_item);
161 		pango_glyph_item_free(pangoGlyphItem);
162 	}
163 	
164 	/**
165 	 * Modifies orig to cover only the text after split_index, and
166 	 * returns a new item that covers the text before split_index that
167 	 * used to be in orig. You can think of split_index as the length of
168 	 * the returned item. split_index may not be 0, and it may not be
169 	 * greater than or equal to the length of orig (that is, there must
170 	 * be at least one byte assigned to each item, you can't create a
171 	 * zero-length item).
172 	 * This function is similar in function to pango_item_split() (and uses
173 	 * it internally.)
174 	 * Since 1.2
175 	 * Params:
176 	 * text = text to which positions in orig apply
177 	 * splitIndex = byte index of position to split item, relative to the start of the item
178 	 * Returns: the newly allocated item representing text before split_index, which should be freed with pango_glyph_item_free().
179 	 */
180 	public PgGlyphItem split(string text, int splitIndex)
181 	{
182 		// PangoGlyphItem * pango_glyph_item_split (PangoGlyphItem *orig,  const char *text,  int split_index);
183 		auto p = pango_glyph_item_split(pangoGlyphItem, Str.toStringz(text), splitIndex);
184 		
185 		if(p is null)
186 		{
187 			return null;
188 		}
189 		
190 		return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) p);
191 	}
192 	
193 	/**
194 	 * Splits a shaped item (PangoGlyphItem) into multiple items based
195 	 * on an attribute list. The idea is that if you have attributes
196 	 * that don't affect shaping, such as color or underline, to avoid
197 	 * affecting shaping, you filter them out (pango_attr_list_filter()),
198 	 * apply the shaping process and then reapply them to the result using
199 	 * this function.
200 	 * All attributes that start or end inside a cluster are applied
201 	 * to that cluster; for instance, if half of a cluster is underlined
202 	 * and the other-half strikethrough, then the cluster will end
203 	 * up with both underline and strikethrough attributes. In these
204 	 * cases, it may happen that item->extra_attrs for some of the
205 	 * result items can have multiple attributes of the same type.
206 	 * This function takes ownership of glyph_item; it will be reused
207 	 * as one of the elements in the list.
208 	 * Since 1.2
209 	 * Params:
210 	 * text = text that list applies to
211 	 * list = a PangoAttrList
212 	 * Returns: a list of glyph items resulting from splitting glyph_item. Free the elements using pango_glyph_item_free(), the list using g_slist_free().
213 	 */
214 	public ListSG applyAttrs(string text, PgAttributeList list)
215 	{
216 		// GSList * pango_glyph_item_apply_attrs (PangoGlyphItem *glyph_item,  const char *text,  PangoAttrList *list);
217 		auto p = pango_glyph_item_apply_attrs(pangoGlyphItem, Str.toStringz(text), (list is null) ? null : list.getPgAttributeListStruct());
218 		
219 		if(p is null)
220 		{
221 			return null;
222 		}
223 		
224 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
225 	}
226 	
227 	/**
228 	 * Adds spacing between the graphemes of glyph_item to
229 	 * give the effect of typographic letter spacing.
230 	 * Since 1.6
231 	 * Params:
232 	 * text = text that glyph_item corresponds to
233 	 *  (glyph_item->item->offset is an offset from the
234 	 *  start of text)
235 	 * logAttrs = logical attributes for the item (the
236 	 *  first logical attribute refers to the position
237 	 *  before the first character in the item)
238 	 * letterSpacing = amount of letter spacing to add
239 	 *  in Pango units. May be negative, though too large
240 	 *  negative values will give ugly results.
241 	 */
242 	public void letterSpace(string text, ref PangoLogAttr logAttrs, int letterSpacing)
243 	{
244 		// void pango_glyph_item_letter_space (PangoGlyphItem *glyph_item,  const char *text,  PangoLogAttr *log_attrs,  int letter_spacing);
245 		pango_glyph_item_letter_space(pangoGlyphItem, Str.toStringz(text), &logAttrs, letterSpacing);
246 	}
247 }