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