Debian Codegraph @

gtk/src/entrybuffer.hg

raw
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, see <https://www.gnu.org/licenses/>.
15 */
16
17 // This is for including the config header before any code (such as
18 // the #ifndef GTKMM_DISABLE_DEPRECATED in deprecated classes) is generated:
19 _CONFIGINCLUDE(gtkmmconfig.h)
20
21 #include <glibmm/object.h>
22 #include <gtkmmconfig.h>
23 #include <utility>
24
25 _DEFS(gtkmm,gtk)
26 _PINCLUDE(glibmm/private/object_p.h)
27
28 namespace Gtk
29 {
30
31 /** A Text buffer for the Entry widget.
32 *
33 * The EntryBuffer class contains the actual text displayed in an Entry widget.
34 *
35 * A single EntryBuffer object can be shared by multiple Entry
36 * widgets which will then share the same text content, but not the cursor
37 * position, visibility attributes, icon etc.
38 *
39 * EntryBuffer may be derived from. Such a derived class might allow
40 * text to be stored in an alternate location, such as non-pageable memory,
41 * useful in the case of important passwords. Or a derived class could
42 * integrate with an application's concept of undo/redo.
43 *
44 * @newin{2,20}
45 */
46 class GTKMM_API EntryBuffer : public Glib::Object
47 {
48 _CLASS_GOBJECT(EntryBuffer, GtkEntryBuffer, GTK_ENTRY_BUFFER, Glib::Object, GObject, , , GTKMM_API)
49 protected:
50
51 /** Create a new EntryBuffer object with no text.
52 */
53 _CTOR_DEFAULT()
54
55 /** Create a new EntryBuffer object.
56 *
57 * @param text Initial buffer text.
58 */
59 explicit EntryBuffer(const Glib::ustring& text);
60
61 public:
62 /** Create a new EntryBuffer object with no text.
63 */
64 _WRAP_CREATE()
65
66 /** Create a new EntryBuffer object.
67 *
68 * @param text Initial buffer text.
69 */
70 _WRAP_CREATE(const Glib::ustring& text)
71
72 _WRAP_METHOD(gsize get_bytes() const, gtk_entry_buffer_get_bytes)
73 _WRAP_METHOD(guint get_length() const, gtk_entry_buffer_get_length)
74 _WRAP_METHOD(Glib::ustring get_text() const, gtk_entry_buffer_get_text)
75
76 /** Sets the text in the buffer.
77 * This is roughly equivalent to calling delete_text() and insert_text().
78 *
79 * @param text The text to set in the buffer.
80 */
81 void set_text(const Glib::ustring& text);
82 _IGNORE(gtk_entry_buffer_set_text)
83
84 _WRAP_METHOD(void set_max_length(int max_length), gtk_entry_buffer_set_max_length)
85 _WRAP_METHOD(int get_max_length() const, gtk_entry_buffer_get_max_length)
86
87 /** Inserts @a text into the contents of the buffer, at position @a position.
88 *
89 * @param position The position at which to insert text.
90 * @param text The text to insert into the buffer.
91 * @result The number of characters actually inserted.
92 */
93 guint insert_text(guint position, const Glib::ustring& text);
94 _IGNORE(gtk_entry_buffer_insert_text)
95
96 _WRAP_METHOD(guint delete_text(guint position, int n_chars), gtk_entry_buffer_delete_text)
97
98 /** Used when deriving from EntryBuffer.
99 * @param position Position at which text was inserted.
100 * @param text Text that was inserted.
101 */
102 void emit_inserted_text(guint position, const Glib::ustring& text);
103 _IGNORE(gtk_entry_buffer_emit_inserted_text)
104
105 _WRAP_METHOD(void emit_deleted_text(guint position, guint n_chars), gtk_entry_buffer_emit_deleted_text)
106
107 _WRAP_SIGNAL(void inserted_text(guint position, const gchar* chars, guint n_chars), "inserted-text")
108 _WRAP_SIGNAL(void deleted_text(guint position, guint n_chars), "deleted-text")
109
110 _WRAP_PROPERTY("text", Glib::ustring)
111 _WRAP_PROPERTY("length", guint)
112 _WRAP_PROPERTY("max-length", int)
113 };
114
115 } // namespace Gtk