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.PgCoverage; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtkc.pango; 31 public import gtkc.pangotypes; 32 private import gtkd.Loader; 33 34 35 /** 36 * The #PangoCoverage structure represents a map from Unicode characters 37 * to #PangoCoverageLevel. It is an opaque structure with no public fields. 38 */ 39 public class PgCoverage 40 { 41 /** the main Gtk struct */ 42 protected PangoCoverage* pangoCoverage; 43 protected bool ownedRef; 44 45 /** Get the main Gtk struct */ 46 public PangoCoverage* getPgCoverageStruct(bool transferOwnership = false) 47 { 48 if (transferOwnership) 49 ownedRef = false; 50 return pangoCoverage; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected void* getStruct() 55 { 56 return cast(void*)pangoCoverage; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (PangoCoverage* pangoCoverage, bool ownedRef = false) 63 { 64 this.pangoCoverage = pangoCoverage; 65 this.ownedRef = ownedRef; 66 } 67 68 ~this () 69 { 70 if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef ) 71 pango_coverage_unref(pangoCoverage); 72 } 73 74 75 /** 76 * Copy an existing #PangoCoverage. (This function may now be unnecessary 77 * since we refcount the structure. File a bug if you use it.) 78 * 79 * Returns: the newly allocated #PangoCoverage, 80 * with a reference count of one, which should be freed 81 * with pango_coverage_unref(). 82 */ 83 public PgCoverage copy() 84 { 85 auto p = pango_coverage_copy(pangoCoverage); 86 87 if(p is null) 88 { 89 return null; 90 } 91 92 return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p, true); 93 } 94 95 /** 96 * Determine whether a particular index is covered by @coverage 97 * 98 * Params: 99 * index = the index to check 100 * 101 * Returns: the coverage level of @coverage for character @index_. 102 */ 103 public PangoCoverageLevel get(int index) 104 { 105 return pango_coverage_get(pangoCoverage, index); 106 } 107 108 /** 109 * Set the coverage for each index in @coverage to be the max (better) 110 * value of the current coverage for the index and the coverage for 111 * the corresponding index in @other. 112 * 113 * Params: 114 * other = another #PangoCoverage 115 */ 116 public void max(PgCoverage other) 117 { 118 pango_coverage_max(pangoCoverage, (other is null) ? null : other.getPgCoverageStruct()); 119 } 120 121 /** 122 * Increase the reference count on the #PangoCoverage by one 123 * 124 * Returns: @coverage 125 */ 126 public PgCoverage doref() 127 { 128 auto p = pango_coverage_ref(pangoCoverage); 129 130 if(p is null) 131 { 132 return null; 133 } 134 135 return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p); 136 } 137 138 /** 139 * Modify a particular index within @coverage 140 * 141 * Params: 142 * index = the index to modify 143 * level = the new level for @index_ 144 */ 145 public void set(int index, PangoCoverageLevel level) 146 { 147 pango_coverage_set(pangoCoverage, index, level); 148 } 149 150 /** 151 * Convert a #PangoCoverage structure into a flat binary format 152 * 153 * Params: 154 * bytes = location to store result (must be freed with g_free()) 155 * nBytes = location to store size of result 156 */ 157 public void toBytes(out ubyte[] bytes) 158 { 159 ubyte* outbytes = null; 160 int nBytes; 161 162 pango_coverage_to_bytes(pangoCoverage, cast(char**)&outbytes, &nBytes); 163 164 bytes = outbytes[0 .. nBytes]; 165 } 166 167 /** 168 * Decrease the reference count on the #PangoCoverage by one. 169 * If the result is zero, free the coverage and all associated memory. 170 */ 171 public void unref() 172 { 173 pango_coverage_unref(pangoCoverage); 174 } 175 176 /** 177 * Convert data generated from pango_coverage_to_bytes() back 178 * to a #PangoCoverage 179 * 180 * Params: 181 * bytes = binary data 182 * representing a #PangoCoverage 183 * nBytes = the size of @bytes in bytes 184 * 185 * Returns: a newly allocated 186 * #PangoCoverage, or %NULL if the data was invalid. 187 */ 188 public static PgCoverage fromBytes(char[] bytes) 189 { 190 auto p = pango_coverage_from_bytes(bytes.ptr, cast(int)bytes.length); 191 192 if(p is null) 193 { 194 return null; 195 } 196 197 return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p, true); 198 } 199 200 /** 201 * Create a new #PangoCoverage 202 * 203 * Returns: the newly allocated #PangoCoverage, 204 * initialized to %PANGO_COVERAGE_NONE 205 * with a reference count of one, which 206 * should be freed with pango_coverage_unref(). 207 * 208 * Throws: ConstructionException GTK+ fails to create the object. 209 */ 210 public this() 211 { 212 auto p = pango_coverage_new(); 213 214 if(p is null) 215 { 216 throw new ConstructionException("null returned by new"); 217 } 218 219 this(cast(PangoCoverage*) p); 220 } 221 }