Debian Codegraph @

gtk/src/textview.hg

raw
1 /* Copyright (C) 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 <gtkmm/container.h>
22 #include <gtkmm/scrollable.h>
23 #include <gtkmm/textbuffer.h>
24 #include <gtkmm/textmark.h>
25 #include <gtkmm/menu.h>
26
27 _DEFS(gtkmm,gtk)
28 _PINCLUDE(gtkmm/private/container_p.h)
29
30
31 namespace Gtk
32 {
33
34 _CC_INCLUDE(gtk/gtk.h)
35 _WRAP_ENUM(TextWindowType, GtkTextWindowType, decl_prefix GTKMM_API)
36
37
38 /** @defgroup TextView TextView Classes
39 * These classes are used with the Gtk::TextView widget.
40 */
41
42 /** Multi-line text editing widget. It displays a Gtk::TextBuffer.
43 *
44 * The TextView widget looks like this:
45 * @image html textview1.png
46 *
47 * @ingroup Widgets
48 * @ingroup Containers
49 * @ingroup TextView
50 */
51 class GTKMM_API TextView
52 : public Container,
53 public Scrollable
54 {
55 _CLASS_GTKOBJECT(TextView, GtkTextView, GTK_TEXT_VIEW, Gtk::Container, GtkContainer, , , GTKMM_API)
56 _IMPLEMENTS_INTERFACE(Scrollable)
57 public:
58 _CTOR_DEFAULT()
59 explicit TextView(const Glib::RefPtr<TextBuffer>& buffer);
60
61 _WRAP_METHOD(void set_buffer(const Glib::RefPtr<TextBuffer>& buffer), gtk_text_view_set_buffer)
62 _WRAP_METHOD(Glib::RefPtr<TextBuffer> get_buffer(), gtk_text_view_get_buffer, refreturn)
63 _WRAP_METHOD(Glib::RefPtr<const TextBuffer> get_buffer() const, gtk_text_view_get_buffer, refreturn, constversion)
64
65 /** Scrolls the TextView so that @a iter is on the screen, by scrolling the minimal distance to get the mark onscreen,
66 * possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size
67 * @a within_margin.
68 * @note This function uses the currently-computed height of the lines in the text buffer. Note that line heights are computed
69 * in an idle handler; so this function may not have the desired effect if it's called before the height computations. To avoid
70 * oddness, consider using gtk_text_view_scroll_to_mark() which saves a point to be scrolled to after line validation.
71 *
72 * @param iter An iterator pointing to the position that should be made visible by scrolling.
73 * @param within_margin margin as a [0.0,0.5] fraction of screen size.
74 * @result true if scrolling occurred.
75 */
76 bool scroll_to(TextBuffer::iterator& iter, double within_margin = 0);
77
78 /** Scrolls the TextView so that @a iter is on the screen, in the position indicated by xalign and yalign,
79 * possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size
80 * @a within_margin.
81 * @note This function uses the currently-computed height of the lines in the text buffer. Note that line heights are computed
82 * in an idle handler; so this function may not have the desired effect if it's called before the height computations. To avoid
83 * oddness, consider using gtk_text_view_scroll_to_mark() which saves a point to be scrolled to after line validation.
84 *
85 * @param iter An iterator pointing to the position that should be made visible by scrolling.
86 * @param within_margin margin as a [0.0,0.5] fraction of screen size.
87 * @param xalign horizontal alignment of mark within visible area. An alignment of 0.0 indicates left, 1.0 indicates right, 0.5 means center.
88 * @param yalign vertical alignment of mark within visible area. An alignment of 0.0 indicates top, 1.0 indicates bottom, 0.5 means center.
89 * @result true if scrolling occurred.
90 */
91 bool scroll_to(TextBuffer::iterator& iter, double within_margin, double xalign, double yalign);
92 _IGNORE(gtk_text_view_scroll_to_iter)
93
94 /** Scrolls text_view so that @a mark is on the screen, by scrolling the minimal distance to get the mark onscreen,
95 * possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size
96 * @a within_margin.
97 *
98 * @param mark An mark pointing to the position that should be made visible by scrolling.
99 * @param within_margin margin as a [0.0,0.5] fraction of screen size.
100 */
101 void scroll_to(const Glib::RefPtr<TextBuffer::Mark>& mark, double within_margin = 0);
102
103 /** Scrolls the TextView so that @a iter is on the screen, in the position indicated by xalign and yalign,
104 * possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size
105 * @a within_margin.
106 *
107 * @param mark An mark pointing to the position that should be made visible by scrolling.
108 * @param within_margin margin as a [0.0,0.5] fraction of screen size.
109 * @param xalign horizontal alignment of mark within visible area. An alignment of 0.0 indicates left, 1.0 indicates right, 0.5 means center.
110 * @param yalign vertical alignment of mark within visible area. An alignment of 0.0 indicates top, 1.0 indicates bottom, 0.5 means center.
111 */
112 void scroll_to(const Glib::RefPtr<TextBuffer::Mark>& mark, double within_margin, double xalign, double yalign);
113 _IGNORE(gtk_text_view_scroll_to_mark)
114
115 _IGNORE(gtk_text_view_scroll_mark_onscreen) //It does not do anything more than the default scroll_to(mark).
116
117 _WRAP_METHOD(bool move_mark_onscreen(const Glib::RefPtr<TextBuffer::Mark>& mark), gtk_text_view_move_mark_onscreen)
118 _WRAP_METHOD(bool place_cursor_onscreen(), gtk_text_view_place_cursor_onscreen)
119
120 _WRAP_METHOD(void get_visible_rect(Gdk::Rectangle& visible_rect) const, gtk_text_view_get_visible_rect)
121 _WRAP_METHOD(void set_cursor_visible(bool setting = true), gtk_text_view_set_cursor_visible)
122 _WRAP_METHOD(bool get_cursor_visible() const, gtk_text_view_get_cursor_visible)
123 _WRAP_METHOD(void reset_cursor_blink(), gtk_text_view_reset_cursor_blink)
124
125 _WRAP_METHOD(void get_cursor_locations(const TextBuffer::iterator& iter, Gdk::Rectangle& strong, Gdk::Rectangle& weak) const, gtk_text_view_get_cursor_locations)
126
127 _WRAP_METHOD(void get_iter_location(const TextBuffer::iterator& iter, Gdk::Rectangle& location) const, gtk_text_view_get_iter_location)
128 _WRAP_METHOD(void get_iter_at_location(TextBuffer::iterator& iter, int x, int y) const, gtk_text_view_get_iter_at_location)
129 _WRAP_METHOD(void get_iter_at_position(TextBuffer::iterator& iter, int& trailing, int x, int y) const, gtk_text_view_get_iter_at_position)
130 _WRAP_METHOD(void get_line_yrange(const TextBuffer::iterator& iter, int& y, int& height) const, gtk_text_view_get_line_yrange)
131
132 _WRAP_METHOD(void get_line_at_y(TextBuffer::iterator& target_iter, int y, int& line_top) const, gtk_text_view_get_line_at_y)
133
134 _WRAP_METHOD(void buffer_to_window_coords(TextWindowType win,
135 int buffer_x, int buffer_y,
136 int& window_x, int& window_y) const, gtk_text_view_buffer_to_window_coords)
137 _WRAP_METHOD(void window_to_buffer_coords(TextWindowType win,
138 int window_x, int window_y,
139 int& buffer_x, int& buffer_y) const, gtk_text_view_window_to_buffer_coords)
140
141 _IGNORE(gtk_text_view_get_hadjustment, gtk_text_view_get_vadjustment) //deprecated
142
143 _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_window(TextWindowType win), gtk_text_view_get_window, refreturn)
144 _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_window(TextWindowType win) const, gtk_text_view_get_window, refreturn, constversion)
145 _WRAP_METHOD(TextWindowType get_window_type(const Glib::RefPtr<Gdk::Window>& window), gtk_text_view_get_window_type)
146
147 _WRAP_METHOD(void set_border_window_size(TextWindowType type, int size), gtk_text_view_set_border_window_size)
148 _WRAP_METHOD(int get_border_window_size(TextWindowType type) const, gtk_text_view_get_border_window_size)
149
150 _WRAP_METHOD(bool forward_display_line(TextBuffer::iterator& iter), gtk_text_view_forward_display_line)
151 _WRAP_METHOD(bool backward_display_line(TextBuffer::iterator& iter), gtk_text_view_backward_display_line)
152 _WRAP_METHOD(bool forward_display_line_end(TextBuffer::iterator& iter), gtk_text_view_forward_display_line_end)
153 _WRAP_METHOD(bool backward_display_line_start(TextBuffer::iterator& iter), gtk_text_view_backward_display_line_start)
154 _WRAP_METHOD(bool starts_display_line(const TextBuffer::iterator& iter), gtk_text_view_starts_display_line)
155 _WRAP_METHOD(bool move_visually(TextBuffer::iterator& iter, int count), gtk_text_view_move_visually)
156
157 _WRAP_METHOD(bool im_context_filter_keypress(GdkEventKey* gdk_event), gtk_text_view_im_context_filter_keypress)
158 _WRAP_METHOD(void reset_im_context(), gtk_text_view_reset_im_context)
159
160 _WRAP_METHOD(void add_child_at_anchor(Widget& child, const Glib::RefPtr<TextBuffer::ChildAnchor>& anchor), gtk_text_view_add_child_at_anchor)
161
162 _WRAP_METHOD(void add_child_in_window(Widget& child, TextWindowType which_window,
163 int xpos, int ypos), gtk_text_view_add_child_in_window)
164
165 _WRAP_METHOD(void move_child(Widget& child, int xpos,int ypos), gtk_text_view_move_child)
166
167 _WRAP_METHOD(void set_wrap_mode(WrapMode wrap_mode), gtk_text_view_set_wrap_mode)
168 _WRAP_METHOD(WrapMode get_wrap_mode() const, gtk_text_view_get_wrap_mode)
169 _WRAP_METHOD(void set_editable(bool setting = true), gtk_text_view_set_editable)
170 _WRAP_METHOD(bool get_editable() const, gtk_text_view_get_editable)
171 _WRAP_METHOD(void set_pixels_above_lines(int pixels_above_lines), gtk_text_view_set_pixels_above_lines)
172 _WRAP_METHOD(int get_pixels_above_lines() const, gtk_text_view_get_pixels_above_lines)
173 _WRAP_METHOD(void set_pixels_below_lines(int pixels_below_lines), gtk_text_view_set_pixels_below_lines)
174 _WRAP_METHOD(int get_pixels_below_lines() const, gtk_text_view_get_pixels_below_lines)
175 _WRAP_METHOD(void set_pixels_inside_wrap(int pixels_inside_wrap), gtk_text_view_set_pixels_inside_wrap)
176 _WRAP_METHOD(int get_pixels_inside_wrap() const, gtk_text_view_get_pixels_inside_wrap)
177 _WRAP_METHOD(void set_justification(Justification justification), gtk_text_view_set_justification)
178 _WRAP_METHOD(Justification get_justification() const, gtk_text_view_get_justification)
179 _WRAP_METHOD(void set_left_margin(int left_margin), gtk_text_view_set_left_margin)
180 _WRAP_METHOD(int get_left_margin() const, gtk_text_view_get_left_margin)
181 _WRAP_METHOD(void set_right_margin(int right_margin), gtk_text_view_set_right_margin)
182 _WRAP_METHOD(int get_right_margin() const, gtk_text_view_get_right_margin)
183 _WRAP_METHOD(void set_top_margin(int top_margin), gtk_text_view_set_top_margin, newin "3,20")
184 _WRAP_METHOD(int get_top_margin() const, gtk_text_view_get_top_margin, newin "3,20")
185 _WRAP_METHOD(void set_bottom_margin(int bottom_margin), gtk_text_view_set_bottom_margin, newin "3,20")
186 _WRAP_METHOD(int get_bottom_margin() const, gtk_text_view_get_bottom_margin, newin "3,20")
187 _WRAP_METHOD(void set_indent(int indent), gtk_text_view_set_indent)
188 _WRAP_METHOD(int get_indent() const, gtk_text_view_get_indent)
189
190 #m4 _CONVERSION(`PangoTabArray*',`Pango::TabArray',`Pango::TabArray(($3), false)')
191 _WRAP_METHOD(void set_tabs(Pango::TabArray& tabs), gtk_text_view_set_tabs)
192 _WRAP_METHOD(Pango::TabArray get_tabs() const, gtk_text_view_get_tabs)
193 _WRAP_METHOD(TextAttributes get_default_attributes() const, gtk_text_view_get_default_attributes)
194
195 _WRAP_METHOD(void set_overwrite(bool overwrite = true), gtk_text_view_set_overwrite)
196 _WRAP_METHOD(bool get_overwrite() const, gtk_text_view_get_overwrite)
197
198 _WRAP_METHOD(void set_accepts_tab(bool accepts_tab = true), gtk_text_view_set_accepts_tab)
199 _WRAP_METHOD(bool get_accepts_tab() const, gtk_text_view_get_accepts_tab)
200
201 _WRAP_METHOD(void set_input_purpose(InputPurpose purpose), gtk_text_view_set_input_purpose)
202 _WRAP_METHOD(InputPurpose get_input_purpose() const, gtk_text_view_get_input_purpose)
203
204 _WRAP_METHOD(void set_input_hints(InputHints hints), gtk_text_view_set_input_hints)
205 _WRAP_METHOD(InputHints get_input_hints() const, gtk_text_view_get_input_hints)
206
207 _WRAP_METHOD(void set_monospace(bool monospace = true), gtk_text_view_set_monospace)
208 _WRAP_METHOD(bool get_monospace() const, gtk_text_view_get_monospace)
209
210 //TODO: This signal now takes a GtkWidget* instead of just a GtkMenu*,
211 //so change that when we can break ABI.
212 //See https://git.gnome.org/browse/gtk+/commit/?id=88623b98a7ca0afca08ac21bc3aa662c6ed3ab7f
213 #m4 _CONVERSION(`Menu*',`GtkWidget*',`GTK_WIDGET(($3)->gobj())')
214 _WRAP_SIGNAL(void populate_popup(Menu* menu), "populate_popup")
215
216 _WRAP_SIGNAL(void set_anchor(), "set_anchor")
217
218 #m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
219 _WRAP_SIGNAL(void insert_at_cursor(const Glib::ustring& str), "insert_at_cursor")
220
221 //Keybinding signals:
222 _IGNORE_SIGNAL("move_cursor")
223 _IGNORE_SIGNAL("delete_from_cursor")
224 _IGNORE_SIGNAL("cut_clipboard")
225 _IGNORE_SIGNAL("copy_clipboard")
226 _IGNORE_SIGNAL("paste_clipboard")
227 _IGNORE_SIGNAL("toggle_overwrite")
228 _IGNORE_SIGNAL("move_viewport")
229 _IGNORE_SIGNAL("select_all")
230 _IGNORE_SIGNAL("backspace")
231 _IGNORE_SIGNAL("toggle_cursor_visible")
232 _IGNORE_SIGNAL("preedit-changed")
233 _IGNORE_SIGNAL("extend-selection")
234
235 _WRAP_PROPERTY("pixels-above-lines", int)
236 _WRAP_PROPERTY("pixels-below-lines", int)
237 _WRAP_PROPERTY("pixels-inside-wrap", int)
238 _WRAP_PROPERTY("editable", bool)
239 _WRAP_PROPERTY("wrap-mode", WrapMode)
240 _WRAP_PROPERTY("justification", Justification)
241 _WRAP_PROPERTY("left-margin", int)
242 _WRAP_PROPERTY("right-margin", int)
243 _WRAP_PROPERTY("top-margin", int, newin "2,30")
244 _WRAP_PROPERTY("bottom-margin", int, newin "2,30")
245 _WRAP_PROPERTY("indent", int)
246 _WRAP_PROPERTY("tabs", Pango::TabArray)
247 _WRAP_PROPERTY("cursor-visible", bool)
248 _WRAP_PROPERTY("buffer", Glib::RefPtr<TextBuffer>)
249 _WRAP_PROPERTY("overwrite", bool)
250 _WRAP_PROPERTY("accepts-tab", bool)
251 _WRAP_PROPERTY("im-module", Glib::ustring)
252 _WRAP_PROPERTY("input-purpose", InputPurpose)
253 _WRAP_PROPERTY("input-hints", InputHints)
254 _WRAP_PROPERTY("populate-all", bool)
255 _WRAP_PROPERTY("monospace", bool)
256 };
257
258 } //namespace Gtk