]> Pileus Git - ~andy/gtk/blob - gtk/gtktexttag.h
Massive reindentation and reformatting. Arg alignment and comments still
[~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_WRAPMODE_NONE,
18   GTK_WRAPMODE_CHAR,
19   GTK_WRAPMODE_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)            (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 {
36   GtkObject 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 font_set : 1;
65   guint fg_stipple_set : 1;
66   guint justify_set : 1;
67   guint left_margin_set : 1;
68   guint left_wrapped_line_margin_set : 1;
69   guint offset_set : 1;
70   guint strikethrough_set : 1;
71   guint right_margin_set : 1;
72   guint pixels_above_lines_set : 1;
73   guint pixels_below_lines_set : 1;
74   guint pixels_inside_wrap_set : 1;
75   guint tabs_set : 1;
76   guint underline_set : 1;
77   guint wrap_mode_set : 1;
78   guint bg_full_height_set : 1;
79   guint invisible_set : 1;
80   guint editable_set : 1;
81   guint language_set : 1;
82   guint pad1 : 1;
83   guint pad2 : 1;
84   guint pad3 : 1;
85 };
86
87 struct _GtkTextTagClass {
88   GtkObjectClass parent_class;
89
90   gint (* event) (GtkTextTag *tag,
91                   GtkObject *event_object,         /* widget, canvas item, whatever */
92                   GdkEvent *event,                 /* the event itself */
93                   const GtkTextIter *iter);        /* location of event in buffer */
94 };
95
96 GtkType      gtk_text_tag_get_type     (void) G_GNUC_CONST;
97 GtkTextTag  *gtk_text_tag_new          (const gchar       *name);
98 gint         gtk_text_tag_get_priority (GtkTextTag        *tag);
99 void         gtk_text_tag_set_priority (GtkTextTag        *tag,
100                                         gint               priority);
101 gint         gtk_text_tag_event        (GtkTextTag        *tag,
102                                         GtkObject         *event_object,
103                                         GdkEvent          *event,
104                                         const GtkTextIter *iter);
105
106 /*
107  * Style object created by folding a set of tags together
108  */
109
110 typedef struct _GtkTextAppearance GtkTextAppearance;
111
112 struct _GtkTextAppearance
113 {
114   GdkColor bg_color;
115   GdkColor fg_color;
116   GdkBitmap *bg_stipple;
117   GdkBitmap *fg_stipple;
118
119   guint underline : 4;          /* PangoUnderline */
120   guint strikethrough : 1;
121
122   /* Whether to use background-related values; this is irrelevant for
123    * the values struct when in a tag, but is used for the composite
124    * values struct; it's true if any of the tags being composited
125    * had background stuff set.
126    */
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    * GtkTextAttributes.
132    */
133   guint inside_selection : 1;
134 };
135
136 struct _GtkTextAttributes
137 {
138   guint refcount;
139
140   GtkTextAppearance appearance;
141
142   GtkJustification justify;
143   GtkTextDirection direction;
144
145   PangoFontDescription *font_desc;
146
147   /* lMargin1 */
148   gint left_margin;
149
150   /* lMargin2 */
151   gint left_wrapped_line_margin;
152
153   /* super/subscript offset, can be negative */
154   gint offset;
155
156   gint right_margin;
157
158   gint pixels_above_lines;
159
160   gint pixels_below_lines;
161
162   gint pixels_inside_wrap;
163
164   PangoTabArray *tabs;
165
166   GtkWrapMode wrap_mode;        /* How to handle wrap-around for this tag.
167                                  * Must be GTK_WRAPMODE_CHAR,
168                                  * GTK_WRAPMODE_NONE, GTK_WRAPMODE_WORD
169                                  */
170
171   gchar *language;
172
173   /* hide the text  */
174   guint invisible : 1;
175
176   /* Background is fit to full line height rather than
177    * baseline +/- ascent/descent (font height)
178    */
179   guint bg_full_height : 1;
180
181   /* can edit this text */
182   guint editable : 1;
183
184   /* colors are allocated etc. */
185   guint realized : 1;
186
187   guint pad1 : 1;
188   guint pad2 : 1;
189   guint pad3 : 1;
190   guint pad4 : 1;
191 };
192
193 GtkTextAttributes  *gtk_text_attributes_new       (void);
194 void                gtk_text_attributes_copy      (GtkTextAttributes *src,
195                                                    GtkTextAttributes *dest);
196 void                gtk_text_attributes_unref     (GtkTextAttributes *values);
197 void                gtk_text_attributes_ref       (GtkTextAttributes *values);
198
199 #ifdef __cplusplus
200 }
201 #endif /* __cplusplus */
202
203 #endif
204