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