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.PgTabArray;
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  * A #PangoTabArray struct contains an array
36  * of tab stops. Each tab stop has an alignment and a position.
37  */
38 public class PgTabArray
39 {
40 	/** the main Gtk struct */
41 	protected PangoTabArray* pangoTabArray;
42 	protected bool ownedRef;
43 
44 	/** Get the main Gtk struct */
45 	public PangoTabArray* getPgTabArrayStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return pangoTabArray;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected void* getStruct()
54 	{
55 		return cast(void*)pangoTabArray;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (PangoTabArray* pangoTabArray, bool ownedRef = false)
62 	{
63 		this.pangoTabArray = pangoTabArray;
64 		this.ownedRef = ownedRef;
65 	}
66 
67 	~this ()
68 	{
69 		if (  Linker.isLoaded(LIBRARY_PANGO) && ownedRef )
70 			pango_tab_array_free(pangoTabArray);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return pango_tab_array_get_type();
78 	}
79 
80 	/**
81 	 * Creates an array of @initial_size tab stops. Tab stops are specified in
82 	 * pixel units if @positions_in_pixels is %TRUE, otherwise in Pango
83 	 * units. All stops are initially at position 0.
84 	 *
85 	 * Params:
86 	 *     initialSize = Initial number of tab stops to allocate, can be 0
87 	 *     positionsInPixels = whether positions are in pixel units
88 	 *
89 	 * Returns: the newly allocated #PangoTabArray, which should
90 	 *     be freed with pango_tab_array_free().
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 */
94 	public this(int initialSize, bool positionsInPixels)
95 	{
96 		auto p = pango_tab_array_new(initialSize, positionsInPixels);
97 		
98 		if(p is null)
99 		{
100 			throw new ConstructionException("null returned by new");
101 		}
102 		
103 		this(cast(PangoTabArray*) p);
104 	}
105 
106 	/**
107 	 * Copies a #PangoTabArray
108 	 *
109 	 * Returns: the newly allocated #PangoTabArray, which should
110 	 *     be freed with pango_tab_array_free().
111 	 */
112 	public PgTabArray copy()
113 	{
114 		auto p = pango_tab_array_copy(pangoTabArray);
115 		
116 		if(p is null)
117 		{
118 			return null;
119 		}
120 		
121 		return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) p, true);
122 	}
123 
124 	/**
125 	 * Frees a tab array and associated resources.
126 	 */
127 	public void free()
128 	{
129 		pango_tab_array_free(pangoTabArray);
130 		ownedRef = false;
131 	}
132 
133 	/**
134 	 * Returns %TRUE if the tab positions are in pixels, %FALSE if they are
135 	 * in Pango units.
136 	 *
137 	 * Returns: whether positions are in pixels.
138 	 */
139 	public bool getPositionsInPixels()
140 	{
141 		return pango_tab_array_get_positions_in_pixels(pangoTabArray) != 0;
142 	}
143 
144 	/**
145 	 * Gets the number of tab stops in @tab_array.
146 	 *
147 	 * Returns: the number of tab stops in the array.
148 	 */
149 	public int getSize()
150 	{
151 		return pango_tab_array_get_size(pangoTabArray);
152 	}
153 
154 	/**
155 	 * Gets the alignment and position of a tab stop.
156 	 *
157 	 * Params:
158 	 *     tabIndex = tab stop index
159 	 *     alignment = location to store alignment, or %NULL
160 	 *     location = location to store tab position, or %NULL
161 	 */
162 	public void getTab(int tabIndex, out PangoTabAlign alignment, out int location)
163 	{
164 		pango_tab_array_get_tab(pangoTabArray, tabIndex, &alignment, &location);
165 	}
166 
167 	/**
168 	 * If non-%NULL, @alignments and @locations are filled with allocated
169 	 * arrays of length pango_tab_array_get_size(). You must free the
170 	 * returned array.
171 	 *
172 	 * Params:
173 	 *     alignments = location to store an array of tab
174 	 *         stop alignments, or %NULL
175 	 *     locations = location to store an array
176 	 *         of tab positions, or %NULL
177 	 */
178 	public void getTabs(out PangoTabAlign* alignments, out int[] locations)
179 	{
180 		int* outlocations = null;
181 		
182 		pango_tab_array_get_tabs(pangoTabArray, &alignments, &outlocations);
183 		
184 		locations = outlocations[0 .. getArrayLength(outlocations)];
185 	}
186 
187 	/**
188 	 * Resizes a tab array. You must subsequently initialize any tabs that
189 	 * were added as a result of growing the array.
190 	 *
191 	 * Params:
192 	 *     newSize = new size of the array
193 	 */
194 	public void resize(int newSize)
195 	{
196 		pango_tab_array_resize(pangoTabArray, newSize);
197 	}
198 
199 	/**
200 	 * Sets the alignment and location of a tab stop.
201 	 * @alignment must always be #PANGO_TAB_LEFT in the current
202 	 * implementation.
203 	 *
204 	 * Params:
205 	 *     tabIndex = the index of a tab stop
206 	 *     alignment = tab alignment
207 	 *     location = tab location in Pango units
208 	 */
209 	public void setTab(int tabIndex, PangoTabAlign alignment, int location)
210 	{
211 		pango_tab_array_set_tab(pangoTabArray, tabIndex, alignment, location);
212 	}
213 }