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.PgItem;
26 
27 private import glib.ConstructionException;
28 private import glib.c.functions;
29 private import gobject.ObjectG;
30 public  import gtkc.pangotypes;
31 private import gtkd.Loader;
32 private import pango.c.functions;
33 public  import pango.c.types;
34 
35 
36 /**
37  * The #PangoItem structure stores information about a segment of text.
38  */
39 public final class PgItem
40 {
41 	/** the main Gtk struct */
42 	protected PangoItem* pangoItem;
43 	protected bool ownedRef;
44 
45 	/** Get the main Gtk struct */
46 	public PangoItem* getPgItemStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return pangoItem;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected void* getStruct()
55 	{
56 		return cast(void*)pangoItem;
57 	}
58 
59 	/**
60 	 * Sets our main struct and passes it to the parent class.
61 	 */
62 	public this (PangoItem* pangoItem, bool ownedRef = false)
63 	{
64 		this.pangoItem = pangoItem;
65 		this.ownedRef = ownedRef;
66 	}
67 
68 	~this ()
69 	{
70 		if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef )
71 			pango_item_free(pangoItem);
72 	}
73 
74 
75 	/**
76 	 * byte offset of the start of this item in text.
77 	 */
78 	public @property int offset()
79 	{
80 		return pangoItem.offset;
81 	}
82 
83 	/** Ditto */
84 	public @property void offset(int value)
85 	{
86 		pangoItem.offset = value;
87 	}
88 
89 	/**
90 	 * length of this item in bytes.
91 	 */
92 	public @property int length()
93 	{
94 		return pangoItem.length;
95 	}
96 
97 	/** Ditto */
98 	public @property void length(int value)
99 	{
100 		pangoItem.length = value;
101 	}
102 
103 	/**
104 	 * number of Unicode characters in the item.
105 	 */
106 	public @property int numChars()
107 	{
108 		return pangoItem.numChars;
109 	}
110 
111 	/** Ditto */
112 	public @property void numChars(int value)
113 	{
114 		pangoItem.numChars = value;
115 	}
116 
117 	/**
118 	 * analysis results for the item.
119 	 */
120 	public @property PangoAnalysis analysis()
121 	{
122 		return pangoItem.analysis;
123 	}
124 
125 	/** Ditto */
126 	public @property void analysis(PangoAnalysis value)
127 	{
128 		pangoItem.analysis = value;
129 	}
130 
131 	/** */
132 	public static GType getType()
133 	{
134 		return pango_item_get_type();
135 	}
136 
137 	/**
138 	 * Creates a new #PangoItem structure initialized to default values.
139 	 *
140 	 * Returns: the newly allocated #PangoItem, which should
141 	 *     be freed with pango_item_free().
142 	 *
143 	 * Throws: ConstructionException GTK+ fails to create the object.
144 	 */
145 	public this()
146 	{
147 		auto p = pango_item_new();
148 
149 		if(p is null)
150 		{
151 			throw new ConstructionException("null returned by new");
152 		}
153 
154 		this(cast(PangoItem*) p);
155 	}
156 
157 	/**
158 	 * Copy an existing #PangoItem structure.
159 	 *
160 	 * Returns: the newly allocated #PangoItem, which
161 	 *     should be freed with pango_item_free(), or %NULL if
162 	 *     @item was %NULL.
163 	 */
164 	public PgItem copy()
165 	{
166 		auto p = pango_item_copy(pangoItem);
167 
168 		if(p is null)
169 		{
170 			return null;
171 		}
172 
173 		return ObjectG.getDObject!(PgItem)(cast(PangoItem*) p, true);
174 	}
175 
176 	/**
177 	 * Free a #PangoItem and all associated memory.
178 	 */
179 	public void free()
180 	{
181 		pango_item_free(pangoItem);
182 		ownedRef = false;
183 	}
184 
185 	/**
186 	 * Modifies @orig to cover only the text after @split_index, and
187 	 * returns a new item that covers the text before @split_index that
188 	 * used to be in @orig. You can think of @split_index as the length of
189 	 * the returned item. @split_index may not be 0, and it may not be
190 	 * greater than or equal to the length of @orig (that is, there must
191 	 * be at least one byte assigned to each item, you can't create a
192 	 * zero-length item). @split_offset is the length of the first item in
193 	 * chars, and must be provided because the text used to generate the
194 	 * item isn't available, so pango_item_split() can't count the char
195 	 * length of the split items itself.
196 	 *
197 	 * Params:
198 	 *     splitIndex = byte index of position to split item, relative to the start of the item
199 	 *     splitOffset = number of chars between start of @orig and @split_index
200 	 *
201 	 * Returns: new item representing text before @split_index, which
202 	 *     should be freed with pango_item_free().
203 	 */
204 	public PgItem split(int splitIndex, int splitOffset)
205 	{
206 		auto p = pango_item_split(pangoItem, splitIndex, splitOffset);
207 
208 		if(p is null)
209 		{
210 			return null;
211 		}
212 
213 		return ObjectG.getDObject!(PgItem)(cast(PangoItem*) p, true);
214 	}
215 }