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