25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

218 lines
6.9 KiB

  1. /* GTK - The GIMP Toolkit
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  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. #ifdef GTK_ENABLE_BROKEN
  26. #ifndef __GTK_TEXT_H__
  27. #define __GTK_TEXT_H__
  28. #include <gtk/gtkoldeditable.h>
  29. G_BEGIN_DECLS
  30. #define GTK_TYPE_TEXT (gtk_text_get_type ())
  31. #define GTK_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT, GtkText))
  32. #define GTK_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT, GtkTextClass))
  33. #define GTK_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT))
  34. #define GTK_IS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT))
  35. #define GTK_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT, GtkTextClass))
  36. typedef struct _GtkTextFont GtkTextFont;
  37. typedef struct _GtkPropertyMark GtkPropertyMark;
  38. typedef struct _GtkText GtkText;
  39. typedef struct _GtkTextClass GtkTextClass;
  40. struct _GtkPropertyMark
  41. {
  42. /* Position in list. */
  43. GList* property;
  44. /* Offset into that property. */
  45. guint offset;
  46. /* Current index. */
  47. guint index;
  48. };
  49. struct _GtkText
  50. {
  51. GtkOldEditable old_editable;
  52. GdkWindow *text_area;
  53. GtkAdjustment *hadj;
  54. GtkAdjustment *vadj;
  55. GdkGC *gc;
  56. GdkPixmap* line_wrap_bitmap;
  57. GdkPixmap* line_arrow_bitmap;
  58. /* GAPPED TEXT SEGMENT */
  59. /* The text, a single segment of text a'la emacs, with a gap
  60. * where insertion occurs. */
  61. union { GdkWChar *wc; guchar *ch; } text;
  62. /* The allocated length of the text segment. */
  63. guint text_len;
  64. /* The gap position, index into address where a char
  65. * should be inserted. */
  66. guint gap_position;
  67. /* The gap size, s.t. *(text + gap_position + gap_size) is
  68. * the first valid character following the gap. */
  69. guint gap_size;
  70. /* The last character position, index into address where a
  71. * character should be appeneded. Thus, text_end - gap_size
  72. * is the length of the actual data. */
  73. guint text_end;
  74. /* LINE START CACHE */
  75. /* A cache of line-start information. Data is a LineParam*. */
  76. GList *line_start_cache;
  77. /* Index to the start of the first visible line. */
  78. guint first_line_start_index;
  79. /* The number of pixels cut off of the top line. */
  80. guint first_cut_pixels;
  81. /* First visible horizontal pixel. */
  82. guint first_onscreen_hor_pixel;
  83. /* First visible vertical pixel. */
  84. guint first_onscreen_ver_pixel;
  85. /* FLAGS */
  86. /* True iff this buffer is wrapping lines, otherwise it is using a
  87. * horizontal scrollbar. */
  88. guint line_wrap : 1;
  89. guint word_wrap : 1;
  90. /* If a fontset is supplied for the widget, use_wchar become true,
  91. * and we use GdkWchar as the encoding of text. */
  92. guint use_wchar : 1;
  93. /* Frozen, don't do updates. @@@ fixme */
  94. guint freeze_count;
  95. /* TEXT PROPERTIES */
  96. /* A doubly-linked-list containing TextProperty objects. */
  97. GList *text_properties;
  98. /* The end of this list. */
  99. GList *text_properties_end;
  100. /* The first node before or on the point along with its offset to
  101. * the point and the buffer's current point. This is the only
  102. * PropertyMark whose index is guaranteed to remain correct
  103. * following a buffer insertion or deletion. */
  104. GtkPropertyMark point;
  105. /* SCRATCH AREA */
  106. union { GdkWChar *wc; guchar *ch; } scratch_buffer;
  107. guint scratch_buffer_len;
  108. /* SCROLLING */
  109. gint last_ver_value;
  110. /* CURSOR */
  111. gint cursor_pos_x; /* Position of cursor. */
  112. gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
  113. GtkPropertyMark cursor_mark; /* Where it is in the buffer. */
  114. GdkWChar cursor_char; /* Character to redraw. */
  115. gchar cursor_char_offset; /* Distance from baseline of the font. */
  116. gint cursor_virtual_x; /* Where it would be if it could be. */
  117. gint cursor_drawn_level; /* How many people have undrawn. */
  118. /* Current Line */
  119. GList *current_line;
  120. /* Tab Stops */
  121. GList *tab_stops;
  122. gint default_tab_width;
  123. GtkTextFont *current_font; /* Text font for current style */
  124. /* Timer used for auto-scrolling off ends */
  125. gint timer;
  126. guint button; /* currently pressed mouse button */
  127. GdkGC *bg_gc; /* gc for drawing background pixmap */
  128. };
  129. struct _GtkTextClass
  130. {
  131. GtkOldEditableClass parent_class;
  132. void (*set_scroll_adjustments) (GtkText *text,
  133. GtkAdjustment *hadjustment,
  134. GtkAdjustment *vadjustment);
  135. };
  136. GType gtk_text_get_type (void) G_GNUC_CONST;
  137. GtkWidget* gtk_text_new (GtkAdjustment *hadj,
  138. GtkAdjustment *vadj);
  139. void gtk_text_set_editable (GtkText *text,
  140. gboolean editable);
  141. void gtk_text_set_word_wrap (GtkText *text,
  142. gboolean word_wrap);
  143. void gtk_text_set_line_wrap (GtkText *text,
  144. gboolean line_wrap);
  145. void gtk_text_set_adjustments (GtkText *text,
  146. GtkAdjustment *hadj,
  147. GtkAdjustment *vadj);
  148. void gtk_text_set_point (GtkText *text,
  149. guint index);
  150. guint gtk_text_get_point (GtkText *text);
  151. guint gtk_text_get_length (GtkText *text);
  152. void gtk_text_freeze (GtkText *text);
  153. void gtk_text_thaw (GtkText *text);
  154. void gtk_text_insert (GtkText *text,
  155. GdkFont *font,
  156. const GdkColor *fore,
  157. const GdkColor *back,
  158. const char *chars,
  159. gint length);
  160. gboolean gtk_text_backward_delete (GtkText *text,
  161. guint nchars);
  162. gboolean gtk_text_forward_delete (GtkText *text,
  163. guint nchars);
  164. #define GTK_TEXT_INDEX(t, index) (((t)->use_wchar) \
  165. ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
  166. (t)->text.wc[(index)+(t)->gap_size]) \
  167. : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
  168. (t)->text.ch[(index)+(t)->gap_size]))
  169. G_END_DECLS
  170. #endif /* __GTK_TEXT_H__ */
  171. #endif /* GTK_ENABLE_BROKEN */