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