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 gsv.Region; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gsv.RegionIter; 31 private import gsv.c.functions; 32 public import gsv.c.types; 33 public import gsvc.gsvtypes; 34 private import gtk.TextBuffer; 35 private import gtk.TextIter; 36 37 38 /** */ 39 public class Region : ObjectG 40 { 41 /** the main Gtk struct */ 42 protected GtkSourceRegion* gtkSourceRegion; 43 44 /** Get the main Gtk struct */ 45 public GtkSourceRegion* getRegionStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return gtkSourceRegion; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)gtkSourceRegion; 56 } 57 58 /** 59 * Sets our main struct and passes it to the parent class. 60 */ 61 public this (GtkSourceRegion* gtkSourceRegion, bool ownedRef = false) 62 { 63 this.gtkSourceRegion = gtkSourceRegion; 64 super(cast(GObject*)gtkSourceRegion, ownedRef); 65 } 66 67 68 /** */ 69 public static GType getType() 70 { 71 return gtk_source_region_get_type(); 72 } 73 74 /** 75 * 76 * Params: 77 * buffer = a #GtkTextBuffer. 78 * Returns: a new #GtkSourceRegion object for @buffer. 79 * 80 * Since: 3.22 81 * 82 * Throws: ConstructionException GTK+ fails to create the object. 83 */ 84 public this(TextBuffer buffer) 85 { 86 auto p = gtk_source_region_new((buffer is null) ? null : buffer.getTextBufferStruct()); 87 88 if(p is null) 89 { 90 throw new ConstructionException("null returned by new"); 91 } 92 93 this(cast(GtkSourceRegion*) p, true); 94 } 95 96 /** 97 * Adds @region_to_add to @region. @region_to_add is not modified. 98 * 99 * Params: 100 * regionToAdd = the #GtkSourceRegion to add to @region, or %NULL. 101 * 102 * Since: 3.22 103 */ 104 public void addRegion(Region regionToAdd) 105 { 106 gtk_source_region_add_region(gtkSourceRegion, (regionToAdd is null) ? null : regionToAdd.getRegionStruct()); 107 } 108 109 /** 110 * Adds the subregion delimited by @_start and @_end to @region. 111 * 112 * Params: 113 * Start = the start of the subregion. 114 * End = the end of the subregion. 115 * 116 * Since: 3.22 117 */ 118 public void addSubregion(TextIter Start, TextIter End) 119 { 120 gtk_source_region_add_subregion(gtkSourceRegion, (Start is null) ? null : Start.getTextIterStruct(), (End is null) ? null : End.getTextIterStruct()); 121 } 122 123 /** 124 * Gets the @start and @end bounds of the @region. 125 * 126 * Params: 127 * start = iterator to initialize with the start of @region, 128 * or %NULL. 129 * end = iterator to initialize with the end of @region, 130 * or %NULL. 131 * 132 * Returns: %TRUE if @start and @end have been set successfully (if non-%NULL), 133 * or %FALSE if the @region is empty. 134 * 135 * Since: 3.22 136 */ 137 public bool getBounds(out TextIter start, out TextIter end) 138 { 139 GtkTextIter* outstart = gMalloc!GtkTextIter(); 140 GtkTextIter* outend = gMalloc!GtkTextIter(); 141 142 auto p = gtk_source_region_get_bounds(gtkSourceRegion, outstart, outend) != 0; 143 144 start = ObjectG.getDObject!(TextIter)(outstart, true); 145 end = ObjectG.getDObject!(TextIter)(outend, true); 146 147 return p; 148 } 149 150 /** 151 * Returns: the #GtkTextBuffer. 152 * 153 * Since: 3.22 154 */ 155 public TextBuffer getBuffer() 156 { 157 auto p = gtk_source_region_get_buffer(gtkSourceRegion); 158 159 if(p is null) 160 { 161 return null; 162 } 163 164 return ObjectG.getDObject!(TextBuffer)(cast(GtkTextBuffer*) p); 165 } 166 167 /** 168 * Initializes a #GtkSourceRegionIter to the first subregion of @region. If 169 * @region is empty, @iter will be initialized to the end iterator. 170 * 171 * Params: 172 * iter = iterator to initialize to the first subregion. 173 * 174 * Since: 3.22 175 */ 176 public void getStartRegionIter(out RegionIter iter) 177 { 178 GtkSourceRegionIter* outiter = gMalloc!GtkSourceRegionIter(); 179 180 gtk_source_region_get_start_region_iter(gtkSourceRegion, outiter); 181 182 iter = ObjectG.getDObject!(RegionIter)(outiter, true); 183 } 184 185 /** 186 * Returns the intersection between @region1 and @region2. @region1 and 187 * @region2 are not modified. 188 * 189 * Params: 190 * region2 = a #GtkSourceRegion, or %NULL. 191 * 192 * Returns: the intersection as a #GtkSourceRegion 193 * object. 194 * 195 * Since: 3.22 196 */ 197 public Region intersectRegion(Region region2) 198 { 199 auto p = gtk_source_region_intersect_region(gtkSourceRegion, (region2 is null) ? null : region2.getRegionStruct()); 200 201 if(p is null) 202 { 203 return null; 204 } 205 206 return ObjectG.getDObject!(Region)(cast(GtkSourceRegion*) p, true); 207 } 208 209 /** 210 * Returns the intersection between @region and the subregion delimited by 211 * @_start and @_end. @region is not modified. 212 * 213 * Params: 214 * Start = the start of the subregion. 215 * End = the end of the subregion. 216 * 217 * Returns: the intersection as a new 218 * #GtkSourceRegion. 219 * 220 * Since: 3.22 221 */ 222 public Region intersectSubregion(TextIter Start, TextIter End) 223 { 224 auto p = gtk_source_region_intersect_subregion(gtkSourceRegion, (Start is null) ? null : Start.getTextIterStruct(), (End is null) ? null : End.getTextIterStruct()); 225 226 if(p is null) 227 { 228 return null; 229 } 230 231 return ObjectG.getDObject!(Region)(cast(GtkSourceRegion*) p, true); 232 } 233 234 /** 235 * Returns whether the @region is empty. A %NULL @region is considered empty. 236 * 237 * Returns: whether the @region is empty. 238 * 239 * Since: 3.22 240 */ 241 public bool isEmpty() 242 { 243 return gtk_source_region_is_empty(gtkSourceRegion) != 0; 244 } 245 246 /** 247 * Subtracts @region_to_subtract from @region. @region_to_subtract is not 248 * modified. 249 * 250 * Params: 251 * regionToSubtract = the #GtkSourceRegion to subtract from 252 * @region, or %NULL. 253 * 254 * Since: 3.22 255 */ 256 public void subtractRegion(Region regionToSubtract) 257 { 258 gtk_source_region_subtract_region(gtkSourceRegion, (regionToSubtract is null) ? null : regionToSubtract.getRegionStruct()); 259 } 260 261 /** 262 * Subtracts the subregion delimited by @_start and @_end from @region. 263 * 264 * Params: 265 * Start = the start of the subregion. 266 * End = the end of the subregion. 267 * 268 * Since: 3.22 269 */ 270 public void subtractSubregion(TextIter Start, TextIter End) 271 { 272 gtk_source_region_subtract_subregion(gtkSourceRegion, (Start is null) ? null : Start.getTextIterStruct(), (End is null) ? null : End.getTextIterStruct()); 273 } 274 275 /** 276 * Gets a string represention of @region, for debugging purposes. 277 * 278 * The returned string contains the character offsets of the subregions. It 279 * doesn't include a newline character at the end of the string. 280 * 281 * Returns: a string represention of @region. Free 282 * with g_free() when no longer needed. 283 * 284 * Since: 3.22 285 */ 286 public override string toString() 287 { 288 auto retStr = gtk_source_region_to_string(gtkSourceRegion); 289 290 scope(exit) Str.freeString(retStr); 291 return Str.toString(retStr); 292 } 293 }