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