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