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 = PgAttributeList
29  * strct   = PangoAttrList
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgAttributeList
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_attr_list_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- pango.PgAttribute
47  * 	- pango.PgAttributeIterator
48  * structWrap:
49  * 	- PangoAttrIterator* -> PgAttributeIterator
50  * 	- PangoAttrList* -> PgAttributeList
51  * 	- PangoAttribute* -> PgAttribute
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module pango.PgAttributeList;
58 
59 public  import gtkc.pangotypes;
60 
61 private import gtkc.pango;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 
66 private import pango.PgAttribute;
67 private import pango.PgAttributeIterator;
68 
69 
70 
71 
72 /**
73  * Description
74  * Attributed text is used in a number of places in Pango. It
75  * is used as the input to the itemization process and also when
76  * creating a PangoLayout. The data types and functions in
77  * this section are used to represent and manipulate sets
78  * of attributes applied to a portion of text.
79  */
80 public class PgAttributeList
81 {
82 	
83 	/** the main Gtk struct */
84 	protected PangoAttrList* pangoAttrList;
85 	
86 	
87 	public PangoAttrList* getPgAttributeListStruct()
88 	{
89 		return pangoAttrList;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected void* getStruct()
95 	{
96 		return cast(void*)pangoAttrList;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (PangoAttrList* pangoAttrList)
103 	{
104 		this.pangoAttrList = pangoAttrList;
105 	}
106 	
107 	/**
108 	 */
109 	
110 	/**
111 	 * Create a new empty attribute list with a reference count of one.
112 	 * Throws: ConstructionException GTK+ fails to create the object.
113 	 */
114 	public this ()
115 	{
116 		// PangoAttrList * pango_attr_list_new (void);
117 		auto p = pango_attr_list_new();
118 		if(p is null)
119 		{
120 			throw new ConstructionException("null returned by pango_attr_list_new()");
121 		}
122 		this(cast(PangoAttrList*) p);
123 	}
124 	
125 	/**
126 	 * Increase the reference count of the given attribute list by one.
127 	 * Since 1.10
128 	 * Returns: The attribute list passed in
129 	 */
130 	public PgAttributeList doref()
131 	{
132 		// PangoAttrList * pango_attr_list_ref (PangoAttrList *list);
133 		auto p = pango_attr_list_ref(pangoAttrList);
134 		
135 		if(p is null)
136 		{
137 			return null;
138 		}
139 		
140 		return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p);
141 	}
142 	
143 	/**
144 	 * Decrease the reference count of the given attribute list by one.
145 	 * If the result is zero, free the attribute list and the attributes
146 	 * it contains.
147 	 */
148 	public void unref()
149 	{
150 		// void pango_attr_list_unref (PangoAttrList *list);
151 		pango_attr_list_unref(pangoAttrList);
152 	}
153 	
154 	/**
155 	 * Copy list and return an identical new list.
156 	 * Returns: the newly allocated PangoAttrList, with a reference count of one, which should be freed with pango_attr_list_unref(). Returns NULL if list was NULL.
157 	 */
158 	public PgAttributeList copy()
159 	{
160 		// PangoAttrList * pango_attr_list_copy (PangoAttrList *list);
161 		auto p = pango_attr_list_copy(pangoAttrList);
162 		
163 		if(p is null)
164 		{
165 			return null;
166 		}
167 		
168 		return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p);
169 	}
170 	
171 	/**
172 	 * Insert the given attribute into the PangoAttrList. It will
173 	 * be inserted after all other attributes with a matching
174 	 * start_index.
175 	 * Params:
176 	 * attr = the attribute to insert. Ownership of this value is
177 	 *  assumed by the list.
178 	 */
179 	public void insert(PgAttribute attr)
180 	{
181 		// void pango_attr_list_insert (PangoAttrList *list,  PangoAttribute *attr);
182 		pango_attr_list_insert(pangoAttrList, (attr is null) ? null : attr.getPgAttributeStruct());
183 	}
184 	
185 	/**
186 	 * Insert the given attribute into the PangoAttrList. It will
187 	 * be inserted before all other attributes with a matching
188 	 * start_index.
189 	 * Params:
190 	 * attr = the attribute to insert. Ownership of this value is
191 	 *  assumed by the list.
192 	 */
193 	public void insertBefore(PgAttribute attr)
194 	{
195 		// void pango_attr_list_insert_before (PangoAttrList *list,  PangoAttribute *attr);
196 		pango_attr_list_insert_before(pangoAttrList, (attr is null) ? null : attr.getPgAttributeStruct());
197 	}
198 	
199 	/**
200 	 * Insert the given attribute into the PangoAttrList. It will
201 	 * replace any attributes of the same type on that segment
202 	 * and be merged with any adjoining attributes that are identical.
203 	 * This function is slower than pango_attr_list_insert() for
204 	 * creating a attribute list in order (potentially much slower
205 	 * for large lists). However, pango_attr_list_insert() is not
206 	 * suitable for continually changing a set of attributes
207 	 * since it never removes or combines existing attributes.
208 	 * Params:
209 	 * attr = the attribute to insert. Ownership of this value is
210 	 *  assumed by the list.
211 	 */
212 	public void change(PgAttribute attr)
213 	{
214 		// void pango_attr_list_change (PangoAttrList *list,  PangoAttribute *attr);
215 		pango_attr_list_change(pangoAttrList, (attr is null) ? null : attr.getPgAttributeStruct());
216 	}
217 	
218 	/**
219 	 * This function opens up a hole in list, fills it in with attributes from
220 	 * the left, and then merges other on top of the hole.
221 	 * This operation is equivalent to stretching every attribute
222 	 * that applies at position pos in list by an amount len,
223 	 * and then calling pango_attr_list_change() with a copy
224 	 * of each attribute in other in sequence (offset in position by pos).
225 	 * This operation proves useful for, for instance, inserting
226 	 * a pre-edit string in the middle of an edit buffer.
227 	 * Params:
228 	 * other = another PangoAttrList
229 	 * pos = the position in list at which to insert other
230 	 * len = the length of the spliced segment. (Note that this
231 	 *  must be specified since the attributes in other
232 	 *  may only be present at some subsection of this range)
233 	 */
234 	public void splice(PgAttributeList other, int pos, int len)
235 	{
236 		// void pango_attr_list_splice (PangoAttrList *list,  PangoAttrList *other,  gint pos,  gint len);
237 		pango_attr_list_splice(pangoAttrList, (other is null) ? null : other.getPgAttributeListStruct(), pos, len);
238 	}
239 	
240 	/**
241 	 * Given a PangoAttrList and callback function, removes any elements
242 	 * of list for which func returns TRUE and inserts them into
243 	 * a new list.
244 	 * Since 1.2
245 	 * Params:
246 	 * func = callback function; returns TRUE if an attribute
247 	 *  should be filtered out.
248 	 * data = Data to be passed to func
249 	 * Returns: the new PangoAttrList or NULL if no attributes of the given types were found.
250 	 */
251 	public PgAttributeList filter(PangoAttrFilterFunc func, void* data)
252 	{
253 		// PangoAttrList * pango_attr_list_filter (PangoAttrList *list,  PangoAttrFilterFunc func,  gpointer data);
254 		auto p = pango_attr_list_filter(pangoAttrList, func, data);
255 		
256 		if(p is null)
257 		{
258 			return null;
259 		}
260 		
261 		return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p);
262 	}
263 	
264 	/**
265 	 * Create a iterator initialized to the beginning of the list.
266 	 * list must not be modified until this iterator is freed.
267 	 * Returns: the newly allocated PangoAttrIterator, which should be freed with pango_attr_iterator_destroy().
268 	 */
269 	public PgAttributeIterator getIterator()
270 	{
271 		// PangoAttrIterator * pango_attr_list_get_iterator (PangoAttrList *list);
272 		auto p = pango_attr_list_get_iterator(pangoAttrList);
273 		
274 		if(p is null)
275 		{
276 			return null;
277 		}
278 		
279 		return ObjectG.getDObject!(PgAttributeIterator)(cast(PangoAttrIterator*) p);
280 	}
281 }