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