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