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  * Conversion parameters:
26  * inFile  = GtkEditable.html
27  * outPack = gtk
28  * outFile = EditableT
29  * strct   = GtkEditable
30  * realStrct=
31  * ctorStrct=
32  * clss    = EditableT
33  * interf  = EditableIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- gtk_editable_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * structWrap:
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gtk.EditableT;
55 
56 public  import gtkc.gtktypes;
57 
58 public import gtkc.gtk;
59 public import glib.ConstructionException;
60 public import gobject.ObjectG;
61 
62 public import gobject.Signals;
63 public  import gtkc.gdktypes;
64 public import glib.Str;
65 
66 
67 
68 /**
69  * The GtkEditable interface is an interface which should be implemented by
70  * text editing widgets, such as GtkEntry and GtkSpinButton. It contains functions
71  * for generically manipulating an editable widget, a large number of action
72  * signals used for key bindings, and several signals that an application can
73  * connect to to modify the behavior of a widget.
74  *
75  * As an example of the latter usage, by connecting
76  * the following handler to "insert-text", an application
77  * can convert all entry into a widget into uppercase.
78  *
79  * $(DDOC_COMMENT example)
80  */
81 public template EditableT(TStruct)
82 {
83 	
84 	/** the main Gtk struct */
85 	protected GtkEditable* gtkEditable;
86 	
87 	
88 	/** Get the main Gtk struct */
89 	public GtkEditable* getEditableTStruct()
90 	{
91 		return cast(GtkEditable*)getStruct();
92 	}
93 	
94 	
95 	/**
96 	 */
97 	int[string] connectedSignals;
98 	
99 	void delegate(EditableIF)[] _onChangedListeners;
100 	@property void delegate(EditableIF)[] onChangedListeners()
101 	{
102 		return  _onChangedListeners;
103 	}
104 	/**
105 	 * The ::changed signal is emitted at the end of a single
106 	 * user-visible operation on the contents of the GtkEditable.
107 	 * E.g., a paste operation that replaces the contents of the
108 	 * selection will cause only one signal emission (even though it
109 	 * is implemented by first deleting the selection, then inserting
110 	 * the new content, and may cause multiple ::notify::text signals
111 	 * to be emitted).
112 	 */
113 	void addOnChanged(void delegate(EditableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
114 	{
115 		if ( !("changed" in connectedSignals) )
116 		{
117 			Signals.connectData(
118 			getStruct(),
119 			"changed",
120 			cast(GCallback)&callBackChanged,
121 			cast(void*)cast(EditableIF)this,
122 			null,
123 			connectFlags);
124 			connectedSignals["changed"] = 1;
125 		}
126 		_onChangedListeners ~= dlg;
127 	}
128 	extern(C) static void callBackChanged(GtkEditable* editableStruct, EditableIF _editableIF)
129 	{
130 		foreach ( void delegate(EditableIF) dlg ; _editableIF.onChangedListeners )
131 		{
132 			dlg(_editableIF);
133 		}
134 	}
135 	
136 	void delegate(gint, gint, EditableIF)[] _onDeleteTextListeners;
137 	@property void delegate(gint, gint, EditableIF)[] onDeleteTextListeners()
138 	{
139 		return  _onDeleteTextListeners;
140 	}
141 	/**
142 	 * This signal is emitted when text is deleted from
143 	 * the widget by the user. The default handler for
144 	 * this signal will normally be responsible for deleting
145 	 * the text, so by connecting to this signal and then
146 	 * stopping the signal with g_signal_stop_emission(), it
147 	 * is possible to modify the range of deleted text, or
148 	 * prevent it from being deleted entirely. The start_pos
149 	 * and end_pos parameters are interpreted as for
150 	 * gtk_editable_delete_text().
151 	 */
152 	void addOnDeleteText(void delegate(gint, gint, EditableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
153 	{
154 		if ( !("delete-text" in connectedSignals) )
155 		{
156 			Signals.connectData(
157 			getStruct(),
158 			"delete-text",
159 			cast(GCallback)&callBackDeleteText,
160 			cast(void*)cast(EditableIF)this,
161 			null,
162 			connectFlags);
163 			connectedSignals["delete-text"] = 1;
164 		}
165 		_onDeleteTextListeners ~= dlg;
166 	}
167 	extern(C) static void callBackDeleteText(GtkEditable* editableStruct, gint startPos, gint endPos, EditableIF _editableIF)
168 	{
169 		foreach ( void delegate(gint, gint, EditableIF) dlg ; _editableIF.onDeleteTextListeners )
170 		{
171 			dlg(startPos, endPos, _editableIF);
172 		}
173 	}
174 	
175 	void delegate(string, gint, void*, EditableIF)[] _onInsertTextListeners;
176 	@property void delegate(string, gint, void*, EditableIF)[] onInsertTextListeners()
177 	{
178 		return  _onInsertTextListeners;
179 	}
180 	/**
181 	 * This signal is emitted when text is inserted into
182 	 * the widget by the user. The default handler for
183 	 * this signal will normally be responsible for inserting
184 	 * the text, so by connecting to this signal and then
185 	 * stopping the signal with g_signal_stop_emission(), it
186 	 * is possible to modify the inserted text, or prevent
187 	 * it from being inserted entirely.
188 	 */
189 	void addOnInsertText(void delegate(string, gint, void*, EditableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
190 	{
191 		if ( !("insert-text" in connectedSignals) )
192 		{
193 			Signals.connectData(
194 			getStruct(),
195 			"insert-text",
196 			cast(GCallback)&callBackInsertText,
197 			cast(void*)cast(EditableIF)this,
198 			null,
199 			connectFlags);
200 			connectedSignals["insert-text"] = 1;
201 		}
202 		_onInsertTextListeners ~= dlg;
203 	}
204 	extern(C) static void callBackInsertText(GtkEditable* editableStruct, gchar* newText, gint newTextLength, void* position, EditableIF _editableIF)
205 	{
206 		foreach ( void delegate(string, gint, void*, EditableIF) dlg ; _editableIF.onInsertTextListeners )
207 		{
208 			dlg(Str.toString(newText), newTextLength, position, _editableIF);
209 		}
210 	}
211 	
212 	
213 	/**
214 	 * Selects a region of text. The characters that are selected are
215 	 * those characters at positions from start_pos up to, but not
216 	 * including end_pos. If end_pos is negative, then the
217 	 * characters selected are those characters from start_pos to
218 	 * the end of the text.
219 	 * Note that positions are specified in characters, not bytes.
220 	 * Virtual: set_selection_bounds
221 	 * Params:
222 	 * startPos = start of region
223 	 * endPos = end of region
224 	 */
225 	public void selectRegion(int startPos, int endPos)
226 	{
227 		// void gtk_editable_select_region (GtkEditable *editable,  gint start_pos,  gint end_pos);
228 		gtk_editable_select_region(getEditableTStruct(), startPos, endPos);
229 	}
230 	
231 	/**
232 	 * Retrieves the selection bound of the editable. start_pos will be filled
233 	 * with the start of the selection and end_pos with end. If no text was
234 	 * selected both will be identical and FALSE will be returned.
235 	 * Note that positions are specified in characters, not bytes.
236 	 * Params:
237 	 * startPos = location to store the starting position, or NULL. [out][allow-none]
238 	 * endPos = location to store the end position, or NULL. [out][allow-none]
239 	 * Returns: TRUE if an area is selected, FALSE otherwise
240 	 */
241 	public int getSelectionBounds(out int startPos, out int endPos)
242 	{
243 		// gboolean gtk_editable_get_selection_bounds (GtkEditable *editable,  gint *start_pos,  gint *end_pos);
244 		return gtk_editable_get_selection_bounds(getEditableTStruct(), &startPos, &endPos);
245 	}
246 	
247 	/**
248 	 * Inserts new_text_length bytes of new_text into the contents of the
249 	 * widget, at position position.
250 	 * Note that the position is in characters, not in bytes.
251 	 * The function updates position to point after the newly inserted text.
252 	 * Virtual: do_insert_text
253 	 * Params:
254 	 * newText = the text to append
255 	 * position = location of the position text will be inserted at. [inout]
256 	 */
257 	public void insertText(string newText, ref int position)
258 	{
259 		// void gtk_editable_insert_text (GtkEditable *editable,  const gchar *new_text,  gint new_text_length,  gint *position);
260 		gtk_editable_insert_text(getEditableTStruct(), cast(char*)newText.ptr, cast(int) newText.length, &position);
261 	}
262 	
263 	/**
264 	 * Deletes a sequence of characters. The characters that are deleted are
265 	 * those characters at positions from start_pos up to, but not including
266 	 * end_pos. If end_pos is negative, then the characters deleted
267 	 * are those from start_pos to the end of the text.
268 	 * Note that the positions are specified in characters, not bytes.
269 	 * Virtual: do_delete_text
270 	 * Params:
271 	 * startPos = start position
272 	 * endPos = end position
273 	 */
274 	public void deleteText(int startPos, int endPos)
275 	{
276 		// void gtk_editable_delete_text (GtkEditable *editable,  gint start_pos,  gint end_pos);
277 		gtk_editable_delete_text(getEditableTStruct(), startPos, endPos);
278 	}
279 	
280 	/**
281 	 * Retrieves a sequence of characters. The characters that are retrieved
282 	 * are those characters at positions from start_pos up to, but not
283 	 * including end_pos. If end_pos is negative, then the characters
284 	 * retrieved are those characters from start_pos to the end of the text.
285 	 * Note that positions are specified in characters, not bytes.
286 	 * Params:
287 	 * startPos = start of text
288 	 * endPos = end of text
289 	 * Returns: a pointer to the contents of the widget as a string. This string is allocated by the GtkEditable implementation and should be freed by the caller.
290 	 */
291 	public string getChars(int startPos, int endPos)
292 	{
293 		// gchar * gtk_editable_get_chars (GtkEditable *editable,  gint start_pos,  gint end_pos);
294 		return Str.toString(gtk_editable_get_chars(getEditableTStruct(), startPos, endPos));
295 	}
296 	
297 	/**
298 	 * Removes the contents of the currently selected content in the editable and
299 	 * puts it on the clipboard.
300 	 */
301 	public void cutClipboard()
302 	{
303 		// void gtk_editable_cut_clipboard (GtkEditable *editable);
304 		gtk_editable_cut_clipboard(getEditableTStruct());
305 	}
306 	
307 	/**
308 	 * Copies the contents of the currently selected content in the editable and
309 	 * puts it on the clipboard.
310 	 */
311 	public void copyClipboard()
312 	{
313 		// void gtk_editable_copy_clipboard (GtkEditable *editable);
314 		gtk_editable_copy_clipboard(getEditableTStruct());
315 	}
316 	
317 	/**
318 	 * Pastes the content of the clipboard to the current position of the
319 	 * cursor in the editable.
320 	 */
321 	public void pasteClipboard()
322 	{
323 		// void gtk_editable_paste_clipboard (GtkEditable *editable);
324 		gtk_editable_paste_clipboard(getEditableTStruct());
325 	}
326 	
327 	/**
328 	 * Deletes the currently selected text of the editable.
329 	 * This call doesn't do anything if there is no selected text.
330 	 */
331 	public void deleteSelection()
332 	{
333 		// void gtk_editable_delete_selection (GtkEditable *editable);
334 		gtk_editable_delete_selection(getEditableTStruct());
335 	}
336 	
337 	/**
338 	 * Sets the cursor position in the editable to the given value.
339 	 * The cursor is displayed before the character with the given (base 0)
340 	 * index in the contents of the editable. The value must be less than or
341 	 * equal to the number of characters in the editable. A value of -1
342 	 * indicates that the position should be set after the last character
343 	 * of the editable. Note that position is in characters, not in bytes.
344 	 * Params:
345 	 * position = the position of the cursor
346 	 */
347 	public void setPosition(int position)
348 	{
349 		// void gtk_editable_set_position (GtkEditable *editable,  gint position);
350 		gtk_editable_set_position(getEditableTStruct(), position);
351 	}
352 	
353 	/**
354 	 * Retrieves the current position of the cursor relative to the start
355 	 * of the content of the editable.
356 	 * Note that this position is in characters, not in bytes.
357 	 * Returns: the cursor position
358 	 */
359 	public int getPosition()
360 	{
361 		// gint gtk_editable_get_position (GtkEditable *editable);
362 		return gtk_editable_get_position(getEditableTStruct());
363 	}
364 	
365 	/**
366 	 * Determines if the user can edit the text in the editable
367 	 * widget or not.
368 	 * Params:
369 	 * isEditable = TRUE if the user is allowed to edit the text
370 	 * in the widget
371 	 */
372 	public void setEditable(int isEditable)
373 	{
374 		// void gtk_editable_set_editable (GtkEditable *editable,  gboolean is_editable);
375 		gtk_editable_set_editable(getEditableTStruct(), isEditable);
376 	}
377 	
378 	/**
379 	 * Retrieves whether editable is editable. See
380 	 * gtk_editable_set_editable().
381 	 * Returns: TRUE if editable is editable. Signal Details The "changed" signal void user_function (GtkEditable *editable, gpointer user_data) : Run Last The ::changed signal is emitted at the end of a single user-visible operation on the contents of the GtkEditable. E.g., a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple ::notify::text signals to be emitted).
382 	 */
383 	public int getEditable()
384 	{
385 		// gboolean gtk_editable_get_editable (GtkEditable *editable);
386 		return gtk_editable_get_editable(getEditableTStruct());
387 	}
388 }