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