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