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