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