Debian Codegraph @

gtk/src/editable.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 _CONFIGINCLUDE(gtkmmconfig.h)
18
19 #include <glibmm/interface.h>
20 _DEFS(gtkmm,gtk)
21 _PINCLUDE(glibmm/private/interface_p.h)
22
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24 extern "C"
25 {
26 typedef struct _GtkEditableInterface GtkEditableInterface;
27 }
28 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
29
30 namespace Gtk
31 {
32
33 /** Base class for text-editing widgets.
34 *
35 * The Gtk::Editable class is a base class for widgets for editing text,
36 * such as Gtk::Entry. It cannot be instantiated by itself. The editable
37 * class contains functions for generically manipulating an editable widget,
38 * a large number of action signals used for key bindings, and several
39 * signals that an application can connect to to modify the behavior of a
40 * widget.
41 *
42 */
43 class GTKMM_API Editable : public Glib::Interface
44 {
45 _CLASS_INTERFACE(Editable,GtkEditable,GTK_EDITABLE,GtkEditableInterface,,,GTKMM_API)
46
47 public:
48 _WRAP_METHOD(void cut_clipboard(), gtk_editable_cut_clipboard)
49 _WRAP_METHOD(void copy_clipboard(), gtk_editable_copy_clipboard)
50 _WRAP_METHOD(void paste_clipboard(), gtk_editable_paste_clipboard)
51 _WRAP_METHOD(void delete_selection(), gtk_editable_delete_selection)
52 _WRAP_METHOD(void set_editable(bool is_editable = true), gtk_editable_set_editable)
53 _WRAP_METHOD(bool get_editable() const, gtk_editable_get_editable)
54
55 _WRAP_METHOD(void insert_text(const Glib::ustring& new_text, int new_text_length, int& position), gtk_editable_insert_text)
56 _WRAP_METHOD(void delete_text(int start_pos, int end_pos), gtk_editable_delete_text)
57
58 _WRAP_METHOD(Glib::ustring get_chars(int start_pos, int end_pos) const, gtk_editable_get_chars)
59
60 _WRAP_METHOD(void select_region(int start_pos, int end_pos), gtk_editable_select_region)
61 _WRAP_METHOD(bool get_selection_bounds(int& start_pos, int& end_pos) const, gtk_editable_get_selection_bounds)
62
63 _WRAP_METHOD(void set_position(int position), gtk_editable_set_position)
64 _WRAP_METHOD(int get_position() const, gtk_editable_get_position)
65
66 _IGNORE_SIGNAL(insert_text)
67
68 #m4begin
69 dnl // WRAP_SIGNAL "insert_text"
70 dnl // C++ prototype: void insert_text(const Glib::ustring& text, int* position)
71 dnl // C prototype: void insert_text(const gchar* text, gint length, gint* position)
72
73 _SIGNAL_PROXY(
74 insert_text, void, `const gchar* text, gint length, gint* position',
75 insert_text, void, `const Glib::ustring&, int*',dnl // C++ prototype
76 `Glib::ustring(text, text + length), position',`dnl // C -> C++ conversion
77 /**
78 * @param const Glib::ustring& text
79 * @param int* position
80 * @return void
81 */')
82
83 _SIGNAL_H(insert_text, void, `const Glib::ustring& text, int* position')
84 _SIGNAL_PH(insert_text, void, `GtkEditable* self, const gchar* text, gint length, gint* position')
85
86 _SIGNAL_CC(
87 insert_text, insert_text, void, void,
88 `const Glib::ustring& text, int* position',dnl // C++ arguments
89 `text.data(), text.bytes(), position')dnl // C++ -> C conversion
90
91 _SIGNAL_PCC(
92 insert_text, insert_text, void, void,
93 `GtkEditable* self, const gchar* text, gint length, gint* position',dnl // C arguments
94 `self, text, length, position',dnl // C argument names
95 `Glib::ustring(text, text + length), position',dnl // C -> C++ conversion
96 self)
97 #m4end
98
99 _WRAP_SIGNAL(void delete_text(int start_pos, int end_pos), "delete_text")
100 _WRAP_SIGNAL(void changed(), "changed")
101
102 protected:
103
104 #m4begin
105 dnl // WRAP_VFUNC "do_insert_text"
106 dnl // C++ prototype: void insert_text_vfunc(const Glib::ustring& text, int& position)
107 dnl // C prototype: void do_insert_text(const gchar* text, gint length, gint* position)
108
109 _VFUNC_H(insert_text_vfunc, void, `const Glib::ustring& text, int& position')
110 _VFUNC_PH(do_insert_text, void, `GtkEditable* self, const gchar* text, gint length, gint* position')
111 _VFUNC_CC(
112 insert_text_vfunc, do_insert_text, void, void,
113 `const Glib::ustring& text, int& position',dnl // C++ arguments
114 `text.data(), text.bytes(), &position')dnl // C++ -> C conversion
115 _VFUNC_PCC(
116 insert_text_vfunc, do_insert_text, void, void,
117 `GtkEditable* self, const gchar* text, gint length, gint* position',dnl // C arguments
118 `self, text, length, position',dnl // C argument names
119 `Glib::ustring(text, text + length), *position',dnl // C -> C++ conversion
120 self)
121 #m4end
122
123 _WRAP_VFUNC(void delete_text(int start_pos, int end_pos), do_delete_text)
124
125 #m4begin
126 dnl // This special conversion is not in convert_gtk.m4, because allocating a new
127 dnl // string is rarely needed -- probably not a good idea to make this generic.
128 _CONVERSION(`Glib::ustring', `gchar*', `g_strdup(($3).c_str())')
129 _CONVERSION(`gchar*', `Glib::ustring', `Glib::convert_return_gchar_ptr_to_ustring($3)')
130 #m4end
131 _WRAP_VFUNC(Glib::ustring get_chars(int start_pos, int end_pos) const, get_chars)
132
133 _WRAP_VFUNC(void select_region(int start_pos, int end_pos), set_selection_bounds)
134 _WRAP_VFUNC(bool get_selection_bounds(int& start_pos, int& end_pos) const, get_selection_bounds)
135 _WRAP_VFUNC(void set_position(int position), set_position)
136 _WRAP_VFUNC(int get_position() const, get_position)
137 };
138
139 } // namespace Gtk