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