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