Debian Codegraph @

gtk/src/entry.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 #include <gtkmm/widget.h>
18 #include <gtkmm/editable.h>
19 #include <gtkmm/menu.h>
20 #include <gtkmm/celleditable.h>
21 #include <gtkmm/entrycompletion.h>
22 #include <gtkmm/adjustment.h>
23 #include <gtkmm/image.h> //For ImageType.
24 #include <gtkmm/border.h>
25 #include <gtkmm/entrybuffer.h>
26 #include <pangomm/attrlist.h>
27 #include <pangomm/tabarray.h>
28
29 _DEFS(gtkmm,gtk)
30 _PINCLUDE(gtkmm/private/widget_p.h)
31
32 namespace Gtk
33 {
34
35 _WRAP_ENUM(EntryIconPosition, GtkEntryIconPosition, decl_prefix GTKMM_API)
36
37 /** A single line text entry field.
38 *
39 * The Gtk::Entry widget is a single line text entry widget. A fairly large
40 * set of key bindings are supported by default. If the entered text is
41 * longer than the allocation of the widget, the widget will scroll so that
42 * the cursor position is visible.
43 *
44 * The Entry widget looks like this:
45 * @image html entry1.png
46 *
47 * @ingroup Widgets
48 */
49 class GTKMM_API Entry
50 : public Widget,
51 public Editable,
52 public CellEditable
53 {
54 _CLASS_GTKOBJECT(Entry,GtkEntry,GTK_ENTRY,Gtk::Widget,GtkWidget, , , GTKMM_API)
55 _IMPLEMENTS_INTERFACE(Editable)
56 _IMPLEMENTS_INTERFACE(CellEditable)
57 public:
58
59 _CTOR_DEFAULT
60 _WRAP_CTOR(Entry(const Glib::RefPtr<EntryBuffer>& buffer), gtk_entry_new_with_buffer)
61
62 _WRAP_METHOD(Glib::RefPtr<EntryBuffer> get_buffer(), gtk_entry_get_buffer, refreturn)
63 _WRAP_METHOD(Glib::RefPtr<const EntryBuffer> get_buffer() const, gtk_entry_get_buffer, refreturn, constversion)
64
65 /** Returns the area where the entry's text is drawn.
66 * This function is useful when drawing something to the entry in a draw callback.
67 *
68 * See also get_icon_area().
69 *
70 * @result The location for the text area.
71 *
72 * @newin{3,0}
73 **/
74 Gdk::Rectangle get_text_area() const;
75 _IGNORE(gtk_entry_get_text_area)
76
77 _WRAP_METHOD(void set_buffer(const Glib::RefPtr<EntryBuffer>& buffer), gtk_entry_set_buffer)
78 _WRAP_METHOD(void set_visibility(bool visible = true), gtk_entry_set_visibility)
79 _WRAP_METHOD(bool get_visibility() const, gtk_entry_get_visibility)
80 _WRAP_METHOD(void set_invisible_char(gunichar ch), gtk_entry_set_invisible_char)
81 _WRAP_METHOD(void unset_invisible_char(), gtk_entry_unset_invisible_char)
82 _WRAP_METHOD(gunichar get_invisible_char() const, gtk_entry_get_invisible_char)
83 _WRAP_METHOD(void set_has_frame(bool setting = true), gtk_entry_set_has_frame)
84 _WRAP_METHOD(bool get_has_frame() const, gtk_entry_get_has_frame)
85
86 _WRAP_METHOD(void set_inner_border(const Border& border), gtk_entry_set_inner_border, deprecated "Use the standard border and padding CSS properties instead (through classes like StyleContext and CssProvider).")
87 _WRAP_METHOD(Border get_inner_border() const, gtk_entry_get_inner_border, deprecated "Use the standard border and padding CSS properties instead (through classes like StyleContext and CssProvider).")
88
89 _WRAP_METHOD(void set_overwrite_mode(bool overwrite = true), gtk_entry_set_overwrite_mode)
90 _WRAP_METHOD(bool get_overwrite_mode() const, gtk_entry_get_overwrite_mode)
91 _WRAP_METHOD(void set_max_length(int max), gtk_entry_set_max_length)
92 _WRAP_METHOD(int get_max_length() const, gtk_entry_get_max_length)
93 _WRAP_METHOD(guint16 get_text_length() const, gtk_entry_get_text_length)
94 _WRAP_METHOD(void set_activates_default(bool setting = true), gtk_entry_set_activates_default)
95 _WRAP_METHOD(gboolean get_activates_default() const, gtk_entry_get_activates_default)
96 _WRAP_METHOD(void set_width_chars(int n_chars), gtk_entry_set_width_chars)
97 _WRAP_METHOD(int get_width_chars() const, gtk_entry_get_width_chars)
98 _WRAP_METHOD(void set_max_width_chars(int n_chars), gtk_entry_set_max_width_chars)
99 _WRAP_METHOD(int get_max_width_chars() const, gtk_entry_get_max_width_chars)
100 _WRAP_METHOD(void set_text(const Glib::ustring &text), gtk_entry_set_text)
101 _WRAP_METHOD(Glib::ustring get_text() const, gtk_entry_get_text)
102 _WRAP_METHOD(Glib::RefPtr<Pango::Layout> get_layout(), gtk_entry_get_layout, refreturn)
103 _WRAP_METHOD(Glib::RefPtr<const Pango::Layout> get_layout() const, gtk_entry_get_layout, refreturn, constversion)
104 _WRAP_METHOD(void get_layout_offsets(int& x, int& y), gtk_entry_get_layout_offsets)
105
106 _WRAP_METHOD(int layout_index_to_text_index(int layout_index) const, gtk_entry_layout_index_to_text_index)
107 _WRAP_METHOD(int text_index_to_layout_index(int text_index) const, gtk_entry_text_index_to_layout_index)
108
109 _WRAP_METHOD(void set_cursor_hadjustment(const Glib::RefPtr<Adjustment>& adjustment), gtk_entry_set_cursor_hadjustment)
110 _WRAP_METHOD(Glib::RefPtr<Adjustment> get_cursor_hadjustment(), gtk_entry_get_cursor_hadjustment, refreturn)
111 _WRAP_METHOD(Glib::RefPtr<const Adjustment> get_cursor_hadjustment() const, gtk_entry_get_cursor_hadjustment, refreturn, constversion)
112
113 _WRAP_METHOD(void set_alignment(float xalign), gtk_entry_set_alignment)
114 _WRAP_METHOD(void set_alignment(Align xalign), gtk_entry_set_alignment)
115 _WRAP_METHOD(float get_alignment() const, gtk_entry_get_alignment)
116
117 _WRAP_METHOD(void set_completion(const Glib::RefPtr<EntryCompletion>& completion), gtk_entry_set_completion)
118 _WRAP_METHOD(Glib::RefPtr<EntryCompletion> get_completion(), gtk_entry_get_completion, refreturn)
119 _WRAP_METHOD(Glib::RefPtr<const EntryCompletion> get_completion() const, gtk_entry_get_completion, refreturn, constversion)
120
121 _WRAP_METHOD(void set_progress_fraction(double fraction), gtk_entry_set_progress_fraction)
122 _WRAP_METHOD(double get_progress_fraction() const, gtk_entry_get_progress_fraction)
123 _WRAP_METHOD(void set_progress_pulse_step(double fraction), gtk_entry_set_progress_pulse_step)
124 _WRAP_METHOD(double get_progress_pulse_step(), gtk_entry_get_progress_pulse_step)
125 _WRAP_METHOD(void progress_pulse(), gtk_entry_progress_pulse)
126
127 _WRAP_METHOD(Glib::ustring get_placeholder_text() const, gtk_entry_get_placeholder_text)
128 _WRAP_METHOD(void set_placeholder_text(const Glib::ustring& text), gtk_entry_set_placeholder_text)
129
130 //We hand-code these so we can change the parameter order, so we can have a default parameter value:
131 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_from_pixbuf)
132 void set_icon_from_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
133 _IGNORE(gtk_entry_set_icon_from_pixbuf)
134
135 _WRAP_METHOD(void set_icon_from_stock(const StockID& stock_id{.}, EntryIconPosition icon_pos{.} = ENTRY_ICON_PRIMARY), gtk_entry_set_icon_from_stock, deprecated "Use set_icon_from_icon_name() instead.")
136
137 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_from_icon_name)
138 void set_icon_from_icon_name(const Glib::ustring& icon_name, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
139 _IGNORE(gtk_entry_set_icon_from_icon_name)
140
141 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_from_gicon)
142 void set_icon_from_gicon(const Glib::RefPtr<Gio::Icon>& icon, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
143 _IGNORE(gtk_entry_set_icon_from_gicon)
144
145 /** Do not show any icon in the specified position.
146 * See set_icon_from_pixbuf(), set_icon_from_stock(), set_icon_from_icon_name(),
147 * and set_icon_from_gicon().
148 *
149 * @param icon_pos The icon position.
150 *
151 * @newin{3,0}
152 */
153 void unset_icon(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
154
155 _WRAP_METHOD(ImageType get_icon_storage_type(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_storage_type)
156 _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_icon_pixbuf(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY), gtk_entry_get_icon_pixbuf, refreturn)
157 _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_icon_pixbuf(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_pixbuf, refreturn, constversion)
158 _WRAP_METHOD(StockID get_icon_stock(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_stock, deprecated "Use get_icon_name() instead.")
159 _WRAP_METHOD(Glib::ustring get_icon_name(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_name)
160 _WRAP_METHOD(Glib::RefPtr<Gio::Icon> get_icon_gicon(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY), gtk_entry_get_icon_gicon, refreturn)
161 _WRAP_METHOD(Glib::RefPtr<const Gio::Icon> get_icon_gicon(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_gicon, refreturn, constversion)
162
163 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_activatable)
164 void set_icon_activatable(bool activatable = true, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
165 _IGNORE(gtk_entry_set_icon_activatable)
166
167 _WRAP_METHOD(bool get_icon_activatable(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_activatable)
168 _WRAP_METHOD(void set_icon_sensitive(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY, bool sensitive = true), gtk_entry_set_icon_sensitive)
169 _WRAP_METHOD(bool get_icon_sensitive(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY), gtk_entry_get_icon_sensitive)
170 _WRAP_METHOD(int get_icon_at_pos(int x, int y) const, gtk_entry_get_icon_at_pos)
171
172 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_tooltip_text)
173 void set_icon_tooltip_text(const Glib::ustring& tooltip, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
174 _IGNORE(gtk_entry_set_icon_tooltip_text)
175
176 _WRAP_METHOD(Glib::ustring get_icon_tooltip_text(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_tooltip_text)
177
178 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_tooltip_markup)
179 void set_icon_tooltip_markup(const Glib::ustring& tooltip, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
180 _IGNORE(gtk_entry_set_icon_tooltip_markup)
181
182 _WRAP_METHOD(Glib::ustring get_icon_tooltip_markup(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const, gtk_entry_get_icon_tooltip_markup)
183
184 _WRAP_METHOD_DOCS_ONLY(gtk_entry_set_icon_drag_source)
185 void set_icon_drag_source(const Glib::RefPtr<TargetList>& target_list, Gdk::DragAction actions = Gdk::ACTION_COPY, EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY);
186 _IGNORE(gtk_entry_set_icon_drag_source)
187
188 /** Returns the area where entry's icon at @a icon_pos is drawn.
189 * This function is useful when drawing something to the
190 * entry in a draw callback.
191 *
192 * See also get_text_area().
193 *
194 * @param icon_pos Icon position.
195 * @result The location for the icon area.
196 *
197 * @newin{3,0}
198 */
199 Gdk::Rectangle get_icon_area(EntryIconPosition icon_pos = ENTRY_ICON_PRIMARY) const;
200 _IGNORE(gtk_entry_get_icon_area)
201
202 _WRAP_METHOD(int get_current_icon_drag_source(), gtk_entry_get_current_icon_drag_source)
203 _WRAP_METHOD(bool im_context_filter_keypress(GdkEventKey* gdk_event), gtk_entry_im_context_filter_keypress)
204 _WRAP_METHOD(void reset_im_context(), gtk_entry_reset_im_context)
205
206 _WRAP_METHOD(void set_input_purpose(InputPurpose purpose), gtk_entry_set_input_purpose)
207 _WRAP_METHOD(InputPurpose get_input_purpose() const, gtk_entry_get_input_purpose)
208
209 _WRAP_METHOD(void set_input_hints(InputHints hints), gtk_entry_set_input_hints)
210 _WRAP_METHOD(InputHints get_input_hints() const, gtk_entry_get_input_hints)
211
212 _WRAP_METHOD(void set_attributes(Pango::AttrList& attrs), gtk_entry_set_attributes)
213 _WRAP_METHOD(Pango::AttrList get_attributes() const, gtk_entry_get_attributes)
214
215 #m4 _CONVERSION(`PangoTabArray*',`Pango::TabArray',`Pango::TabArray(($3))')
216 #m4 _CONVERSION(`const Pango::TabArray&',`PangoTabArray*',`const_cast<Pango::TabArray&>($3).gobj()')
217 _WRAP_METHOD(void set_tabs(const Pango::TabArray& tabs), gtk_entry_set_tabs)
218 _WRAP_METHOD(Pango::TabArray get_tabs() const, gtk_entry_get_tabs)
219
220 _WRAP_METHOD(void grab_focus_without_selecting(), gtk_entry_grab_focus_without_selecting)
221
222 //TODO: This signal now takes a GtkWidget* instead of just a GtkMenu*,
223 //so change that when we can break ABI.
224 //See https://git.gnome.org/browse/gtk+/commit/?id=88623b98a7ca0afca08ac21bc3aa662c6ed3ab7f
225 #m4 _CONVERSION(`Menu*',`GtkWidget*',`GTK_WIDGET(($3)->gobj())')
226 _WRAP_SIGNAL(void populate_popup(Menu* menu), "populate_popup")
227
228 #m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
229 _WRAP_SIGNAL(void insert_at_cursor(const Glib::ustring& str), "insert_at_cursor")
230
231 //Note that the GTK+ C documentation for the activate signal says (as of 2012-06) that it should be used by applications even though it is a keybinding signal.
232 _WRAP_SIGNAL(void activate(), "activate")
233
234 _WRAP_SIGNAL(void icon_release(EntryIconPosition icon_position, const GdkEventButton* event), "icon-release", no_default_handler)
235 _WRAP_SIGNAL(void icon_press(EntryIconPosition icon_position, const GdkEventButton* event), "icon-press", no_default_handler)
236
237 _IGNORE_SIGNAL("move_cursor")
238 _IGNORE_SIGNAL("delete_from_cursor")
239 _IGNORE_SIGNAL("cut_clipboard")
240 _IGNORE_SIGNAL("copy_clipboard")
241 _IGNORE_SIGNAL("paste_clipboard")
242 _IGNORE_SIGNAL("toggle_overwrite")
243 _IGNORE_SIGNAL("backspace")
244 _IGNORE_SIGNAL("preedit-changed")
245
246 _WRAP_PROPERTY("buffer", Glib::RefPtr<EntryBuffer>)
247 _WRAP_PROPERTY("cursor-position", int)
248 _WRAP_PROPERTY("selection-bound", int)
249 _WRAP_PROPERTY("editable", bool)
250 _WRAP_PROPERTY("max-length", int)
251 _WRAP_PROPERTY("visibility", bool)
252 _WRAP_PROPERTY("has-frame", bool)
253 _WRAP_PROPERTY("inner-border", Border, deprecated "Use the standard border and padding CSS properties (through objects like StyleContext and CssProvider); the value of this style property is ignored.")
254 _WRAP_PROPERTY("invisible-char", gunichar)
255 _WRAP_PROPERTY("invisible-char-set", bool)
256 _WRAP_PROPERTY("activates-default", bool)
257 _WRAP_PROPERTY("width-chars", int)
258 _WRAP_PROPERTY("max-width-chars", int)
259 _WRAP_PROPERTY("scroll-offset", int)
260 _WRAP_PROPERTY("shadow-type", ShadowType,
261 deprecated "This property is ignored. Use CSS to determine the style of the border.")
262 _WRAP_PROPERTY("text", Glib::ustring)
263 _WRAP_PROPERTY("xalign", float)
264 _WRAP_PROPERTY("truncate-multiline", bool)
265 _WRAP_PROPERTY("overwrite-mode", bool)
266 _WRAP_PROPERTY("text-length", guint)
267 _WRAP_PROPERTY("caps-lock-warning", bool)
268 _WRAP_PROPERTY("progress-fraction", double)
269 _WRAP_PROPERTY("progress-pulse-step", double)
270 _WRAP_PROPERTY("primary-icon-pixbuf", Glib::RefPtr<Gdk::Pixbuf>)
271 _WRAP_PROPERTY("secondary-icon-pixbuf", Glib::RefPtr<Gdk::Pixbuf>)
272 _WRAP_PROPERTY("primary-icon-stock", StockID, deprecated "Use property_primary_icon_name() instead.")
273 _WRAP_PROPERTY("secondary-icon-stock", StockID, deprecated "Use property_secondary_icon_name() instead.")
274 _WRAP_PROPERTY("primary-icon-name", Glib::ustring)
275 _WRAP_PROPERTY("secondary-icon-name", Glib::ustring)
276 _WRAP_PROPERTY("primary-icon-gicon", Glib::RefPtr<Gio::Icon>)
277 _WRAP_PROPERTY("secondary-icon-gicon", Glib::RefPtr<Gio::Icon>)
278 _WRAP_PROPERTY("primary-icon-storage-type", ImageType)
279 _WRAP_PROPERTY("secondary-icon-storage-type", ImageType)
280 _WRAP_PROPERTY("primary-icon-activatable", bool)
281 _WRAP_PROPERTY("secondary-icon-activatable", bool)
282 _WRAP_PROPERTY("primary-icon-sensitive", bool)
283 _WRAP_PROPERTY("secondary-icon-sensitive", bool)
284 _WRAP_PROPERTY("primary-icon-tooltip-text", bool)
285 _WRAP_PROPERTY("secondary-icon-tooltip-text", bool)
286 _WRAP_PROPERTY("primary-icon-tooltip-markup", bool)
287 _WRAP_PROPERTY("secondary-icon-tooltip-markup", bool)
288 _WRAP_PROPERTY("im-module", Glib::ustring)
289 _WRAP_PROPERTY("placeholder-text", Glib::ustring)
290 _WRAP_PROPERTY("completion", Glib::RefPtr<EntryCompletion>)
291 _WRAP_PROPERTY("input-purpose", InputPurpose)
292 _WRAP_PROPERTY("input-hints", InputHints)
293 _WRAP_PROPERTY("attributes", Pango::AttrList)
294 _WRAP_PROPERTY("populate-all", bool)
295 _WRAP_PROPERTY("tabs", Pango::TabArray)
296 };
297
298 } //namespace Gtk