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