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