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.EditableIF; 26 27 private import glib.Str; 28 private import gobject.Signals; 29 private import gtk.c.functions; 30 public import gtk.c.types; 31 public import gtkc.gtktypes; 32 private import std.algorithm; 33 34 35 /** 36 * The #GtkEditable interface is an interface which should be implemented by 37 * text editing widgets, such as #GtkEntry and #GtkSpinButton. It contains functions 38 * for generically manipulating an editable widget, a large number of action 39 * signals used for key bindings, and several signals that an application can 40 * connect to to modify the behavior of a widget. 41 * 42 * As an example of the latter usage, by connecting 43 * the following handler to #GtkEditable::insert-text, an application 44 * can convert all entry into a widget into uppercase. 45 * 46 * ## Forcing entry to uppercase. 47 * 48 * |[<!-- language="C" --> 49 * #include <ctype.h>; 50 * 51 * void 52 * insert_text_handler (GtkEditable *editable, 53 * const gchar *text, 54 * gint length, 55 * gint *position, 56 * gpointer data) 57 * { 58 * gchar *result = g_utf8_strup (text, length); 59 * 60 * g_signal_handlers_block_by_func (editable, 61 * (gpointer) insert_text_handler, data); 62 * gtk_editable_insert_text (editable, result, length, position); 63 * g_signal_handlers_unblock_by_func (editable, 64 * (gpointer) insert_text_handler, data); 65 * 66 * g_signal_stop_emission_by_name (editable, "insert_text"); 67 * 68 * g_free (result); 69 * } 70 * ]| 71 */ 72 public interface EditableIF{ 73 /** Get the main Gtk struct */ 74 public GtkEditable* getEditableStruct(bool transferOwnership = false); 75 76 /** the main Gtk struct as a void* */ 77 protected void* getStruct(); 78 79 80 /** */ 81 public static GType getType() 82 { 83 return gtk_editable_get_type(); 84 } 85 86 /** 87 * Copies the contents of the currently selected content in the editable and 88 * puts it on the clipboard. 89 */ 90 public void copyClipboard(); 91 92 /** 93 * Removes the contents of the currently selected content in the editable and 94 * puts it on the clipboard. 95 */ 96 public void cutClipboard(); 97 98 /** 99 * Deletes the currently selected text of the editable. 100 * This call doesn’t do anything if there is no selected text. 101 */ 102 public void deleteSelection(); 103 104 /** 105 * Deletes a sequence of characters. The characters that are deleted are 106 * those characters at positions from @start_pos up to, but not including 107 * @end_pos. If @end_pos is negative, then the characters deleted 108 * are those from @start_pos to the end of the text. 109 * 110 * Note that the positions are specified in characters, not bytes. 111 * 112 * Params: 113 * startPos = start position 114 * endPos = end position 115 */ 116 public void deleteText(int startPos, int endPos); 117 118 /** 119 * Retrieves a sequence of characters. The characters that are retrieved 120 * are those characters at positions from @start_pos up to, but not 121 * including @end_pos. If @end_pos is negative, then the characters 122 * retrieved are those characters from @start_pos to the end of the text. 123 * 124 * Note that positions are specified in characters, not bytes. 125 * 126 * Params: 127 * startPos = start of text 128 * endPos = end of text 129 * 130 * Returns: a pointer to the contents of the widget as a 131 * string. This string is allocated by the #GtkEditable 132 * implementation and should be freed by the caller. 133 */ 134 public string getChars(int startPos, int endPos); 135 136 /** 137 * Retrieves whether @editable is editable. See 138 * gtk_editable_set_editable(). 139 * 140 * Returns: %TRUE if @editable is editable. 141 */ 142 public bool getEditable(); 143 144 /** 145 * Retrieves the current position of the cursor relative to the start 146 * of the content of the editable. 147 * 148 * Note that this position is in characters, not in bytes. 149 * 150 * Returns: the cursor position 151 */ 152 public int getPosition(); 153 154 /** 155 * Retrieves the selection bound of the editable. start_pos will be filled 156 * with the start of the selection and @end_pos with end. If no text was 157 * selected both will be identical and %FALSE will be returned. 158 * 159 * Note that positions are specified in characters, not bytes. 160 * 161 * Params: 162 * startPos = location to store the starting position, or %NULL 163 * endPos = location to store the end position, or %NULL 164 * 165 * Returns: %TRUE if an area is selected, %FALSE otherwise 166 */ 167 public bool getSelectionBounds(out int startPos, out int endPos); 168 169 /** 170 * Inserts @new_text_length bytes of @new_text into the contents of the 171 * widget, at position @position. 172 * 173 * Note that the position is in characters, not in bytes. 174 * The function updates @position to point after the newly inserted text. 175 * 176 * Params: 177 * newText = the text to append 178 * newTextLength = the length of the text in bytes, or -1 179 * position = location of the position text will be inserted at 180 */ 181 public void insertText(string newText, int newTextLength, ref int position); 182 183 /** 184 * Pastes the content of the clipboard to the current position of the 185 * cursor in the editable. 186 */ 187 public void pasteClipboard(); 188 189 /** 190 * Selects a region of text. The characters that are selected are 191 * those characters at positions from @start_pos up to, but not 192 * including @end_pos. If @end_pos is negative, then the 193 * characters selected are those characters from @start_pos to 194 * the end of the text. 195 * 196 * Note that positions are specified in characters, not bytes. 197 * 198 * Params: 199 * startPos = start of region 200 * endPos = end of region 201 */ 202 public void selectRegion(int startPos, int endPos); 203 204 /** 205 * Determines if the user can edit the text in the editable 206 * widget or not. 207 * 208 * Params: 209 * isEditable = %TRUE if the user is allowed to edit the text 210 * in the widget 211 */ 212 public void setEditable(bool isEditable); 213 214 /** 215 * Sets the cursor position in the editable to the given value. 216 * 217 * The cursor is displayed before the character with the given (base 0) 218 * index in the contents of the editable. The value must be less than or 219 * equal to the number of characters in the editable. A value of -1 220 * indicates that the position should be set after the last character 221 * of the editable. Note that @position is in characters, not in bytes. 222 * 223 * Params: 224 * position = the position of the cursor 225 */ 226 public void setPosition(int position); 227 228 /** 229 * The ::changed signal is emitted at the end of a single 230 * user-visible operation on the contents of the #GtkEditable. 231 * 232 * E.g., a paste operation that replaces the contents of the 233 * selection will cause only one signal emission (even though it 234 * is implemented by first deleting the selection, then inserting 235 * the new content, and may cause multiple ::notify::text signals 236 * to be emitted). 237 */ 238 gulong addOnChanged(void delegate(EditableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 239 240 /** 241 * This signal is emitted when text is deleted from 242 * the widget by the user. The default handler for 243 * this signal will normally be responsible for deleting 244 * the text, so by connecting to this signal and then 245 * stopping the signal with g_signal_stop_emission(), it 246 * is possible to modify the range of deleted text, or 247 * prevent it from being deleted entirely. The @start_pos 248 * and @end_pos parameters are interpreted as for 249 * gtk_editable_delete_text(). 250 * 251 * Params: 252 * startPos = the starting position 253 * endPos = the end position 254 */ 255 gulong addOnDeleteText(void delegate(int, int, EditableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 256 257 /** 258 * This signal is emitted when text is inserted into 259 * the widget by the user. The default handler for 260 * this signal will normally be responsible for inserting 261 * the text, so by connecting to this signal and then 262 * stopping the signal with g_signal_stop_emission(), it 263 * is possible to modify the inserted text, or prevent 264 * it from being inserted entirely. 265 * 266 * Params: 267 * newText = the new text to insert 268 * newTextLength = the length of the new text, in bytes, 269 * or -1 if new_text is nul-terminated 270 * position = the position, in characters, 271 * at which to insert the new text. this is an in-out 272 * parameter. After the signal emission is finished, it 273 * should point after the newly inserted text. 274 */ 275 gulong addOnInsertText(void delegate(string, int, void*, EditableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 276 }