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