1 /* GTK - The GIMP Toolkit
2 * gtktextview.h Copyright (C) 2000 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
31 #ifndef __GTK_TEXT_VIEW_H__
32 #define __GTK_TEXT_VIEW_H__
34 #include <gtk/gtkcontainer.h>
35 #include <gtk/gtkimcontext.h>
36 #include <gtk/gtktextbuffer.h>
37 #include <gtk/gtkmenu.h>
41 #define GTK_TYPE_TEXT_VIEW (gtk_text_view_get_type ())
42 #define GTK_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_VIEW, GtkTextView))
43 #define GTK_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
44 #define GTK_IS_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_VIEW))
45 #define GTK_IS_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_VIEW))
46 #define GTK_TEXT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
50 GTK_TEXT_WINDOW_PRIVATE,
51 GTK_TEXT_WINDOW_WIDGET,
54 GTK_TEXT_WINDOW_RIGHT,
56 GTK_TEXT_WINDOW_BOTTOM
59 #define GTK_TEXT_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
61 typedef struct _GtkTextView GtkTextView;
62 typedef struct _GtkTextViewClass GtkTextViewClass;
64 /* Internal private types. */
65 typedef struct _GtkTextWindow GtkTextWindow;
66 typedef struct _GtkTextPendingScroll GtkTextPendingScroll;
70 GtkContainer parent_instance;
72 struct _GtkTextLayout *GSEAL (layout);
73 GtkTextBuffer *GSEAL (buffer);
75 guint GSEAL (selection_drag_handler);
76 guint GSEAL (scroll_timeout);
78 /* Default style settings */
79 gint GSEAL (pixels_above_lines);
80 gint GSEAL (pixels_below_lines);
81 gint GSEAL (pixels_inside_wrap);
82 GtkWrapMode GSEAL (wrap_mode);
83 GtkJustification GSEAL (justify);
84 gint GSEAL (left_margin);
85 gint GSEAL (right_margin);
87 PangoTabArray *GSEAL (tabs);
88 guint GSEAL (editable) : 1;
90 guint GSEAL (overwrite_mode) : 1;
91 guint GSEAL (cursor_visible) : 1;
93 /* if we have reset the IM since the last character entered */
94 guint GSEAL (need_im_reset) : 1;
96 guint GSEAL (accepts_tab) : 1;
98 guint GSEAL (width_changed) : 1;
100 /* debug flag - means that we've validated onscreen since the
101 * last "invalidate" signal from the layout
103 guint GSEAL (onscreen_validated) : 1;
105 guint GSEAL (mouse_cursor_obscured) : 1;
107 GtkTextWindow *GSEAL (text_window);
108 GtkTextWindow *GSEAL (left_window);
109 GtkTextWindow *GSEAL (right_window);
110 GtkTextWindow *GSEAL (top_window);
111 GtkTextWindow *GSEAL (bottom_window);
113 GtkAdjustment *GSEAL (hadjustment);
114 GtkAdjustment *GSEAL (vadjustment);
116 gint GSEAL (xoffset); /* Offsets between widget coordinates and buffer coordinates */
117 gint GSEAL (yoffset);
118 gint GSEAL (width); /* Width and height of the buffer */
121 /* The virtual cursor position is normally the same as the
122 * actual (strong) cursor position, except in two circumstances:
124 * a) When the cursor is moved vertically with the keyboard
125 * b) When the text view is scrolled with the keyboard
127 * In case a), virtual_cursor_x is preserved, but not virtual_cursor_y
128 * In case b), both virtual_cursor_x and virtual_cursor_y are preserved.
130 gint GSEAL (virtual_cursor_x); /* -1 means use actual cursor position */
131 gint GSEAL (virtual_cursor_y); /* -1 means use actual cursor position */
133 GtkTextMark *GSEAL (first_para_mark); /* Mark at the beginning of the first onscreen paragraph */
134 gint GSEAL (first_para_pixels); /* Offset of top of screen in the first onscreen paragraph */
136 GtkTextMark *GSEAL (dnd_mark);
137 guint GSEAL (blink_timeout);
139 guint GSEAL (first_validate_idle); /* Idle to revalidate onscreen portion, runs before resize */
140 guint GSEAL (incremental_validate_idle); /* Idle to revalidate offscreen portions, runs after redraw */
142 GtkIMContext *GSEAL (im_context);
143 GtkWidget *GSEAL (popup_menu);
145 gint GSEAL (drag_start_x);
146 gint GSEAL (drag_start_y);
148 GSList *GSEAL (children);
150 GtkTextPendingScroll *GSEAL (pending_scroll);
152 gint GSEAL (pending_place_cursor_button);
155 struct _GtkTextViewClass
157 GtkContainerClass parent_class;
159 void (* set_scroll_adjustments) (GtkTextView *text_view,
160 GtkAdjustment *hadjustment,
161 GtkAdjustment *vadjustment);
163 void (* populate_popup) (GtkTextView *text_view,
166 /* These are all RUN_ACTION signals for keybindings */
168 /* move insertion point */
169 void (* move_cursor) (GtkTextView *text_view,
170 GtkMovementStep step,
172 gboolean extend_selection);
174 /* FIXME should be deprecated in favor of adding GTK_MOVEMENT_HORIZONTAL_PAGES
175 * or something in GTK 2.2, was put in to avoid adding enum values during
178 void (* page_horizontally) (GtkTextView *text_view,
180 gboolean extend_selection);
182 /* move the "anchor" (what Emacs calls the mark) to the cursor position */
183 void (* set_anchor) (GtkTextView *text_view);
186 void (* insert_at_cursor) (GtkTextView *text_view,
188 void (* delete_from_cursor) (GtkTextView *text_view,
191 void (* backspace) (GtkTextView *text_view);
194 void (* cut_clipboard) (GtkTextView *text_view);
195 void (* copy_clipboard) (GtkTextView *text_view);
196 void (* paste_clipboard) (GtkTextView *text_view);
198 void (* toggle_overwrite) (GtkTextView *text_view);
200 /* as of GTK+ 2.12 the "move-focus" signal has been moved to GtkWidget,
201 * so this is merley a virtual function now. Overriding it in subclasses
202 * continues to work though.
204 void (* move_focus) (GtkTextView *text_view,
205 GtkDirectionType direction);
207 /* Padding for future expansion */
208 void (*_gtk_reserved1) (void);
209 void (*_gtk_reserved2) (void);
210 void (*_gtk_reserved3) (void);
211 void (*_gtk_reserved4) (void);
212 void (*_gtk_reserved5) (void);
213 void (*_gtk_reserved6) (void);
214 void (*_gtk_reserved7) (void);
217 GType gtk_text_view_get_type (void) G_GNUC_CONST;
218 GtkWidget * gtk_text_view_new (void);
219 GtkWidget * gtk_text_view_new_with_buffer (GtkTextBuffer *buffer);
220 void gtk_text_view_set_buffer (GtkTextView *text_view,
221 GtkTextBuffer *buffer);
222 GtkTextBuffer *gtk_text_view_get_buffer (GtkTextView *text_view);
223 gboolean gtk_text_view_scroll_to_iter (GtkTextView *text_view,
225 gdouble within_margin,
229 void gtk_text_view_scroll_to_mark (GtkTextView *text_view,
231 gdouble within_margin,
235 void gtk_text_view_scroll_mark_onscreen (GtkTextView *text_view,
237 gboolean gtk_text_view_move_mark_onscreen (GtkTextView *text_view,
239 gboolean gtk_text_view_place_cursor_onscreen (GtkTextView *text_view);
241 void gtk_text_view_get_visible_rect (GtkTextView *text_view,
242 GdkRectangle *visible_rect);
243 void gtk_text_view_set_cursor_visible (GtkTextView *text_view,
245 gboolean gtk_text_view_get_cursor_visible (GtkTextView *text_view);
247 void gtk_text_view_get_iter_location (GtkTextView *text_view,
248 const GtkTextIter *iter,
249 GdkRectangle *location);
250 void gtk_text_view_get_iter_at_location (GtkTextView *text_view,
254 void gtk_text_view_get_iter_at_position (GtkTextView *text_view,
259 void gtk_text_view_get_line_yrange (GtkTextView *text_view,
260 const GtkTextIter *iter,
264 void gtk_text_view_get_line_at_y (GtkTextView *text_view,
265 GtkTextIter *target_iter,
269 void gtk_text_view_buffer_to_window_coords (GtkTextView *text_view,
270 GtkTextWindowType win,
275 void gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
276 GtkTextWindowType win,
282 GdkWindow* gtk_text_view_get_window (GtkTextView *text_view,
283 GtkTextWindowType win);
284 GtkTextWindowType gtk_text_view_get_window_type (GtkTextView *text_view,
287 void gtk_text_view_set_border_window_size (GtkTextView *text_view,
288 GtkTextWindowType type,
290 gint gtk_text_view_get_border_window_size (GtkTextView *text_view,
291 GtkTextWindowType type);
293 gboolean gtk_text_view_forward_display_line (GtkTextView *text_view,
295 gboolean gtk_text_view_backward_display_line (GtkTextView *text_view,
297 gboolean gtk_text_view_forward_display_line_end (GtkTextView *text_view,
299 gboolean gtk_text_view_backward_display_line_start (GtkTextView *text_view,
301 gboolean gtk_text_view_starts_display_line (GtkTextView *text_view,
302 const GtkTextIter *iter);
303 gboolean gtk_text_view_move_visually (GtkTextView *text_view,
307 /* Adding child widgets */
308 void gtk_text_view_add_child_at_anchor (GtkTextView *text_view,
310 GtkTextChildAnchor *anchor);
312 void gtk_text_view_add_child_in_window (GtkTextView *text_view,
314 GtkTextWindowType which_window,
315 /* window coordinates */
319 void gtk_text_view_move_child (GtkTextView *text_view,
321 /* window coordinates */
325 /* Default style settings (fallbacks if no tag affects the property) */
327 void gtk_text_view_set_wrap_mode (GtkTextView *text_view,
328 GtkWrapMode wrap_mode);
329 GtkWrapMode gtk_text_view_get_wrap_mode (GtkTextView *text_view);
330 void gtk_text_view_set_editable (GtkTextView *text_view,
332 gboolean gtk_text_view_get_editable (GtkTextView *text_view);
333 void gtk_text_view_set_overwrite (GtkTextView *text_view,
335 gboolean gtk_text_view_get_overwrite (GtkTextView *text_view);
336 void gtk_text_view_set_accepts_tab (GtkTextView *text_view,
337 gboolean accepts_tab);
338 gboolean gtk_text_view_get_accepts_tab (GtkTextView *text_view);
339 void gtk_text_view_set_pixels_above_lines (GtkTextView *text_view,
340 gint pixels_above_lines);
341 gint gtk_text_view_get_pixels_above_lines (GtkTextView *text_view);
342 void gtk_text_view_set_pixels_below_lines (GtkTextView *text_view,
343 gint pixels_below_lines);
344 gint gtk_text_view_get_pixels_below_lines (GtkTextView *text_view);
345 void gtk_text_view_set_pixels_inside_wrap (GtkTextView *text_view,
346 gint pixels_inside_wrap);
347 gint gtk_text_view_get_pixels_inside_wrap (GtkTextView *text_view);
348 void gtk_text_view_set_justification (GtkTextView *text_view,
349 GtkJustification justification);
350 GtkJustification gtk_text_view_get_justification (GtkTextView *text_view);
351 void gtk_text_view_set_left_margin (GtkTextView *text_view,
353 gint gtk_text_view_get_left_margin (GtkTextView *text_view);
354 void gtk_text_view_set_right_margin (GtkTextView *text_view,
356 gint gtk_text_view_get_right_margin (GtkTextView *text_view);
357 void gtk_text_view_set_indent (GtkTextView *text_view,
359 gint gtk_text_view_get_indent (GtkTextView *text_view);
360 void gtk_text_view_set_tabs (GtkTextView *text_view,
361 PangoTabArray *tabs);
362 PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view);
364 /* note that the return value of this changes with the theme */
365 GtkTextAttributes* gtk_text_view_get_default_attributes (GtkTextView *text_view);
369 #endif /* __GTK_TEXT_VIEW_H__ */