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 gtk.TextMark; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.TextBuffer; 31 private import gtk.c.functions; 32 public import gtk.c.types; 33 public import gtkc.gtktypes; 34 35 36 /** 37 * You may wish to begin by reading the 38 * [text widget conceptual overview][TextWidget] 39 * which gives an overview of all the objects and data 40 * types related to the text widget and how they work together. 41 * 42 * A #GtkTextMark is like a bookmark in a text buffer; it preserves a position in 43 * the text. You can convert the mark to an iterator using 44 * gtk_text_buffer_get_iter_at_mark(). Unlike iterators, marks remain valid across 45 * buffer mutations, because their behavior is defined when text is inserted or 46 * deleted. When text containing a mark is deleted, the mark remains in the 47 * position originally occupied by the deleted text. When text is inserted at a 48 * mark, a mark with “left gravity” will be moved to the 49 * beginning of the newly-inserted text, and a mark with “right 50 * gravity” will be moved to the end. 51 * 52 * Note that “left” and “right” here refer to logical direction (left 53 * is the toward the start of the buffer); in some languages such as 54 * Hebrew the logically-leftmost text is not actually on the left when 55 * displayed. 56 * 57 * Marks are reference counted, but the reference count only controls the validity 58 * of the memory; marks can be deleted from the buffer at any time with 59 * gtk_text_buffer_delete_mark(). Once deleted from the buffer, a mark is 60 * essentially useless. 61 * 62 * Marks optionally have names; these can be convenient to avoid passing the 63 * #GtkTextMark object around. 64 * 65 * Marks are typically created using the gtk_text_buffer_create_mark() function. 66 */ 67 public class TextMark : ObjectG 68 { 69 /** the main Gtk struct */ 70 protected GtkTextMark* gtkTextMark; 71 72 /** Get the main Gtk struct */ 73 public GtkTextMark* getTextMarkStruct(bool transferOwnership = false) 74 { 75 if (transferOwnership) 76 ownedRef = false; 77 return gtkTextMark; 78 } 79 80 /** the main Gtk struct as a void* */ 81 protected override void* getStruct() 82 { 83 return cast(void*)gtkTextMark; 84 } 85 86 protected override void setStruct(GObject* obj) 87 { 88 gtkTextMark = cast(GtkTextMark*)obj; 89 super.setStruct(obj); 90 } 91 92 /** 93 * Sets our main struct and passes it to the parent class. 94 */ 95 public this (GtkTextMark* gtkTextMark, bool ownedRef = false) 96 { 97 this.gtkTextMark = gtkTextMark; 98 super(cast(GObject*)gtkTextMark, ownedRef); 99 } 100 101 102 /** */ 103 public static GType getType() 104 { 105 return gtk_text_mark_get_type(); 106 } 107 108 /** 109 * Creates a text mark. Add it to a buffer using gtk_text_buffer_add_mark(). 110 * If @name is %NULL, the mark is anonymous; otherwise, the mark can be 111 * retrieved by name using gtk_text_buffer_get_mark(). If a mark has left 112 * gravity, and text is inserted at the mark’s current location, the mark 113 * will be moved to the left of the newly-inserted text. If the mark has 114 * right gravity (@left_gravity = %FALSE), the mark will end up on the 115 * right of newly-inserted text. The standard left-to-right cursor is a 116 * mark with right gravity (when you type, the cursor stays on the right 117 * side of the text you’re typing). 118 * 119 * Params: 120 * name = mark name or %NULL 121 * leftGravity = whether the mark should have left gravity 122 * 123 * Returns: new #GtkTextMark 124 * 125 * Since: 2.12 126 * 127 * Throws: ConstructionException GTK+ fails to create the object. 128 */ 129 public this(string name, bool leftGravity) 130 { 131 auto p = gtk_text_mark_new(Str.toStringz(name), leftGravity); 132 133 if(p is null) 134 { 135 throw new ConstructionException("null returned by new"); 136 } 137 138 this(cast(GtkTextMark*) p, true); 139 } 140 141 /** 142 * Gets the buffer this mark is located inside, 143 * or %NULL if the mark is deleted. 144 * 145 * Returns: the mark’s #GtkTextBuffer 146 */ 147 public TextBuffer getBuffer() 148 { 149 auto p = gtk_text_mark_get_buffer(gtkTextMark); 150 151 if(p is null) 152 { 153 return null; 154 } 155 156 return ObjectG.getDObject!(TextBuffer)(cast(GtkTextBuffer*) p); 157 } 158 159 /** 160 * Returns %TRUE if the mark has been removed from its buffer 161 * with gtk_text_buffer_delete_mark(). See gtk_text_buffer_add_mark() 162 * for a way to add it to a buffer again. 163 * 164 * Returns: whether the mark is deleted 165 */ 166 public bool getDeleted() 167 { 168 return gtk_text_mark_get_deleted(gtkTextMark) != 0; 169 } 170 171 /** 172 * Determines whether the mark has left gravity. 173 * 174 * Returns: %TRUE if the mark has left gravity, %FALSE otherwise 175 */ 176 public bool getLeftGravity() 177 { 178 return gtk_text_mark_get_left_gravity(gtkTextMark) != 0; 179 } 180 181 /** 182 * Returns the mark name; returns NULL for anonymous marks. 183 * 184 * Returns: mark name 185 */ 186 public string getName() 187 { 188 return Str.toString(gtk_text_mark_get_name(gtkTextMark)); 189 } 190 191 /** 192 * Returns %TRUE if the mark is visible (i.e. a cursor is displayed 193 * for it). 194 * 195 * Returns: %TRUE if visible 196 */ 197 public bool getVisible() 198 { 199 return gtk_text_mark_get_visible(gtkTextMark) != 0; 200 } 201 202 /** 203 * Sets the visibility of @mark; the insertion point is normally 204 * visible, i.e. you can see it as a vertical bar. Also, the text 205 * widget uses a visible mark to indicate where a drop will occur when 206 * dragging-and-dropping text. Most other marks are not visible. 207 * Marks are not visible by default. 208 * 209 * Params: 210 * setting = visibility of mark 211 */ 212 public void setVisible(bool setting) 213 { 214 gtk_text_mark_set_visible(gtkTextMark, setting); 215 } 216 }