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