1/* Copyright(C) 1998-2002 The gtkmm Development Team 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Lesser General Public 5 * License as published by the Free Software Foundation; either 6 * version 2.1 of the License, or(at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public 14 * License along with this library; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 */ 17 18// This is for including the config header before any code (such as 19// the #ifndef GTKMM_DISABLE_DEPRECATED in deprecated classes) is generated: 20_CONFIGINCLUDE(gtkmmconfig.h) 21 22#include <glibmm/object.h> 23#include <gtkmmconfig.h> 24#include <utility> 25 26_DEFS(gtkmm,gtk) 27_PINCLUDE(glibmm/private/object_p.h) 28 29namespace Gtk 30{ 31 32/** A Text buffer for the Entry widget. 33 * 34 * The EntryBuffer class contains the actual text displayed in an Entry widget. 35 * 36 * A single EntryBuffer object can be shared by multiple Entry 37 * widgets which will then share the same text content, but not the cursor 38 * position, visibility attributes, icon etc. 39 * 40 * EntryBuffer may be derived from. Such a derived class might allow 41 * text to be stored in an alternate location, such as non-pageable memory, 42 * useful in the case of important passwords. Or a derived class could 43 * integrate with an application's concept of undo/redo. 44 * 45 * @newin{2,20} 46 */ 47class EntryBuffer : public Glib::Object 48{ 49 _CLASS_GOBJECT(EntryBuffer, GtkEntryBuffer, GTK_ENTRY_BUFFER, Glib::Object, GObject) 50protected: 51 52 /** Create a new EntryBuffer object with no text. 53 */ 54 _CTOR_DEFAULT() 55 56 /** Create a new EntryBuffer object. 57 * 58 * @param text Initial buffer text. 59 */ 60 explicit EntryBuffer(const Glib::ustring& text); 61 62public: 63 /** Create a new EntryBuffer object with no text. 64 */ 65 _WRAP_CREATE() 66 67 /** Create a new EntryBuffer object. 68 * 69 * @param text Initial buffer text. 70 */ 71 _WRAP_CREATE(const Glib::ustring& text) 72 73 _WRAP_METHOD(gsize get_bytes() const, gtk_entry_buffer_get_bytes) 74 _WRAP_METHOD(guint get_length() const, gtk_entry_buffer_get_length) 75 _WRAP_METHOD(Glib::ustring get_text() const, gtk_entry_buffer_get_text) 76 77 /** Sets the text in the buffer. 78 * This is roughly equivalent to calling delete_text() and insert_text(). 79 * 80 * @param text The text to set in the buffer. 81 */ 82 void set_text(const Glib::ustring& text); 83 _IGNORE(gtk_entry_buffer_set_text) 84 85 _WRAP_METHOD(void set_max_length(int max_length), gtk_entry_buffer_set_max_length) 86 _WRAP_METHOD(int get_max_length() const, gtk_entry_buffer_get_max_length) 87 88 /** Inserts @a text into the contents of the buffer, at position @a position. 89 * 90 * @param position The position at which to insert text. 91 * @param text The text to insert into the buffer. 92 * @result The number of characters actually inserted. 93 */ 94 guint insert_text(guint position, const Glib::ustring& text); 95 _IGNORE(gtk_entry_buffer_insert_text) 96 97 _WRAP_METHOD(guint delete_text(guint position, int n_chars), gtk_entry_buffer_delete_text) 98 99 /** Used when deriving from EntryBuffer. 100 * @param position Position at which text was inserted. 101 * @param text Text that was inserted. 102 */ 103 void emit_inserted_text(guint position, const Glib::ustring& text); 104 _IGNORE(gtk_entry_buffer_emit_inserted_text) 105 106 _WRAP_METHOD(void emit_deleted_text(guint position, guint n_chars), gtk_entry_buffer_emit_deleted_text) 107 108 _WRAP_SIGNAL(void inserted_text(guint position, const gchar* chars, guint n_chars), "inserted-text") 109 _WRAP_SIGNAL(void deleted_text(guint position, guint n_chars), "deleted-text") 110 111 _WRAP_PROPERTY("text", Glib::ustring) 112 _WRAP_PROPERTY("length", guint) 113 _WRAP_PROPERTY("max-length", int) 114}; 115 116} // namespace Gtk 117 118