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