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