You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

377 rivejä
18 KiB

  1. /* GTK - The GIMP Toolkit
  2. * gtktextview.h Copyright (C) 2000 Red Hat, Inc.
  3. *
  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.
  8. *
  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.
  13. *
  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.
  18. */
  19. /*
  20. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GTK+ Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  26. #error "Only <gtk/gtk.h> can be included directly."
  27. #endif
  28. #ifndef __GTK_TEXT_VIEW_H__
  29. #define __GTK_TEXT_VIEW_H__
  30. #include <gtk/gtkcontainer.h>
  31. #include <gtk/gtkimcontext.h>
  32. #include <gtk/gtktextbuffer.h>
  33. #include <gtk/gtkmenu.h>
  34. G_BEGIN_DECLS
  35. #define GTK_TYPE_TEXT_VIEW (gtk_text_view_get_type ())
  36. #define GTK_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_VIEW, GtkTextView))
  37. #define GTK_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
  38. #define GTK_IS_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_VIEW))
  39. #define GTK_IS_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_VIEW))
  40. #define GTK_TEXT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
  41. typedef enum
  42. {
  43. GTK_TEXT_WINDOW_PRIVATE,
  44. GTK_TEXT_WINDOW_WIDGET,
  45. GTK_TEXT_WINDOW_TEXT,
  46. GTK_TEXT_WINDOW_LEFT,
  47. GTK_TEXT_WINDOW_RIGHT,
  48. GTK_TEXT_WINDOW_TOP,
  49. GTK_TEXT_WINDOW_BOTTOM
  50. } GtkTextWindowType;
  51. #define GTK_TEXT_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
  52. typedef struct _GtkTextView GtkTextView;
  53. typedef struct _GtkTextViewClass GtkTextViewClass;
  54. /* Internal private types. */
  55. typedef struct _GtkTextWindow GtkTextWindow;
  56. typedef struct _GtkTextPendingScroll GtkTextPendingScroll;
  57. struct _GtkTextView
  58. {
  59. GtkContainer parent_instance;
  60. struct _GtkTextLayout *GSEAL (layout);
  61. GtkTextBuffer *GSEAL (buffer);
  62. guint GSEAL (selection_drag_handler);
  63. guint GSEAL (scroll_timeout);
  64. /* Default style settings */
  65. gint GSEAL (pixels_above_lines);
  66. gint GSEAL (pixels_below_lines);
  67. gint GSEAL (pixels_inside_wrap);
  68. GtkWrapMode GSEAL (wrap_mode);
  69. GtkJustification GSEAL (justify);
  70. gint GSEAL (left_margin);
  71. gint GSEAL (right_margin);
  72. gint GSEAL (indent);
  73. PangoTabArray *GSEAL (tabs);
  74. guint GSEAL (editable) : 1;
  75. guint GSEAL (overwrite_mode) : 1;
  76. guint GSEAL (cursor_visible) : 1;
  77. /* if we have reset the IM since the last character entered */
  78. guint GSEAL (need_im_reset) : 1;
  79. guint GSEAL (accepts_tab) : 1;
  80. guint GSEAL (width_changed) : 1;
  81. /* debug flag - means that we've validated onscreen since the
  82. * last "invalidate" signal from the layout
  83. */
  84. guint GSEAL (onscreen_validated) : 1;
  85. guint GSEAL (mouse_cursor_obscured) : 1;
  86. GtkTextWindow *GSEAL (text_window);
  87. GtkTextWindow *GSEAL (left_window);
  88. GtkTextWindow *GSEAL (right_window);
  89. GtkTextWindow *GSEAL (top_window);
  90. GtkTextWindow *GSEAL (bottom_window);
  91. GtkAdjustment *GSEAL (hadjustment);
  92. GtkAdjustment *GSEAL (vadjustment);
  93. gint GSEAL (xoffset); /* Offsets between widget coordinates and buffer coordinates */
  94. gint GSEAL (yoffset);
  95. gint GSEAL (width); /* Width and height of the buffer */
  96. gint GSEAL (height);
  97. /* The virtual cursor position is normally the same as the
  98. * actual (strong) cursor position, except in two circumstances:
  99. *
  100. * a) When the cursor is moved vertically with the keyboard
  101. * b) When the text view is scrolled with the keyboard
  102. *
  103. * In case a), virtual_cursor_x is preserved, but not virtual_cursor_y
  104. * In case b), both virtual_cursor_x and virtual_cursor_y are preserved.
  105. */
  106. gint GSEAL (virtual_cursor_x); /* -1 means use actual cursor position */
  107. gint GSEAL (virtual_cursor_y); /* -1 means use actual cursor position */
  108. GtkTextMark *GSEAL (first_para_mark); /* Mark at the beginning of the first onscreen paragraph */
  109. gint GSEAL (first_para_pixels); /* Offset of top of screen in the first onscreen paragraph */
  110. GtkTextMark *GSEAL (dnd_mark);
  111. guint GSEAL (blink_timeout);
  112. guint GSEAL (first_validate_idle); /* Idle to revalidate onscreen portion, runs before resize */
  113. guint GSEAL (incremental_validate_idle); /* Idle to revalidate offscreen portions, runs after redraw */
  114. GtkIMContext *GSEAL (im_context);
  115. GtkWidget *GSEAL (popup_menu);
  116. gint GSEAL (drag_start_x);
  117. gint GSEAL (drag_start_y);
  118. GSList *GSEAL (children);
  119. GtkTextPendingScroll *GSEAL (pending_scroll);
  120. gint GSEAL (pending_place_cursor_button);
  121. };
  122. struct _GtkTextViewClass
  123. {
  124. GtkContainerClass parent_class;
  125. void (* set_scroll_adjustments) (GtkTextView *text_view,
  126. GtkAdjustment *hadjustment,
  127. GtkAdjustment *vadjustment);
  128. void (* populate_popup) (GtkTextView *text_view,
  129. GtkMenu *menu);
  130. /* These are all RUN_ACTION signals for keybindings */
  131. /* move insertion point */
  132. void (* move_cursor) (GtkTextView *text_view,
  133. GtkMovementStep step,
  134. gint count,
  135. gboolean extend_selection);
  136. /* FIXME should be deprecated in favor of adding GTK_MOVEMENT_HORIZONTAL_PAGES
  137. * or something in GTK 2.2, was put in to avoid adding enum values during
  138. * the freeze.
  139. */
  140. void (* page_horizontally) (GtkTextView *text_view,
  141. gint count,
  142. gboolean extend_selection);
  143. /* move the "anchor" (what Emacs calls the mark) to the cursor position */
  144. void (* set_anchor) (GtkTextView *text_view);
  145. /* Edits */
  146. void (* insert_at_cursor) (GtkTextView *text_view,
  147. const gchar *str);
  148. void (* delete_from_cursor) (GtkTextView *text_view,
  149. GtkDeleteType type,
  150. gint count);
  151. void (* backspace) (GtkTextView *text_view);
  152. /* cut copy paste */
  153. void (* cut_clipboard) (GtkTextView *text_view);
  154. void (* copy_clipboard) (GtkTextView *text_view);
  155. void (* paste_clipboard) (GtkTextView *text_view);
  156. /* overwrite */
  157. void (* toggle_overwrite) (GtkTextView *text_view);
  158. /* as of GTK+ 2.12 the "move-focus" signal has been moved to GtkWidget,
  159. * so this is merley a virtual function now. Overriding it in subclasses
  160. * continues to work though.
  161. */
  162. void (* move_focus) (GtkTextView *text_view,
  163. GtkDirectionType direction);
  164. /* Padding for future expansion */
  165. void (*_gtk_reserved1) (void);
  166. void (*_gtk_reserved2) (void);
  167. void (*_gtk_reserved3) (void);
  168. void (*_gtk_reserved4) (void);
  169. void (*_gtk_reserved5) (void);
  170. void (*_gtk_reserved6) (void);
  171. void (*_gtk_reserved7) (void);
  172. };
  173. GType gtk_text_view_get_type (void) G_GNUC_CONST;
  174. GtkWidget * gtk_text_view_new (void);
  175. GtkWidget * gtk_text_view_new_with_buffer (GtkTextBuffer *buffer);
  176. void gtk_text_view_set_buffer (GtkTextView *text_view,
  177. GtkTextBuffer *buffer);
  178. GtkTextBuffer *gtk_text_view_get_buffer (GtkTextView *text_view);
  179. gboolean gtk_text_view_scroll_to_iter (GtkTextView *text_view,
  180. GtkTextIter *iter,
  181. gdouble within_margin,
  182. gboolean use_align,
  183. gdouble xalign,
  184. gdouble yalign);
  185. void gtk_text_view_scroll_to_mark (GtkTextView *text_view,
  186. GtkTextMark *mark,
  187. gdouble within_margin,
  188. gboolean use_align,
  189. gdouble xalign,
  190. gdouble yalign);
  191. void gtk_text_view_scroll_mark_onscreen (GtkTextView *text_view,
  192. GtkTextMark *mark);
  193. gboolean gtk_text_view_move_mark_onscreen (GtkTextView *text_view,
  194. GtkTextMark *mark);
  195. gboolean gtk_text_view_place_cursor_onscreen (GtkTextView *text_view);
  196. void gtk_text_view_get_visible_rect (GtkTextView *text_view,
  197. GdkRectangle *visible_rect);
  198. void gtk_text_view_set_cursor_visible (GtkTextView *text_view,
  199. gboolean setting);
  200. gboolean gtk_text_view_get_cursor_visible (GtkTextView *text_view);
  201. void gtk_text_view_get_iter_location (GtkTextView *text_view,
  202. const GtkTextIter *iter,
  203. GdkRectangle *location);
  204. void gtk_text_view_get_iter_at_location (GtkTextView *text_view,
  205. GtkTextIter *iter,
  206. gint x,
  207. gint y);
  208. void gtk_text_view_get_iter_at_position (GtkTextView *text_view,
  209. GtkTextIter *iter,
  210. gint *trailing,
  211. gint x,
  212. gint y);
  213. void gtk_text_view_get_line_yrange (GtkTextView *text_view,
  214. const GtkTextIter *iter,
  215. gint *y,
  216. gint *height);
  217. void gtk_text_view_get_line_at_y (GtkTextView *text_view,
  218. GtkTextIter *target_iter,
  219. gint y,
  220. gint *line_top);
  221. void gtk_text_view_buffer_to_window_coords (GtkTextView *text_view,
  222. GtkTextWindowType win,
  223. gint buffer_x,
  224. gint buffer_y,
  225. gint *window_x,
  226. gint *window_y);
  227. void gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
  228. GtkTextWindowType win,
  229. gint window_x,
  230. gint window_y,
  231. gint *buffer_x,
  232. gint *buffer_y);
  233. GtkAdjustment* gtk_text_view_get_hadjustment (GtkTextView *text_view);
  234. GtkAdjustment* gtk_text_view_get_vadjustment (GtkTextView *text_view);
  235. GdkWindow* gtk_text_view_get_window (GtkTextView *text_view,
  236. GtkTextWindowType win);
  237. GtkTextWindowType gtk_text_view_get_window_type (GtkTextView *text_view,
  238. GdkWindow *window);
  239. void gtk_text_view_set_border_window_size (GtkTextView *text_view,
  240. GtkTextWindowType type,
  241. gint size);
  242. gint gtk_text_view_get_border_window_size (GtkTextView *text_view,
  243. GtkTextWindowType type);
  244. gboolean gtk_text_view_forward_display_line (GtkTextView *text_view,
  245. GtkTextIter *iter);
  246. gboolean gtk_text_view_backward_display_line (GtkTextView *text_view,
  247. GtkTextIter *iter);
  248. gboolean gtk_text_view_forward_display_line_end (GtkTextView *text_view,
  249. GtkTextIter *iter);
  250. gboolean gtk_text_view_backward_display_line_start (GtkTextView *text_view,
  251. GtkTextIter *iter);
  252. gboolean gtk_text_view_starts_display_line (GtkTextView *text_view,
  253. const GtkTextIter *iter);
  254. gboolean gtk_text_view_move_visually (GtkTextView *text_view,
  255. GtkTextIter *iter,
  256. gint count);
  257. gboolean gtk_text_view_im_context_filter_keypress (GtkTextView *text_view,
  258. GdkEventKey *event);
  259. void gtk_text_view_reset_im_context (GtkTextView *text_view);
  260. /* Adding child widgets */
  261. void gtk_text_view_add_child_at_anchor (GtkTextView *text_view,
  262. GtkWidget *child,
  263. GtkTextChildAnchor *anchor);
  264. void gtk_text_view_add_child_in_window (GtkTextView *text_view,
  265. GtkWidget *child,
  266. GtkTextWindowType which_window,
  267. /* window coordinates */
  268. gint xpos,
  269. gint ypos);
  270. void gtk_text_view_move_child (GtkTextView *text_view,
  271. GtkWidget *child,
  272. /* window coordinates */
  273. gint xpos,
  274. gint ypos);
  275. /* Default style settings (fallbacks if no tag affects the property) */
  276. void gtk_text_view_set_wrap_mode (GtkTextView *text_view,
  277. GtkWrapMode wrap_mode);
  278. GtkWrapMode gtk_text_view_get_wrap_mode (GtkTextView *text_view);
  279. void gtk_text_view_set_editable (GtkTextView *text_view,
  280. gboolean setting);
  281. gboolean gtk_text_view_get_editable (GtkTextView *text_view);
  282. void gtk_text_view_set_overwrite (GtkTextView *text_view,
  283. gboolean overwrite);
  284. gboolean gtk_text_view_get_overwrite (GtkTextView *text_view);
  285. void gtk_text_view_set_accepts_tab (GtkTextView *text_view,
  286. gboolean accepts_tab);
  287. gboolean gtk_text_view_get_accepts_tab (GtkTextView *text_view);
  288. void gtk_text_view_set_pixels_above_lines (GtkTextView *text_view,
  289. gint pixels_above_lines);
  290. gint gtk_text_view_get_pixels_above_lines (GtkTextView *text_view);
  291. void gtk_text_view_set_pixels_below_lines (GtkTextView *text_view,
  292. gint pixels_below_lines);
  293. gint gtk_text_view_get_pixels_below_lines (GtkTextView *text_view);
  294. void gtk_text_view_set_pixels_inside_wrap (GtkTextView *text_view,
  295. gint pixels_inside_wrap);
  296. gint gtk_text_view_get_pixels_inside_wrap (GtkTextView *text_view);
  297. void gtk_text_view_set_justification (GtkTextView *text_view,
  298. GtkJustification justification);
  299. GtkJustification gtk_text_view_get_justification (GtkTextView *text_view);
  300. void gtk_text_view_set_left_margin (GtkTextView *text_view,
  301. gint left_margin);
  302. gint gtk_text_view_get_left_margin (GtkTextView *text_view);
  303. void gtk_text_view_set_right_margin (GtkTextView *text_view,
  304. gint right_margin);
  305. gint gtk_text_view_get_right_margin (GtkTextView *text_view);
  306. void gtk_text_view_set_indent (GtkTextView *text_view,
  307. gint indent);
  308. gint gtk_text_view_get_indent (GtkTextView *text_view);
  309. void gtk_text_view_set_tabs (GtkTextView *text_view,
  310. PangoTabArray *tabs);
  311. PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view);
  312. /* note that the return value of this changes with the theme */
  313. GtkTextAttributes* gtk_text_view_get_default_attributes (GtkTextView *text_view);
  314. G_END_DECLS
  315. #endif /* __GTK_TEXT_VIEW_H__ */