]> Pileus Git - ~andy/gtk/blob - gtk/gtktexttag.h
Use G_GNUC_CONST.
[~andy/gtk] / gtk / gtktexttag.h
1 #ifndef GTK_TEXT_TAG_H
2 #define GTK_TEXT_TAG_H
3
4 #include <gtk/gtkobject.h>
5 #include <gdk/gdk.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif /* __cplusplus */
10
11 typedef struct _GtkTextIter GtkTextIter;
12 typedef struct _GtkTextBTreeNode GtkTextBTreeNode;
13 typedef struct _GtkTextTagTable GtkTextTagTable;
14 typedef struct _GtkTextTabArray GtkTextTabArray;
15
16 typedef enum {
17   GTK_WRAPMODE_NONE,
18   GTK_WRAPMODE_CHAR,
19   GTK_WRAPMODE_WORD
20 } GtkWrapMode;
21
22 typedef struct _GtkTextStyleValues GtkTextStyleValues;
23
24 #define GTK_TYPE_TEXT_TAG            (gtk_text_tag_get_type())
25 #define GTK_TEXT_TAG(obj)            (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_TAG, GtkTextTag))
26 #define GTK_TEXT_TAG_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
27 #define GTK_IS_TEXT_TAG(obj)         (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_TAG))
28 #define GTK_IS_TEXT_TAG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG))
29 #define GTK_TEXT_TAG_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
30
31 typedef struct _GtkTextTag GtkTextTag;
32 typedef struct _GtkTextTagClass GtkTextTagClass;
33
34 struct _GtkTextTag {
35   GtkObject parent_instance;
36
37   GtkTextTagTable *table;
38   
39   char *name;                   /* Name of this tag.  This field is actually
40                                  * a pointer to the key from the entry in
41                                  * tkxt->tagTable, so it needn't be freed
42                                  * explicitly. */
43   int priority;         /* Priority of this tag within widget.  0
44                          * means lowest priority.  Exactly one tag
45                          * has each integer value between 0 and
46                          * numTags-1. */
47   /*
48    * Information for displaying text with this tag.  The information
49    * belows acts as an override on information specified by lower-priority
50    * tags.  If no value is specified, then the next-lower-priority tag
51    * on the text determins the value.  The text widget itself provides
52    * defaults if no tag specifies an override.
53    */
54
55   GtkTextStyleValues *values;  
56   
57   /*
58     Flags for whether a given value is set; if a value is unset, then
59     this tag does not affect it.  */
60   guint bg_color_set : 1;
61   guint border_width_set : 1;
62   guint relief_set : 1;
63   guint bg_stipple_set : 1;
64   guint fg_color_set : 1;
65   guint font_set : 1;
66   guint fg_stipple_set : 1;
67   guint justify_set : 1;
68   guint left_margin_set : 1;
69   guint left_wrapped_line_margin_set : 1;
70   guint offset_set : 1;
71   guint overstrike_set : 1;
72   guint right_margin_set : 1;
73   guint pixels_above_lines_set : 1;
74   guint pixels_below_lines_set : 1;
75   guint pixels_inside_wrap_set : 1;
76   guint tab_array_set : 1;
77   guint underline_set : 1;
78   guint wrap_mode_set : 1;
79   guint bg_full_height_set : 1;
80   guint invisible_set : 1;
81   guint editable_set : 1;
82   guint language_set : 1;
83   guint pad1 : 1;
84   guint pad2 : 1;
85   guint pad3 : 1;
86 };
87
88 struct _GtkTextTagClass {
89   GtkObjectClass parent_class;
90
91   gint (* event) (GtkTextTag *tag,
92                   GtkObject *event_object,         /* widget, canvas item, whatever */
93                   GdkEvent *event,                 /* the event itself */
94                   const GtkTextIter *iter);        /* location of event in buffer */
95 };
96
97 GtkType      gtk_text_tag_get_type     (void) G_GNUC_CONST;
98 GtkTextTag  *gtk_text_tag_new          (const gchar       *name);
99 gint         gtk_text_tag_get_priority (GtkTextTag        *tag);
100 void         gtk_text_tag_set_priority (GtkTextTag        *tag,
101                                         gint               priority);
102 gint         gtk_text_tag_event        (GtkTextTag        *tag,
103                                         GtkObject         *event_object,
104                                         GdkEvent          *event,
105                                         const GtkTextIter *iter);
106
107 /*
108  * Style object created by folding a set of tags together
109  */
110
111 typedef struct _GtkTextAppearance GtkTextAppearance;
112
113 struct _GtkTextAppearance
114 {
115   GdkColor bg_color;
116   GdkColor fg_color;
117   GdkBitmap *bg_stipple;
118   GdkBitmap *fg_stipple;
119
120   guint underline : 4;          /* PangoUnderline */
121   guint overstrike : 1;
122
123   /* Whether to use background-related values; this is irrelevant for
124    * the values struct when in a tag, but is used for the composite
125    * values struct; it's true if any of the tags being composited
126    * had background stuff set. */
127   guint draw_bg : 1;
128
129   /* This is only used when we are actually laying out and rendering
130    * a paragraph; not when a GtkTextAppearance is part of a
131    * GtkTextStyleValues.
132    */
133   guint inside_selection : 1;
134 };
135
136 struct _GtkTextStyleValues
137 {
138   guint refcount;
139
140   GtkTextAppearance appearance;
141   
142   gint border_width;
143   GtkShadowType relief;
144   GtkJustification justify;
145   GtkTextDirection direction;
146   
147   PangoFontDescription *font_desc;
148   
149   /* lMargin1 */
150   gint left_margin;
151   
152   /* lMargin2 */
153   gint left_wrapped_line_margin;
154
155   /* super/subscript offset, can be negative */
156   gint offset;
157   
158   gint right_margin;
159
160   gint pixels_above_lines;
161
162   gint pixels_below_lines;
163
164   gint pixels_inside_wrap;
165
166   GtkTextTabArray *tab_array;
167   
168   GtkWrapMode wrap_mode;        /* How to handle wrap-around for this tag.
169                                  * Must be GTK_WRAPMODE_CHAR,
170                                  * GTK_WRAPMODE_NONE, GTK_WRAPMODE_WORD
171                                  */
172
173   gchar *language;
174   
175   /* hide the text  */
176   guint invisible : 1;
177
178   /* Background is fit to full line height rather than
179    * baseline +/- ascent/descent (font height) */
180   guint bg_full_height : 1;
181   
182   /* can edit this text */
183   guint editable : 1;
184
185   /* colors are allocated etc. */
186   guint realized : 1;
187
188   guint pad1 : 1;
189   guint pad2 : 1;
190   guint pad3 : 1;
191   guint pad4 : 1;
192 };
193
194 GtkTextStyleValues *gtk_text_style_values_new       (void);
195 void                gtk_text_style_values_copy      (GtkTextStyleValues *src,
196                                                      GtkTextStyleValues *dest);
197 void                gtk_text_style_values_unref     (GtkTextStyleValues *values);
198 void                gtk_text_style_values_ref       (GtkTextStyleValues *values);
199
200
201 #ifdef __cplusplus
202 }
203 #endif /* __cplusplus */
204
205 #endif
206