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