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 gobject.ObjectG;
29 private import gtkc.pango;
30 public  import gtkc.pangotypes;
31 
32 
33 /**
34  * The #PangoItem structure stores information about a segment of text.
35  */
36 public class PgItem
37 {
38 	/** the main Gtk struct */
39 	protected PangoItem* pangoItem;
40 	protected bool ownedRef;
41 
42 	/** Get the main Gtk struct */
43 	public PangoItem* getPgItemStruct()
44 	{
45 		return pangoItem;
46 	}
47 
48 	/** the main Gtk struct as a void* */
49 	protected void* getStruct()
50 	{
51 		return cast(void*)pangoItem;
52 	}
53 
54 	/**
55 	 * Sets our main struct and passes it to the parent class.
56 	 */
57 	public this (PangoItem* pangoItem, bool ownedRef = false)
58 	{
59 		this.pangoItem = pangoItem;
60 		this.ownedRef = ownedRef;
61 	}
62 
63 
64 	/** */
65 	public static GType getType()
66 	{
67 		return pango_item_get_type();
68 	}
69 
70 	/**
71 	 * Creates a new #PangoItem structure initialized to default values.
72 	 *
73 	 * Return: the newly allocated #PangoItem, which should
74 	 *     be freed with pango_item_free().
75 	 *
76 	 * Throws: ConstructionException GTK+ fails to create the object.
77 	 */
78 	public this()
79 	{
80 		auto p = pango_item_new();
81 		
82 		if(p is null)
83 		{
84 			throw new ConstructionException("null returned by new");
85 		}
86 		
87 		this(cast(PangoItem*) p);
88 	}
89 
90 	/**
91 	 * Copy an existing #PangoItem structure.
92 	 *
93 	 * Return: the newly allocated #PangoItem, which
94 	 *     should be freed with pango_item_free(), or %NULL if
95 	 *     @item was %NULL.
96 	 */
97 	public PgItem copy()
98 	{
99 		auto p = pango_item_copy(pangoItem);
100 		
101 		if(p is null)
102 		{
103 			return null;
104 		}
105 		
106 		return ObjectG.getDObject!(PgItem)(cast(PangoItem*) p, true);
107 	}
108 
109 	/**
110 	 * Free a #PangoItem and all associated memory.
111 	 */
112 	public void free()
113 	{
114 		pango_item_free(pangoItem);
115 	}
116 
117 	/**
118 	 * Modifies @orig to cover only the text after @split_index, and
119 	 * returns a new item that covers the text before @split_index that
120 	 * used to be in @orig. You can think of @split_index as the length of
121 	 * the returned item. @split_index may not be 0, and it may not be
122 	 * greater than or equal to the length of @orig (that is, there must
123 	 * be at least one byte assigned to each item, you can't create a
124 	 * zero-length item). @split_offset is the length of the first item in
125 	 * chars, and must be provided because the text used to generate the
126 	 * item isn't available, so pango_item_split() can't count the char
127 	 * length of the split items itself.
128 	 *
129 	 * Params:
130 	 *     splitIndex = byte index of position to split item, relative to the start of the item
131 	 *     splitOffset = number of chars between start of @orig and @split_index
132 	 *
133 	 * Return: new item representing text before @split_index, which
134 	 *     should be freed with pango_item_free().
135 	 */
136 	public PgItem split(int splitIndex, int splitOffset)
137 	{
138 		auto p = pango_item_split(pangoItem, splitIndex, splitOffset);
139 		
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 		
145 		return ObjectG.getDObject!(PgItem)(cast(PangoItem*) p, true);
146 	}
147 }