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 65 public import glib.Str; 66 67 68 69 70 /** 71 * The GtkEditable interface is an interface which should be implemented by 72 * text editing widgets, such as GtkEntry and GtkSpinButton. It contains functions 73 * for generically manipulating an editable widget, a large number of action 74 * signals used for key bindings, and several signals that an application can 75 * connect to to modify the behavior of a widget. 76 * 77 * As an example of the latter usage, by connecting 78 * the following handler to "insert-text", an application 79 * can convert all entry into a widget into uppercase. 80 * 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 @property 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 @property 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 @property 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 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 * Virtual: set_selection_bounds 222 * Params: 223 * startPos = start of region 224 * endPos = end of region 225 */ 226 public void selectRegion(int startPos, int endPos) 227 { 228 // void gtk_editable_select_region (GtkEditable *editable, gint start_pos, gint end_pos); 229 gtk_editable_select_region(getEditableTStruct(), startPos, endPos); 230 } 231 232 /** 233 * Retrieves the selection bound of the editable. start_pos will be filled 234 * with the start of the selection and end_pos with end. If no text was 235 * selected both will be identical and FALSE will be returned. 236 * Note that positions are specified in characters, not bytes. 237 * Params: 238 * startPos = location to store the starting position, or NULL. [out][allow-none] 239 * endPos = location to store the end position, or NULL. [out][allow-none] 240 * Returns: TRUE if an area is selected, FALSE otherwise 241 */ 242 public int getSelectionBounds(out int startPos, out int endPos) 243 { 244 // gboolean gtk_editable_get_selection_bounds (GtkEditable *editable, gint *start_pos, gint *end_pos); 245 return gtk_editable_get_selection_bounds(getEditableTStruct(), &startPos, &endPos); 246 } 247 248 /** 249 * Inserts new_text_length bytes of new_text into the contents of the 250 * widget, at position position. 251 * Note that the position is in characters, not in bytes. 252 * The function updates position to point after the newly inserted text. 253 * Virtual: do_insert_text 254 * Params: 255 * newText = the text to append 256 * position = location of the position text will be inserted at. [inout] 257 */ 258 public void insertText(string newText, ref int position) 259 { 260 // void gtk_editable_insert_text (GtkEditable *editable, const gchar *new_text, gint new_text_length, gint *position); 261 gtk_editable_insert_text(getEditableTStruct(), cast(char*)newText.ptr, cast(int) newText.length, &position); 262 } 263 264 /** 265 * Deletes a sequence of characters. The characters that are deleted are 266 * those characters at positions from start_pos up to, but not including 267 * end_pos. If end_pos is negative, then the characters deleted 268 * are those from start_pos to the end of the text. 269 * Note that the positions are specified in characters, not bytes. 270 * Virtual: do_delete_text 271 * Params: 272 * startPos = start position 273 * endPos = end position 274 */ 275 public void deleteText(int startPos, int endPos) 276 { 277 // void gtk_editable_delete_text (GtkEditable *editable, gint start_pos, gint end_pos); 278 gtk_editable_delete_text(getEditableTStruct(), startPos, endPos); 279 } 280 281 /** 282 * Retrieves a sequence of characters. The characters that are retrieved 283 * are those characters at positions from start_pos up to, but not 284 * including end_pos. If end_pos is negative, then the characters 285 * retrieved are those characters from start_pos to the end of the text. 286 * Note that positions are specified in characters, not bytes. 287 * Params: 288 * startPos = start of text 289 * endPos = end of text 290 * 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. 291 */ 292 public string getChars(int startPos, int endPos) 293 { 294 // gchar * gtk_editable_get_chars (GtkEditable *editable, gint start_pos, gint end_pos); 295 return Str.toString(gtk_editable_get_chars(getEditableTStruct(), startPos, endPos)); 296 } 297 298 /** 299 * Removes the contents of the currently selected content in the editable and 300 * puts it on the clipboard. 301 */ 302 public void cutClipboard() 303 { 304 // void gtk_editable_cut_clipboard (GtkEditable *editable); 305 gtk_editable_cut_clipboard(getEditableTStruct()); 306 } 307 308 /** 309 * Copies the contents of the currently selected content in the editable and 310 * puts it on the clipboard. 311 */ 312 public void copyClipboard() 313 { 314 // void gtk_editable_copy_clipboard (GtkEditable *editable); 315 gtk_editable_copy_clipboard(getEditableTStruct()); 316 } 317 318 /** 319 * Pastes the content of the clipboard to the current position of the 320 * cursor in the editable. 321 */ 322 public void pasteClipboard() 323 { 324 // void gtk_editable_paste_clipboard (GtkEditable *editable); 325 gtk_editable_paste_clipboard(getEditableTStruct()); 326 } 327 328 /** 329 * Deletes the currently selected text of the editable. 330 * This call doesn't do anything if there is no selected text. 331 */ 332 public void deleteSelection() 333 { 334 // void gtk_editable_delete_selection (GtkEditable *editable); 335 gtk_editable_delete_selection(getEditableTStruct()); 336 } 337 338 /** 339 * Sets the cursor position in the editable to the given value. 340 * The cursor is displayed before the character with the given (base 0) 341 * index in the contents of the editable. The value must be less than or 342 * equal to the number of characters in the editable. A value of -1 343 * indicates that the position should be set after the last character 344 * of the editable. Note that position is in characters, not in bytes. 345 * Params: 346 * position = the position of the cursor 347 */ 348 public void setPosition(int position) 349 { 350 // void gtk_editable_set_position (GtkEditable *editable, gint position); 351 gtk_editable_set_position(getEditableTStruct(), position); 352 } 353 354 /** 355 * Retrieves the current position of the cursor relative to the start 356 * of the content of the editable. 357 * Note that this position is in characters, not in bytes. 358 * Returns: the cursor position 359 */ 360 public int getPosition() 361 { 362 // gint gtk_editable_get_position (GtkEditable *editable); 363 return gtk_editable_get_position(getEditableTStruct()); 364 } 365 366 /** 367 * Determines if the user can edit the text in the editable 368 * widget or not. 369 * Params: 370 * isEditable = TRUE if the user is allowed to edit the text 371 * in the widget 372 */ 373 public void setEditable(int isEditable) 374 { 375 // void gtk_editable_set_editable (GtkEditable *editable, gboolean is_editable); 376 gtk_editable_set_editable(getEditableTStruct(), isEditable); 377 } 378 379 /** 380 * Retrieves whether editable is editable. See 381 * gtk_editable_set_editable(). 382 * 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). 383 */ 384 public int getEditable() 385 { 386 // gboolean gtk_editable_get_editable (GtkEditable *editable); 387 return gtk_editable_get_editable(getEditableTStruct()); 388 } 389 }