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