initial message templates support
[claws.git] / src / gtkstext.h
blob09bb1b98b775e70c34501ddb6fb1373117c8acc8
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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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-1999. 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/.
28 * Modified by the Sylpheed Team and others 2001.
31 #ifndef __GTK_STEXT_H__
32 #define __GTK_STEXT_H__
35 #include <gdk/gdk.h>
36 #include <gtk/gtkadjustment.h>
37 #include <gtk/gtkeditable.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
44 #define GTK_TYPE_STEXT (gtk_stext_get_type ())
45 #define GTK_STEXT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_STEXT, GtkSText))
46 #define GTK_STEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_STEXT, GtkSTextClass))
47 #define GTK_IS_STEXT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_STEXT))
48 #define GTK_IS_STEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STEXT))
50 typedef struct _GtkSTextFont GtkSTextFont;
51 typedef struct _GtkSPropertyMark GtkSPropertyMark;
52 typedef struct _GtkSText GtkSText;
53 typedef struct _GtkSTextClass GtkSTextClass;
55 typedef enum _GtkSTextCursorType GtkSTextCursorType;
57 enum _GtkSTextCursorType
59 STEXT_CURSOR_LINE,
60 STEXT_CURSOR_BLOCK
63 struct _GtkSPropertyMark
65 /* Position in list. */
66 GList* property;
68 /* Offset into that property. */
69 guint offset;
71 /* Current index. */
72 guint index;
75 struct _GtkSText
77 GtkEditable editable;
79 GdkWindow *text_area;
81 GtkAdjustment *hadj;
82 GtkAdjustment *vadj;
84 GdkGC *gc;
86 GdkPixmap* line_wrap_bitmap;
87 GdkPixmap* line_arrow_bitmap;
89 /* GAPPED TEXT SEGMENT */
91 /* The text, a single segment of text a'la emacs, with a gap
92 * where insertion occurs. */
93 union { GdkWChar *wc; guchar *ch; } text;
94 /* The allocated length of the text segment. */
95 guint text_len;
96 /* The gap position, index into address where a char
97 * should be inserted. */
98 guint gap_position;
99 /* The gap size, s.t. *(text + gap_position + gap_size) is
100 * the first valid character following the gap. */
101 guint gap_size;
102 /* The last character position, index into address where a
103 * character should be appeneded. Thus, text_end - gap_size
104 * is the length of the actual data. */
105 guint text_end;
106 /* LINE START CACHE */
108 /* A cache of line-start information. Data is a LineParam*. */
109 GList *line_start_cache;
110 /* Index to the start of the first visible line. */
111 guint first_line_start_index;
112 /* The number of pixels cut off of the top line. */
113 guint first_cut_pixels;
114 /* First visible horizontal pixel. */
115 guint first_onscreen_hor_pixel;
116 /* First visible vertical pixel. */
117 guint first_onscreen_ver_pixel;
119 /* FLAGS */
121 /* True iff this buffer is wrapping lines, otherwise it is using a
122 * horizontal scrollbar. */
123 guint line_wrap : 1;
124 guint word_wrap : 1;
125 /* If a fontset is supplied for the widget, use_wchar become true,
126 * and we use GdkWchar as the encoding of text. */
127 guint use_wchar : 1;
129 /* Frozen, don't do updates. @@@ fixme */
130 guint freeze_count;
131 /* TEXT PROPERTIES */
133 /* A doubly-linked-list containing TextProperty objects. */
134 GList *text_properties;
135 /* The end of this list. */
136 GList *text_properties_end;
137 /* The first node before or on the point along with its offset to
138 * the point and the buffer's current point. This is the only
139 * PropertyMark whose index is guaranteed to remain correct
140 * following a buffer insertion or deletion. */
141 GtkSPropertyMark point;
143 /* SCRATCH AREA */
145 union { GdkWChar *wc; guchar *ch; } scratch_buffer;
146 guint scratch_buffer_len;
148 /* SCROLLING */
150 gint last_ver_value;
152 /* CURSOR */
154 gint cursor_pos_x; /* Position of cursor. */
155 gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
156 GtkSPropertyMark cursor_mark; /* Where it is in the buffer. */
157 GdkWChar cursor_char; /* Character to redraw. */
158 gchar cursor_char_offset; /* Distance from baseline of the font. */
159 gint cursor_virtual_x; /* Where it would be if it could be. */
160 gint cursor_drawn_level; /* How many people have undrawn. */
162 /* Current Line */
164 GList *current_line;
166 /* Tab Stops */
168 GList *tab_stops;
169 gint default_tab_width;
171 GtkSTextFont *current_font; /* Text font for current style */
173 /* Timer used for auto-scrolling off ends */
174 gint timer;
176 guint button; /* currently pressed mouse button */
177 GdkGC *bg_gc; /* gc for drawing background pixmap */
179 /* SYLPHEED:
180 * properties added for different cursor
182 gboolean cursor_visible; /* whether cursor is visible */
183 gboolean cursor_timer_on; /* blinking enabled */
184 guint cursor_off_ms, cursor_on_ms; /* cursor off / on time */
185 gboolean cursor_state_on; /* state */
186 guint32 cursor_timer_id; /* blinking timer */
187 guint32 cursor_idle_time_timer_id; /* timer id */
189 GtkSTextCursorType cursor_type;
191 /* SYLPHEED:
192 * properties added for rmargin
194 gint wrap_rmargin; /* right margin */
196 /* SYLPHEED:
197 * properties added for persist column position when
198 * using up and down key */
199 gint persist_column;
202 struct _GtkSTextClass
204 GtkEditableClass parent_class;
206 void (*set_scroll_adjustments) (GtkSText *text,
207 GtkAdjustment *hadjustment,
208 GtkAdjustment *vadjustment);
212 GtkType gtk_stext_get_type (void);
213 GtkWidget* gtk_stext_new (GtkAdjustment *hadj,
214 GtkAdjustment *vadj);
215 void gtk_stext_set_editable (GtkSText *text,
216 gboolean editable);
217 void gtk_stext_set_word_wrap (GtkSText *text,
218 gint word_wrap);
219 void gtk_stext_set_line_wrap (GtkSText *text,
220 gint line_wrap);
221 void gtk_stext_set_adjustments (GtkSText *text,
222 GtkAdjustment *hadj,
223 GtkAdjustment *vadj);
224 void gtk_stext_set_point (GtkSText *text,
225 guint index);
226 guint gtk_stext_get_point (GtkSText *text);
227 guint gtk_stext_get_length (GtkSText *text);
228 void gtk_stext_freeze (GtkSText *text);
229 void gtk_stext_thaw (GtkSText *text);
230 void gtk_stext_insert (GtkSText *text,
231 GdkFont *font,
232 GdkColor *fore,
233 GdkColor *back,
234 const char *chars,
235 gint length);
236 gint gtk_stext_backward_delete (GtkSText *text,
237 guint nchars);
238 gint gtk_stext_forward_delete (GtkSText *text,
239 guint nchars);
241 /* SYLPHEED
243 void gtk_stext_set_blink (GtkSText *text, gboolean blinking_on);
245 /* Set the rmargin for the stext. if rmargin is 0, then reset to old
246 * behaviour */
247 void gtk_stext_set_wrap_rmargin (GtkSText *text, gint rmargin);
249 void gtk_stext_set_cursor_type (GtkSText *text, GtkSTextCursorType cursor_type);
251 #define GTK_STEXT_INDEX(t, index) (((t)->use_wchar) \
252 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
253 (t)->text.wc[(index)+(t)->gap_size]) \
254 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
255 (t)->text.ch[(index)+(t)->gap_size]))
257 #ifdef __cplusplus
259 #endif /* __cplusplus */
262 #endif /* __GTK_STEXT_H__ */