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  * Conversion parameters:
26  * inFile  = pango-Tab-Stops.html
27  * outPack = pango
28  * outFile = PgTabArray
29  * strct   = PangoTabArray
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgTabArray
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_tab_array_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * 	- PangoTabArray* -> PgTabArray
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module pango.PgTabArray;
54 
55 public  import gtkc.pangotypes;
56 
57 private import gtkc.pango;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 
62 
63 private import gobject.Boxed;
64 
65 /**
66  * Functions in this section are used to deal with PangoTabArray objects
67  * that can be used to set tab stop positions in a PangoLayout.
68  */
69 public class PgTabArray : Boxed
70 {
71 	
72 	/** the main Gtk struct */
73 	protected PangoTabArray* pangoTabArray;
74 	
75 	
76 	/** Get the main Gtk struct */
77 	public PangoTabArray* getPgTabArrayStruct()
78 	{
79 		return pangoTabArray;
80 	}
81 	
82 	
83 	/** the main Gtk struct as a void* */
84 	protected void* getStruct()
85 	{
86 		return cast(void*)pangoTabArray;
87 	}
88 	
89 	/**
90 	 * Sets our main struct and passes it to the parent class
91 	 */
92 	public this (PangoTabArray* pangoTabArray)
93 	{
94 		this.pangoTabArray = pangoTabArray;
95 	}
96 	
97 	/**
98 	 */
99 	
100 	/**
101 	 * Creates an array of initial_size tab stops. Tab stops are specified in
102 	 * pixel units if positions_in_pixels is TRUE, otherwise in Pango
103 	 * units. All stops are initially at position 0.
104 	 * Params:
105 	 * initialSize = Initial number of tab stops to allocate, can be 0
106 	 * positionsInPixels = whether positions are in pixel units
107 	 * Throws: ConstructionException GTK+ fails to create the object.
108 	 */
109 	public this (int initialSize, int positionsInPixels)
110 	{
111 		// PangoTabArray * pango_tab_array_new (gint initial_size,  gboolean positions_in_pixels);
112 		auto p = pango_tab_array_new(initialSize, positionsInPixels);
113 		if(p is null)
114 		{
115 			throw new ConstructionException("null returned by pango_tab_array_new(initialSize, positionsInPixels)");
116 		}
117 		this(cast(PangoTabArray*) p);
118 	}
119 	
120 	/**
121 	 * Copies a PangoTabArray
122 	 * Returns: the newly allocated PangoTabArray, which should be freed with pango_tab_array_free().
123 	 */
124 	public PgTabArray copy()
125 	{
126 		// PangoTabArray * pango_tab_array_copy (PangoTabArray *src);
127 		auto p = pango_tab_array_copy(pangoTabArray);
128 		
129 		if(p is null)
130 		{
131 			return null;
132 		}
133 		
134 		return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) p);
135 	}
136 	
137 	/**
138 	 * Frees a tab array and associated resources.
139 	 */
140 	public void free()
141 	{
142 		// void pango_tab_array_free (PangoTabArray *tab_array);
143 		pango_tab_array_free(pangoTabArray);
144 	}
145 	
146 	/**
147 	 * Gets the number of tab stops in tab_array.
148 	 * Returns: the number of tab stops in the array.
149 	 */
150 	public int getSize()
151 	{
152 		// gint pango_tab_array_get_size (PangoTabArray *tab_array);
153 		return pango_tab_array_get_size(pangoTabArray);
154 	}
155 	
156 	/**
157 	 * Resizes a tab array. You must subsequently initialize any tabs that
158 	 * were added as a result of growing the array.
159 	 * Params:
160 	 * newSize = new size of the array
161 	 */
162 	public void resize(int newSize)
163 	{
164 		// void pango_tab_array_resize (PangoTabArray *tab_array,  gint new_size);
165 		pango_tab_array_resize(pangoTabArray, newSize);
166 	}
167 	
168 	/**
169 	 * Sets the alignment and location of a tab stop.
170 	 * alignment must always be PANGO_TAB_LEFT in the current
171 	 * implementation.
172 	 * Params:
173 	 * tabIndex = the index of a tab stop
174 	 * alignment = tab alignment
175 	 * location = tab location in Pango units
176 	 */
177 	public void setTab(int tabIndex, PangoTabAlign alignment, int location)
178 	{
179 		// void pango_tab_array_set_tab (PangoTabArray *tab_array,  gint tab_index,  PangoTabAlign alignment,  gint location);
180 		pango_tab_array_set_tab(pangoTabArray, tabIndex, alignment, location);
181 	}
182 	
183 	/**
184 	 * Gets the alignment and position of a tab stop.
185 	 * Params:
186 	 * tabIndex = tab stop index
187 	 * alignment = location to store alignment, or NULL. [out][allow-none]
188 	 * location = location to store tab position, or NULL. [out][allow-none]
189 	 */
190 	public void getTab(int tabIndex, out PangoTabAlign alignment, out int location)
191 	{
192 		// void pango_tab_array_get_tab (PangoTabArray *tab_array,  gint tab_index,  PangoTabAlign *alignment,  gint *location);
193 		pango_tab_array_get_tab(pangoTabArray, tabIndex, &alignment, &location);
194 	}
195 	
196 	/**
197 	 * If non-NULL, alignments and locations are filled with allocated
198 	 * arrays of length pango_tab_array_get_size(). You must free the
199 	 * returned array.
200 	 * Params:
201 	 * alignments = location to store an array of tab
202 	 * stop alignments, or NULL. [out][allow-none]
203 	 * locations = location to store an array
204 	 * of tab positions, or NULL. [out][allow-none][array]
205 	 */
206 	public void getTabs(out PangoTabAlign[] alignments, out int[] locations)
207 	{
208 		// void pango_tab_array_get_tabs (PangoTabArray *tab_array,  PangoTabAlign **alignments,  gint **locations);
209 		PangoTabAlign* outalignments = null;
210 		gint* outlocations = null;
211 		
212 		pango_tab_array_get_tabs(pangoTabArray, &outalignments, &outlocations);
213 		
214 		alignments = outalignments[0 .. getSize()];
215 		locations = outlocations[0 .. getSize()];
216 	}
217 	
218 	/**
219 	 * Returns TRUE if the tab positions are in pixels, FALSE if they are
220 	 * in Pango units.
221 	 * Returns: whether positions are in pixels.
222 	 */
223 	public int getPositionsInPixels()
224 	{
225 		// gboolean pango_tab_array_get_positions_in_pixels  (PangoTabArray *tab_array);
226 		return pango_tab_array_get_positions_in_pixels(pangoTabArray);
227 	}
228 }