2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkEditable.html
57 import tango
.io
.Stdout
; // use the tango loging?
61 private import gtkc
.gtktypes
;
63 private import gtkc
.gtk
;
66 private import glib
.Str
;
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 * Example3.Forcing entry to uppercase.
84 * insert_text_handler (GtkEditable *editable,
91 * gchar *result = g_utf8_strup (text, length);
92 * g_signal_handlers_block_by_func (editable,
93 * (gpointer) insert_text_handler, data);
94 * gtk_editable_insert_text (editable, result, length, position);
95 * g_signal_handlers_unblock_by_func (editable,
96 * (gpointer) insert_text_handler, data);
97 * g_signal_stop_emission_by_name (editable, "insert_text");
101 public class Editable
104 /** the main Gtk struct */
105 protected GtkEditable
* gtkEditable
;
108 public GtkEditable
* getEditableStruct()
114 /** the main Gtk struct as a void* */
115 protected void* getStruct()
117 return cast(void*)gtkEditable
;
121 * Sets our main struct and passes it to the parent class
123 public this (GtkEditable
* gtkEditable
)
127 if ( gtkEditable
is null )
132 Stdout("struct gtkEditable is null on constructor").newline
;
136 printf("struct gtkEditable is null on constructor");
143 assert(gtkEditable
!is null, "struct gtkEditable is null on constructor");
145 this.gtkEditable
= gtkEditable
;
151 // imports for the signal processing
152 private import gobject
.Signals
;
153 private import gtkc
.gdktypes
;
154 int[char[]] connectedSignals
;
156 void delegate(Editable
)[] onChangedListeners
;
157 void addOnChanged(void delegate(Editable
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
159 if ( !("changed" in connectedSignals
) )
164 cast(GCallback
)&callBackChanged
,
168 connectedSignals
["changed"] = 1;
170 onChangedListeners
~= dlg
;
172 extern(C
) static void callBackChanged(GtkEditable
* editableStruct
, Editable editable
)
174 bool consumed
= false;
176 foreach ( void delegate(Editable
) dlg
; editable
.onChangedListeners
)
184 void delegate(gint
, gint
, Editable
)[] onDeleteTextListeners
;
185 void addOnDeleteText(void delegate(gint
, gint
, Editable
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
187 if ( !("delete-text" in connectedSignals
) )
192 cast(GCallback
)&callBackDeleteText
,
196 connectedSignals
["delete-text"] = 1;
198 onDeleteTextListeners
~= dlg
;
200 extern(C
) static void callBackDeleteText(GtkEditable
* editableStruct
, gint startPos
, gint endPos
, Editable editable
)
202 bool consumed
= false;
204 foreach ( void delegate(gint
, gint
, Editable
) dlg
; editable
.onDeleteTextListeners
)
206 dlg(startPos
, endPos
, editable
);
212 void delegate(char[], gint
, gint
*, Editable
)[] onInsertTextListeners
;
213 void addOnInsertText(void delegate(char[], gint
, gint
*, Editable
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
215 if ( !("insert-text" in connectedSignals
) )
220 cast(GCallback
)&callBackInsertText
,
224 connectedSignals
["insert-text"] = 1;
226 onInsertTextListeners
~= dlg
;
228 extern(C
) static void callBackInsertText(GtkEditable
* editableStruct
, gchar
* newText
, gint newTextLength
, gint
* position
, Editable editable
)
230 bool consumed
= false;
232 foreach ( void delegate(char[], gint
, gint
*, Editable
) dlg
; editable
.onInsertTextListeners
)
234 dlg(Str
.toString(newText
), newTextLength
, position
, editable
);
243 * Selects a region of text. The characters that
244 * are selected are those characters at positions from
245 * start_pos up to, but not including end_pos. If
246 * end_pos is negative, then the the characters selected
247 * will be those characters from start_pos to the end
250 * a GtkEditable widget.
252 * the starting position.
256 public void selectRegion(int start
, int end
)
258 // void gtk_editable_select_region (GtkEditable *editable, gint start, gint end);
259 gtk_editable_select_region(gtkEditable
, start
, end
);
263 * Gets the current selection bounds, if there is a selection.
265 * a GtkEditable widget.
267 * location to store the starting position, or NULL.
269 * location to store the end position, or NULL.
271 * TRUE if there is a selection.
273 public int getSelectionBounds(int* start
, int* end
)
275 // gboolean gtk_editable_get_selection_bounds (GtkEditable *editable, gint *start, gint *end);
276 return gtk_editable_get_selection_bounds(gtkEditable
, start
, end
);
280 * Inserts text at a given position.
282 * a GtkEditable widget.
284 * the text to insert.
286 * the length of the text to insert, in bytes
288 * an inout parameter. The caller initializes it to
289 * the position at which to insert the text. After the
290 * call it points at the position after the newly
293 public void insertText(char[] newText
, int newTextLength
, int* position
)
295 // void gtk_editable_insert_text (GtkEditable *editable, const gchar *new_text, gint new_text_length, gint *position);
296 gtk_editable_insert_text(gtkEditable
, Str
.toStringz(newText
), newTextLength
, position
);
300 * Deletes a sequence of characters. The characters that
301 * are deleted are those characters at positions from
302 * start_pos up to, but not including end_pos. If
303 * end_pos is negative, then the the characters deleted
304 * will be those characters from start_pos to the end
307 * a GtkEditable widget.
309 * the starting position.
313 public void deleteText(int startPos
, int endPos
)
315 // void gtk_editable_delete_text (GtkEditable *editable, gint start_pos, gint end_pos);
316 gtk_editable_delete_text(gtkEditable
, startPos
, endPos
);
320 * Retrieves a sequence of characters. The characters that
321 * are retrieved are those characters at positions from
322 * start_pos up to, but not including end_pos. If
323 * end_pos is negative, then the the characters retrieved
324 * will be those characters from start_pos to the end
327 * a GtkEditable widget.
329 * the starting position.
333 * the characters in the indicated region.
334 * The result must be freed with g_free() when
335 * the application is finished with it.
337 public char[] getChars(int startPos
, int endPos
)
339 // gchar* gtk_editable_get_chars (GtkEditable *editable, gint start_pos, gint end_pos);
340 return Str
.toString(gtk_editable_get_chars(gtkEditable
, startPos
, endPos
) );
344 * Causes the characters in the current selection to
345 * be copied to the clipboard and then deleted from
348 * a GtkEditable widget.
350 public void cutClipboard()
352 // void gtk_editable_cut_clipboard (GtkEditable *editable);
353 gtk_editable_cut_clipboard(gtkEditable
);
357 * Causes the characters in the current selection to
358 * be copied to the clipboard.
360 * a GtkEditable widget.
362 public void copyClipboard()
364 // void gtk_editable_copy_clipboard (GtkEditable *editable);
365 gtk_editable_copy_clipboard(gtkEditable
);
369 * Causes the contents of the clipboard to be pasted into
370 * the given widget at the current cursor position.
372 * a GtkEditable widget.
374 public void pasteClipboard()
376 // void gtk_editable_paste_clipboard (GtkEditable *editable);
377 gtk_editable_paste_clipboard(gtkEditable
);
381 * Deletes the current contents of the widgets selection and
382 * disclaims the selection.
384 * a GtkEditable widget.
386 public void deleteSelection()
388 // void gtk_editable_delete_selection (GtkEditable *editable);
389 gtk_editable_delete_selection(gtkEditable
);
393 * Sets the cursor position.
395 * a GtkEditable widget.
397 * the position of the cursor. The cursor is displayed
398 * before the character with the given (base 0) index
399 * in the widget. The value must be less than or
400 * equal to the number of characters in the widget.
401 * A value of -1 indicates that the position should
402 * be set after the last character in the entry.
403 * Note that this position is in characters, not in
406 public void setPosition(int position
)
408 // void gtk_editable_set_position (GtkEditable *editable, gint position);
409 gtk_editable_set_position(gtkEditable
, position
);
413 * Retrieves the current cursor position.
415 * a GtkEditable widget.
417 * the position of the cursor. The cursor is displayed
418 * before the character with the given (base 0) index
419 * in the widget. The value will be less than or
420 * equal to the number of characters in the widget.
421 * Note that this position is in characters, not in
424 public int getPosition()
426 // gint gtk_editable_get_position (GtkEditable *editable);
427 return gtk_editable_get_position(gtkEditable
);
431 * Determines if the user can edit the text in the editable
434 * a GtkEditable widget.
436 * TRUE if the user is allowed to edit the text
439 public void setEditable(int isEditable
)
441 // void gtk_editable_set_editable (GtkEditable *editable, gboolean is_editable);
442 gtk_editable_set_editable(gtkEditable
, isEditable
);
446 * Retrieves whether editable is editable. See
447 * gtk_editable_set_editable().
451 * TRUE if editable is editable.
453 * The "changed" signal
454 * void user_function (GtkEditable *editable,
455 * gpointer user_data) : Run Last
456 * Indicates that the user has changed the contents
459 * the object which received the signal.
461 * user data set when the signal handler was connected.
463 public int getEditable()
465 // gboolean gtk_editable_get_editable (GtkEditable *editable);
466 return gtk_editable_get_editable(gtkEditable
);