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