00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __EXT_GTK_TEXT_H__
00041 #define __EXT_GTK_TEXT_H__
00042
00043 #include <gdk/gdk.h>
00044 #include <gtk/gtkadjustment.h>
00045 #include <gtk/gtkeditable.h>
00046 #ifdef HAVE_LIBXFT
00047 #include <X11/Xft/Xft.h>
00048 #endif
00049
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053
00054 #ifndef HAVE_LIBXFT
00055 #define VFont GdkFont
00056 #else
00057 #define VFont XftFont
00058 #endif
00059
00060 #define EXT_GTK_TYPE_TEXT (ext_gtk_text_get_type ())
00061 #define GTK_SCTEXT(obj) (GTK_CHECK_CAST ((obj), EXT_GTK_TYPE_TEXT, ExtGtkText))
00062 #define EXT_GTK_TEXT(obj) (GTK_CHECK_CAST ((obj), EXT_GTK_TYPE_TEXT, ExtGtkText))
00063 #define EXT_GTK_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EXT_GTK_TYPE_TEXT, ExtGtkTextClass))
00064 #define EXT_GTK_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), EXT_GTK_TYPE_TEXT))
00065 #define EXT_GTK_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EXT_GTK_TYPE_TEXT))
00066
00067 typedef struct _ExtGtkTextFont ExtGtkTextFont;
00068 typedef struct _ExtGtkPropertyMark ExtGtkPropertyMark;
00069 typedef struct _ExtGtkText ExtGtkText;
00070 typedef struct _ExtGtkTextClass ExtGtkTextClass;
00071
00072 typedef void DataFunc (GdkWindow * window, gpointer info);
00073
00074
00075 struct _ExtGtkPropertyMark
00076 {
00077
00078 GList* property;
00079
00080
00081 guint offset;
00082
00083
00084 guint index;
00085 };
00086
00087 struct _ExtGtkText
00088 {
00089 GtkEditable editable;
00090
00091 GdkWindow *text_area;
00092
00093 GtkAdjustment *hadj;
00094 GtkAdjustment *vadj;
00095
00096 GdkGC *gc;
00097
00098
00099
00100
00101
00102
00103 union { GdkWChar *wc; guchar *ch; } text;
00104
00105 guint text_len;
00106
00107
00108 guint gap_position;
00109
00110
00111 guint gap_size;
00112
00113
00114
00115 guint text_end;
00116
00117
00118
00119 GList *line_start_cache;
00120
00121 guint first_line_start_index;
00122
00123 guint first_cut_pixels;
00124
00125 guint first_onscreen_hor_pixel;
00126
00127 guint first_onscreen_ver_pixel;
00128
00129
00130
00131
00132
00133 guint line_wrap : 1;
00134 guint word_wrap : 1;
00135
00136
00137 guint use_wchar : 1;
00138
00139
00140 guint freeze_count;
00141
00142
00143
00144 GList *text_properties;
00145
00146 GList *text_properties_end;
00147
00148
00149
00150
00151 ExtGtkPropertyMark point;
00152
00153
00154
00155 union { GdkWChar *wc; guchar *ch; } scratch_buffer;
00156 guint scratch_buffer_len;
00157
00158
00159
00160 gint last_ver_value;
00161
00162
00163
00164 gint cursor_pos_x;
00165 gint cursor_pos_y;
00166 ExtGtkPropertyMark cursor_mark;
00167 GdkWChar cursor_char;
00168 gchar cursor_char_offset;
00169 gint cursor_virtual_x;
00170 gint cursor_drawn_level;
00171
00172
00173
00174 GList *current_line;
00175
00176
00177
00178 GList *tab_stops;
00179 gint default_tab_width;
00180
00181 ExtGtkTextFont *current_font;
00182
00183
00184 gint timer;
00185
00186 guint button;
00187 GdkGC *bg_gc;
00188 };
00189
00190 struct _ExtGtkTextClass
00191 {
00192 GtkEditableClass parent_class;
00193
00194 void (*set_scroll_adjustments) (ExtGtkText *text,
00195 GtkAdjustment *hadjustment,
00196 GtkAdjustment *vadjustment);
00197 };
00198
00199 GtkType ext_gtk_text_get_type (void);
00200 GtkWidget* ext_gtk_text_new (GtkAdjustment *hadj,
00201 GtkAdjustment *vadj);
00202 void ext_gtk_text_set_editable (ExtGtkText *text,
00203 gboolean editable);
00204 void ext_gtk_text_set_word_wrap (ExtGtkText *text,
00205 gint word_wrap);
00206 void ext_gtk_text_set_line_wrap (ExtGtkText *text,
00207 gint line_wrap);
00208 void ext_gtk_text_set_adjustments (ExtGtkText *text,
00209 GtkAdjustment *hadj,
00210 GtkAdjustment *vadj);
00211 void ext_gtk_text_set_point (ExtGtkText *text,
00212 guint index);
00213 guint ext_gtk_text_get_point (ExtGtkText *text);
00214 guint ext_gtk_text_get_length (ExtGtkText *text);
00215 void ext_gtk_text_freeze (ExtGtkText *text);
00216 void ext_gtk_text_thaw (ExtGtkText *text);
00217 void ext_gtk_text_insert (ExtGtkText *text,
00218 VFont *font,
00219 GdkColor *fore,
00220 GdkColor *back,
00221 const char *chars,
00222 gint length);
00223 void ext_gtk_text_insert_underlined(ExtGtkText *text,
00224 VFont *font,
00225 GdkColor *fore,
00226 GdkColor *back,
00227 const char *chars,
00228 gint length);
00229 void
00230 ext_gtk_text_insert_divider(ExtGtkText *text,
00231 VFont *font,
00232 GdkColor *fore,
00233 GdkColor *back,
00234 const char *chars,
00235 gint nchars);
00236
00237 void ext_gtk_text_insert_pixmap(ExtGtkText *text,
00238 VFont *font,
00239 GdkColor *fore,
00240 GdkColor *back,
00241 GdkDrawable *image,
00242 GdkBitmap *mask,
00243 const char *chars,
00244 gint length);
00245 void ext_gtk_text_insert_data_underlined (ExtGtkText *text,
00246 VFont *font,
00247 GdkColor *fore,
00248 GdkColor *back,
00249 gpointer user_data,
00250 guint user_data_length,
00251 DataFunc *user_data_func,
00252 const char *chars,
00253 gint length);
00254 void ext_gtk_text_insert_data (ExtGtkText *text,
00255 VFont *font,
00256 GdkColor *fore,
00257 GdkColor *back,
00258 gpointer user_data,
00259 guint user_data_length,
00260 DataFunc *user_data_func,
00261 const char *chars,
00262 gint length);
00263 gint ext_gtk_text_backward_delete (ExtGtkText *text,
00264 guint nchars);
00265 gint ext_gtk_text_forward_delete (ExtGtkText *text,
00266 guint nchars);
00267
00268 #define EXT_GTK_TEXT_INDEX(t, index) (((t)->use_wchar) \
00269 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
00270 (t)->text.wc[(index)+(t)->gap_size]) \
00271 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
00272 (t)->text.ch[(index)+(t)->gap_size]))
00273
00274 #ifdef __cplusplus
00275 }
00276 #endif
00277
00278
00279 #endif