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 = PgAttributeIterator
29  * strct   = PangoAttrIterator
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgAttributeIterator
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_attr_iterator_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- pango.PgAttribute
47  * 	- pango.PgFontDescription
48  * 	- pango.PgLanguage
49  * 	- glib.ListSG
50  * structWrap:
51  * 	- GSList* -> ListSG
52  * 	- PangoAttrIterator* -> PgAttributeIterator
53  * 	- PangoAttribute* -> PgAttribute
54  * 	- PangoFontDescription* -> PgFontDescription
55  * 	- PangoLanguage* -> PgLanguage
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60 
61 module pango.PgAttributeIterator;
62 
63 public  import gtkc.pangotypes;
64 
65 private import gtkc.pango;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 private import pango.PgAttribute;
70 private import pango.PgFontDescription;
71 private import pango.PgLanguage;
72 private import glib.ListSG;
73 
74 
75 
76 /**
77  * Attributed text is used in a number of places in Pango. It
78  * is used as the input to the itemization process and also when
79  * creating a PangoLayout. The data types and functions in
80  * this section are used to represent and manipulate sets
81  * of attributes applied to a portion of text.
82  */
83 public class PgAttributeIterator
84 {
85 	
86 	/** the main Gtk struct */
87 	protected PangoAttrIterator* pangoAttrIterator;
88 	
89 	
90 	/** Get the main Gtk struct */
91 	public PangoAttrIterator* getPgAttributeIteratorStruct()
92 	{
93 		return pangoAttrIterator;
94 	}
95 	
96 	
97 	/** the main Gtk struct as a void* */
98 	protected void* getStruct()
99 	{
100 		return cast(void*)pangoAttrIterator;
101 	}
102 	
103 	/**
104 	 * Sets our main struct and passes it to the parent class
105 	 */
106 	public this (PangoAttrIterator* pangoAttrIterator)
107 	{
108 		this.pangoAttrIterator = pangoAttrIterator;
109 	}
110 	
111 	/**
112 	 */
113 	
114 	/**
115 	 * Copy a PangoAttrIterator
116 	 * Returns: the newly allocated PangoAttrIterator, which should be freed with pango_attr_iterator_destroy(). [transfer full]
117 	 */
118 	public PgAttributeIterator copy()
119 	{
120 		// PangoAttrIterator * pango_attr_iterator_copy (PangoAttrIterator *iterator);
121 		auto p = pango_attr_iterator_copy(pangoAttrIterator);
122 		
123 		if(p is null)
124 		{
125 			return null;
126 		}
127 		
128 		return ObjectG.getDObject!(PgAttributeIterator)(cast(PangoAttrIterator*) p);
129 	}
130 	
131 	/**
132 	 * Advance the iterator until the next change of style.
133 	 * Returns: FALSE if the iterator is at the end of the list, otherwise TRUE
134 	 */
135 	public int next()
136 	{
137 		// gboolean pango_attr_iterator_next (PangoAttrIterator *iterator);
138 		return pango_attr_iterator_next(pangoAttrIterator);
139 	}
140 	
141 	/**
142 	 * Get the range of the current segment. Note that the
143 	 * stored return values are signed, not unsigned like
144 	 * the values in PangoAttribute. To deal with this API
145 	 * oversight, stored return values that wouldn't fit into
146 	 * a signed integer are clamped to G_MAXINT.
147 	 * Params:
148 	 * start = location to store the start of the range. [out]
149 	 * end = location to store the end of the range. [out]
150 	 */
151 	public void range(out int start, out int end)
152 	{
153 		// void pango_attr_iterator_range (PangoAttrIterator *iterator,  gint *start,  gint *end);
154 		pango_attr_iterator_range(pangoAttrIterator, &start, &end);
155 	}
156 	
157 	/**
158 	 * Find the current attribute of a particular type at the iterator
159 	 * location. When multiple attributes of the same type overlap,
160 	 * the attribute whose range starts closest to the current location
161 	 * is used.
162 	 * Params:
163 	 * type = the type of attribute to find.
164 	 * Returns: the current attribute of the given type, or NULL if no attribute of that type applies to the current location.
165 	 */
166 	public PgAttribute get(PangoAttrType type)
167 	{
168 		// PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator,  PangoAttrType type);
169 		auto p = pango_attr_iterator_get(pangoAttrIterator, type);
170 		
171 		if(p is null)
172 		{
173 			return null;
174 		}
175 		
176 		return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p);
177 	}
178 	
179 	/**
180 	 * Get the font and other attributes at the current iterator position.
181 	 * Params:
182 	 * desc = a PangoFontDescription to fill in with the current values.
183 	 * The family name in this structure will be set using
184 	 * pango_font_description_set_family_static() using values from
185 	 * an attribute in the PangoAttrList associated with the iterator,
186 	 * language = if non-NULL, location to store language tag for item, or NULL
187 	 * if none is found. [allow-none]
188 	 * extraAttrs = if non-NULL,
189 	 * location in which to store a list of non-font
190 	 * attributes at the the current position; only the highest priority
191 	 * value of each attribute will be added to this list. In order
192 	 * to free this value, you must call pango_attribute_destroy() on
193 	 * each member. [allow-none][element-type Pango.Attribute][transfer full]
194 	 */
195 	public void getFont(PgFontDescription desc, out PgLanguage language, out ListSG extraAttrs)
196 	{
197 		// void pango_attr_iterator_get_font (PangoAttrIterator *iterator,  PangoFontDescription *desc,  PangoLanguage **language,  GSList **extra_attrs);
198 		PangoLanguage* outlanguage = null;
199 		GSList* outextraAttrs = null;
200 		
201 		pango_attr_iterator_get_font(pangoAttrIterator, (desc is null) ? null : desc.getPgFontDescriptionStruct(), &outlanguage, &outextraAttrs);
202 		
203 		language = ObjectG.getDObject!(PgLanguage)(outlanguage);
204 		extraAttrs = ObjectG.getDObject!(ListSG)(outextraAttrs);
205 	}
206 	
207 	/**
208 	 * Gets a list of all attributes at the current position of the
209 	 * iterator.
210 	 * Since 1.2
211 	 * Returns: a list of all attributes for the current range. To free this value, call pango_attribute_destroy() on each value and g_slist_free() on the list. [element-type Pango.Attribute][transfer full]
212 	 */
213 	public ListSG getAttrs()
214 	{
215 		// GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
216 		auto p = pango_attr_iterator_get_attrs(pangoAttrIterator);
217 		
218 		if(p is null)
219 		{
220 			return null;
221 		}
222 		
223 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
224 	}
225 	
226 	/**
227 	 * Destroy a PangoAttrIterator and free all associated memory.
228 	 */
229 	public void destroy()
230 	{
231 		// void pango_attr_iterator_destroy (PangoAttrIterator *iterator);
232 		pango_attr_iterator_destroy(pangoAttrIterator);
233 	}
234 }