2 * pango-attributes.h: Attributed text
4 * Copyright (C) 2000 Red Hat Software
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef __PANGO_ATTRIBUTES_H__
23 #define __PANGO_ATTRIBUTES_H__
25 #include <pango/pango-font.h>
26 #include <glib-object.h>
32 typedef struct _PangoColor PangoColor;
41 #define PANGO_TYPE_COLOR pango_color_get_type ()
42 GType pango_color_get_type (void) G_GNUC_CONST;
44 PangoColor *pango_color_copy (const PangoColor *src);
45 void pango_color_free (PangoColor *color);
46 gboolean pango_color_parse (PangoColor *color,
48 gchar *pango_color_to_string(const PangoColor *color);
53 typedef struct _PangoAttribute PangoAttribute;
54 typedef struct _PangoAttrClass PangoAttrClass;
56 typedef struct _PangoAttrString PangoAttrString;
57 typedef struct _PangoAttrLanguage PangoAttrLanguage;
58 typedef struct _PangoAttrInt PangoAttrInt;
59 typedef struct _PangoAttrSize PangoAttrSize;
60 typedef struct _PangoAttrFloat PangoAttrFloat;
61 typedef struct _PangoAttrColor PangoAttrColor;
62 typedef struct _PangoAttrFontDesc PangoAttrFontDesc;
63 typedef struct _PangoAttrShape PangoAttrShape;
65 #define PANGO_TYPE_ATTR_LIST pango_attr_list_get_type ()
66 typedef struct _PangoAttrList PangoAttrList;
67 typedef struct _PangoAttrIterator PangoAttrIterator;
71 PANGO_ATTR_INVALID, /* 0 is an invalid attribute type */
72 PANGO_ATTR_LANGUAGE, /* PangoAttrLanguage */
73 PANGO_ATTR_FAMILY, /* PangoAttrString */
74 PANGO_ATTR_STYLE, /* PangoAttrInt */
75 PANGO_ATTR_WEIGHT, /* PangoAttrInt */
76 PANGO_ATTR_VARIANT, /* PangoAttrInt */
77 PANGO_ATTR_STRETCH, /* PangoAttrInt */
78 PANGO_ATTR_SIZE, /* PangoAttrSize */
79 PANGO_ATTR_FONT_DESC, /* PangoAttrFontDesc */
80 PANGO_ATTR_FOREGROUND, /* PangoAttrColor */
81 PANGO_ATTR_BACKGROUND, /* PangoAttrColor */
82 PANGO_ATTR_UNDERLINE, /* PangoAttrInt */
83 PANGO_ATTR_STRIKETHROUGH, /* PangoAttrInt */
84 PANGO_ATTR_RISE, /* PangoAttrInt */
85 PANGO_ATTR_SHAPE, /* PangoAttrShape */
86 PANGO_ATTR_SCALE, /* PangoAttrFloat */
87 PANGO_ATTR_FALLBACK, /* PangoAttrInt */
88 PANGO_ATTR_LETTER_SPACING, /* PangoAttrInt */
89 PANGO_ATTR_UNDERLINE_COLOR, /* PangoAttrColor */
90 PANGO_ATTR_STRIKETHROUGH_COLOR,/* PangoAttrColor */
91 PANGO_ATTR_ABSOLUTE_SIZE, /* PangoAttrSize */
92 PANGO_ATTR_GRAVITY, /* PangoAttrInt */
93 PANGO_ATTR_GRAVITY_HINT /* PangoAttrInt */
98 PANGO_UNDERLINE_SINGLE,
99 PANGO_UNDERLINE_DOUBLE,
101 PANGO_UNDERLINE_ERROR
104 #define PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING 0
105 #define PANGO_ATTR_INDEX_TO_TEXT_END G_MAXUINT
107 struct _PangoAttribute
109 const PangoAttrClass *klass;
110 guint start_index; /* in bytes */
111 guint end_index; /* in bytes. The character at this index is not included */
114 typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute,
117 typedef gpointer (*PangoAttrDataCopyFunc) (gconstpointer data);
119 struct _PangoAttrClass
123 PangoAttribute * (*copy) (const PangoAttribute *attr);
124 void (*destroy) (PangoAttribute *attr);
125 gboolean (*equal) (const PangoAttribute *attr1, const PangoAttribute *attr2);
128 struct _PangoAttrString
134 struct _PangoAttrLanguage
137 PangoLanguage *value;
146 struct _PangoAttrFloat
152 struct _PangoAttrColor
158 struct _PangoAttrSize
165 struct _PangoAttrShape
168 PangoRectangle ink_rect;
169 PangoRectangle logical_rect;
172 PangoAttrDataCopyFunc copy_func;
173 GDestroyNotify destroy_func;
176 struct _PangoAttrFontDesc
179 PangoFontDescription *desc;
182 PangoAttrType pango_attr_type_register (const gchar *name);
183 G_CONST_RETURN char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST;
185 void pango_attribute_init (PangoAttribute *attr,
186 const PangoAttrClass *klass);
187 PangoAttribute * pango_attribute_copy (const PangoAttribute *attr);
188 void pango_attribute_destroy (PangoAttribute *attr);
189 gboolean pango_attribute_equal (const PangoAttribute *attr1,
190 const PangoAttribute *attr2) G_GNUC_PURE;
192 PangoAttribute *pango_attr_language_new (PangoLanguage *language);
193 PangoAttribute *pango_attr_family_new (const char *family);
194 PangoAttribute *pango_attr_foreground_new (guint16 red,
197 PangoAttribute *pango_attr_background_new (guint16 red,
200 PangoAttribute *pango_attr_size_new (int size);
201 PangoAttribute *pango_attr_size_new_absolute (int size);
202 PangoAttribute *pango_attr_style_new (PangoStyle style);
203 PangoAttribute *pango_attr_weight_new (PangoWeight weight);
204 PangoAttribute *pango_attr_variant_new (PangoVariant variant);
205 PangoAttribute *pango_attr_stretch_new (PangoStretch stretch);
206 PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc);
208 PangoAttribute *pango_attr_underline_new (PangoUnderline underline);
209 PangoAttribute *pango_attr_underline_color_new (guint16 red,
212 PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough);
213 PangoAttribute *pango_attr_strikethrough_color_new (guint16 red,
217 PangoAttribute *pango_attr_rise_new (int rise);
218 PangoAttribute *pango_attr_scale_new (double scale_factor);
219 PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback);
220 PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing);
222 PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect,
223 const PangoRectangle *logical_rect);
224 PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect,
225 const PangoRectangle *logical_rect,
227 PangoAttrDataCopyFunc copy_func,
228 GDestroyNotify destroy_func);
230 PangoAttribute *pango_attr_gravity_new (PangoGravity gravity);
231 PangoAttribute *pango_attr_gravity_hint_new (PangoGravityHint hint);
233 GType pango_attr_list_get_type (void) G_GNUC_CONST;
234 PangoAttrList * pango_attr_list_new (void);
235 PangoAttrList * pango_attr_list_ref (PangoAttrList *list);
236 void pango_attr_list_unref (PangoAttrList *list);
237 PangoAttrList * pango_attr_list_copy (PangoAttrList *list);
238 void pango_attr_list_insert (PangoAttrList *list,
239 PangoAttribute *attr);
240 void pango_attr_list_insert_before (PangoAttrList *list,
241 PangoAttribute *attr);
242 void pango_attr_list_change (PangoAttrList *list,
243 PangoAttribute *attr);
244 void pango_attr_list_splice (PangoAttrList *list,
245 PangoAttrList *other,
249 PangoAttrList *pango_attr_list_filter (PangoAttrList *list,
250 PangoAttrFilterFunc func,
253 PangoAttrIterator *pango_attr_list_get_iterator (PangoAttrList *list);
255 void pango_attr_iterator_range (PangoAttrIterator *iterator,
258 gboolean pango_attr_iterator_next (PangoAttrIterator *iterator);
259 PangoAttrIterator *pango_attr_iterator_copy (PangoAttrIterator *iterator);
260 void pango_attr_iterator_destroy (PangoAttrIterator *iterator);
261 PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator,
263 void pango_attr_iterator_get_font (PangoAttrIterator *iterator,
264 PangoFontDescription *desc,
265 PangoLanguage **language,
266 GSList **extra_attrs);
267 GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
270 gboolean pango_parse_markup (const char *markup_text,
272 gunichar accel_marker,
273 PangoAttrList **attr_list,
275 gunichar *accel_char,
280 #endif /* __PANGO_ATTRIBUTES_H__ */