1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 #ifdef GTK_ENABLE_BROKEN
29 #ifndef __GTK_TEXT_H__
30 #define __GTK_TEXT_H__
34 #include <gtk/gtkadjustment.h>
35 #include <gtk/gtkoldeditable.h>
39 #define GTK_TYPE_TEXT (gtk_text_get_type ())
40 #define GTK_TEXT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT, GtkText))
41 #define GTK_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT, GtkTextClass))
42 #define GTK_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT))
43 #define GTK_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT))
44 #define GTK_TEXT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT, GtkTextClass))
47 typedef struct _GtkTextFont GtkTextFont;
48 typedef struct _GtkPropertyMark GtkPropertyMark;
49 typedef struct _GtkText GtkText;
50 typedef struct _GtkTextClass GtkTextClass;
52 struct _GtkPropertyMark
54 /* Position in list. */
57 /* Offset into that property. */
66 GtkOldEditable old_editable;
75 GdkPixmap* line_wrap_bitmap;
76 GdkPixmap* line_arrow_bitmap;
78 /* GAPPED TEXT SEGMENT */
80 /* The text, a single segment of text a'la emacs, with a gap
81 * where insertion occurs. */
82 union { GdkWChar *wc; guchar *ch; } text;
83 /* The allocated length of the text segment. */
85 /* The gap position, index into address where a char
86 * should be inserted. */
88 /* The gap size, s.t. *(text + gap_position + gap_size) is
89 * the first valid character following the gap. */
91 /* The last character position, index into address where a
92 * character should be appeneded. Thus, text_end - gap_size
93 * is the length of the actual data. */
95 /* LINE START CACHE */
97 /* A cache of line-start information. Data is a LineParam*. */
98 GList *line_start_cache;
99 /* Index to the start of the first visible line. */
100 guint first_line_start_index;
101 /* The number of pixels cut off of the top line. */
102 guint first_cut_pixels;
103 /* First visible horizontal pixel. */
104 guint first_onscreen_hor_pixel;
105 /* First visible vertical pixel. */
106 guint first_onscreen_ver_pixel;
110 /* True iff this buffer is wrapping lines, otherwise it is using a
111 * horizontal scrollbar. */
114 /* If a fontset is supplied for the widget, use_wchar become true,
115 * and we use GdkWchar as the encoding of text. */
118 /* Frozen, don't do updates. @@@ fixme */
120 /* TEXT PROPERTIES */
122 /* A doubly-linked-list containing TextProperty objects. */
123 GList *text_properties;
124 /* The end of this list. */
125 GList *text_properties_end;
126 /* The first node before or on the point along with its offset to
127 * the point and the buffer's current point. This is the only
128 * PropertyMark whose index is guaranteed to remain correct
129 * following a buffer insertion or deletion. */
130 GtkPropertyMark point;
134 union { GdkWChar *wc; guchar *ch; } scratch_buffer;
135 guint scratch_buffer_len;
143 gint cursor_pos_x; /* Position of cursor. */
144 gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
145 GtkPropertyMark cursor_mark; /* Where it is in the buffer. */
146 GdkWChar cursor_char; /* Character to redraw. */
147 gchar cursor_char_offset; /* Distance from baseline of the font. */
148 gint cursor_virtual_x; /* Where it would be if it could be. */
149 gint cursor_drawn_level; /* How many people have undrawn. */
158 gint default_tab_width;
160 GtkTextFont *current_font; /* Text font for current style */
162 /* Timer used for auto-scrolling off ends */
165 guint button; /* currently pressed mouse button */
166 GdkGC *bg_gc; /* gc for drawing background pixmap */
171 GtkOldEditableClass parent_class;
173 void (*set_scroll_adjustments) (GtkText *text,
174 GtkAdjustment *hadjustment,
175 GtkAdjustment *vadjustment);
179 GtkType gtk_text_get_type (void) G_GNUC_CONST;
180 GtkWidget* gtk_text_new (GtkAdjustment *hadj,
181 GtkAdjustment *vadj);
182 void gtk_text_set_editable (GtkText *text,
184 void gtk_text_set_word_wrap (GtkText *text,
186 void gtk_text_set_line_wrap (GtkText *text,
188 void gtk_text_set_adjustments (GtkText *text,
190 GtkAdjustment *vadj);
191 void gtk_text_set_point (GtkText *text,
193 guint gtk_text_get_point (GtkText *text);
194 guint gtk_text_get_length (GtkText *text);
195 void gtk_text_freeze (GtkText *text);
196 void gtk_text_thaw (GtkText *text);
197 void gtk_text_insert (GtkText *text,
199 const GdkColor *fore,
200 const GdkColor *back,
203 gboolean gtk_text_backward_delete (GtkText *text,
205 gboolean gtk_text_forward_delete (GtkText *text,
208 #define GTK_TEXT_INDEX(t, index) (((t)->use_wchar) \
209 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
210 (t)->text.wc[(index)+(t)->gap_size]) \
211 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
212 (t)->text.ch[(index)+(t)->gap_size]))
216 #endif /* __GTK_TEXT_H__ */
218 #endif /* GTK_ENABLE_BROKEN */