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