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