You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

281 lines
9.8 KiB

  1. /* Pango
  2. * pango-attributes.h: Attributed text
  3. *
  4. * Copyright (C) 2000 Red Hat Software
  5. *
  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.
  10. *
  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.
  15. *
  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.
  20. */
  21. #ifndef __PANGO_ATTRIBUTES_H__
  22. #define __PANGO_ATTRIBUTES_H__
  23. #include <pango/pango-font.h>
  24. #include <glib-object.h>
  25. G_BEGIN_DECLS
  26. /* PangoColor */
  27. typedef struct _PangoColor PangoColor;
  28. struct _PangoColor
  29. {
  30. guint16 red;
  31. guint16 green;
  32. guint16 blue;
  33. };
  34. #define PANGO_TYPE_COLOR pango_color_get_type ()
  35. GType pango_color_get_type (void) G_GNUC_CONST;
  36. PangoColor *pango_color_copy (const PangoColor *src);
  37. void pango_color_free (PangoColor *color);
  38. gboolean pango_color_parse (PangoColor *color,
  39. const char *spec);
  40. gchar *pango_color_to_string(const PangoColor *color);
  41. /* Attributes */
  42. typedef struct _PangoAttribute PangoAttribute;
  43. typedef struct _PangoAttrClass PangoAttrClass;
  44. typedef struct _PangoAttrString PangoAttrString;
  45. typedef struct _PangoAttrLanguage PangoAttrLanguage;
  46. typedef struct _PangoAttrInt PangoAttrInt;
  47. typedef struct _PangoAttrSize PangoAttrSize;
  48. typedef struct _PangoAttrFloat PangoAttrFloat;
  49. typedef struct _PangoAttrColor PangoAttrColor;
  50. typedef struct _PangoAttrFontDesc PangoAttrFontDesc;
  51. typedef struct _PangoAttrShape PangoAttrShape;
  52. #define PANGO_TYPE_ATTR_LIST pango_attr_list_get_type ()
  53. typedef struct _PangoAttrList PangoAttrList;
  54. typedef struct _PangoAttrIterator PangoAttrIterator;
  55. typedef enum
  56. {
  57. PANGO_ATTR_INVALID, /* 0 is an invalid attribute type */
  58. PANGO_ATTR_LANGUAGE, /* PangoAttrLanguage */
  59. PANGO_ATTR_FAMILY, /* PangoAttrString */
  60. PANGO_ATTR_STYLE, /* PangoAttrInt */
  61. PANGO_ATTR_WEIGHT, /* PangoAttrInt */
  62. PANGO_ATTR_VARIANT, /* PangoAttrInt */
  63. PANGO_ATTR_STRETCH, /* PangoAttrInt */
  64. PANGO_ATTR_SIZE, /* PangoAttrSize */
  65. PANGO_ATTR_FONT_DESC, /* PangoAttrFontDesc */
  66. PANGO_ATTR_FOREGROUND, /* PangoAttrColor */
  67. PANGO_ATTR_BACKGROUND, /* PangoAttrColor */
  68. PANGO_ATTR_UNDERLINE, /* PangoAttrInt */
  69. PANGO_ATTR_STRIKETHROUGH, /* PangoAttrInt */
  70. PANGO_ATTR_RISE, /* PangoAttrInt */
  71. PANGO_ATTR_SHAPE, /* PangoAttrShape */
  72. PANGO_ATTR_SCALE, /* PangoAttrFloat */
  73. PANGO_ATTR_FALLBACK, /* PangoAttrInt */
  74. PANGO_ATTR_LETTER_SPACING, /* PangoAttrInt */
  75. PANGO_ATTR_UNDERLINE_COLOR, /* PangoAttrColor */
  76. PANGO_ATTR_STRIKETHROUGH_COLOR,/* PangoAttrColor */
  77. PANGO_ATTR_ABSOLUTE_SIZE, /* PangoAttrSize */
  78. PANGO_ATTR_GRAVITY, /* PangoAttrInt */
  79. PANGO_ATTR_GRAVITY_HINT /* PangoAttrInt */
  80. } PangoAttrType;
  81. typedef enum {
  82. PANGO_UNDERLINE_NONE,
  83. PANGO_UNDERLINE_SINGLE,
  84. PANGO_UNDERLINE_DOUBLE,
  85. PANGO_UNDERLINE_LOW,
  86. PANGO_UNDERLINE_ERROR
  87. } PangoUnderline;
  88. #define PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING 0
  89. #define PANGO_ATTR_INDEX_TO_TEXT_END G_MAXUINT
  90. struct _PangoAttribute
  91. {
  92. const PangoAttrClass *klass;
  93. guint start_index; /* in bytes */
  94. guint end_index; /* in bytes. The character at this index is not included */
  95. };
  96. typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute,
  97. gpointer data);
  98. typedef gpointer (*PangoAttrDataCopyFunc) (gconstpointer data);
  99. struct _PangoAttrClass
  100. {
  101. /*< public >*/
  102. PangoAttrType type;
  103. PangoAttribute * (*copy) (const PangoAttribute *attr);
  104. void (*destroy) (PangoAttribute *attr);
  105. gboolean (*equal) (const PangoAttribute *attr1, const PangoAttribute *attr2);
  106. };
  107. struct _PangoAttrString
  108. {
  109. PangoAttribute attr;
  110. char *value;
  111. };
  112. struct _PangoAttrLanguage
  113. {
  114. PangoAttribute attr;
  115. PangoLanguage *value;
  116. };
  117. struct _PangoAttrInt
  118. {
  119. PangoAttribute attr;
  120. int value;
  121. };
  122. struct _PangoAttrFloat
  123. {
  124. PangoAttribute attr;
  125. double value;
  126. };
  127. struct _PangoAttrColor
  128. {
  129. PangoAttribute attr;
  130. PangoColor color;
  131. };
  132. struct _PangoAttrSize
  133. {
  134. PangoAttribute attr;
  135. int size;
  136. guint absolute : 1;
  137. };
  138. struct _PangoAttrShape
  139. {
  140. PangoAttribute attr;
  141. PangoRectangle ink_rect;
  142. PangoRectangle logical_rect;
  143. gpointer data;
  144. PangoAttrDataCopyFunc copy_func;
  145. GDestroyNotify destroy_func;
  146. };
  147. struct _PangoAttrFontDesc
  148. {
  149. PangoAttribute attr;
  150. PangoFontDescription *desc;
  151. };
  152. PangoAttrType pango_attr_type_register (const gchar *name);
  153. G_CONST_RETURN char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST;
  154. void pango_attribute_init (PangoAttribute *attr,
  155. const PangoAttrClass *klass);
  156. PangoAttribute * pango_attribute_copy (const PangoAttribute *attr);
  157. void pango_attribute_destroy (PangoAttribute *attr);
  158. gboolean pango_attribute_equal (const PangoAttribute *attr1,
  159. const PangoAttribute *attr2) G_GNUC_PURE;
  160. PangoAttribute *pango_attr_language_new (PangoLanguage *language);
  161. PangoAttribute *pango_attr_family_new (const char *family);
  162. PangoAttribute *pango_attr_foreground_new (guint16 red,
  163. guint16 green,
  164. guint16 blue);
  165. PangoAttribute *pango_attr_background_new (guint16 red,
  166. guint16 green,
  167. guint16 blue);
  168. PangoAttribute *pango_attr_size_new (int size);
  169. PangoAttribute *pango_attr_size_new_absolute (int size);
  170. PangoAttribute *pango_attr_style_new (PangoStyle style);
  171. PangoAttribute *pango_attr_weight_new (PangoWeight weight);
  172. PangoAttribute *pango_attr_variant_new (PangoVariant variant);
  173. PangoAttribute *pango_attr_stretch_new (PangoStretch stretch);
  174. PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc);
  175. PangoAttribute *pango_attr_underline_new (PangoUnderline underline);
  176. PangoAttribute *pango_attr_underline_color_new (guint16 red,
  177. guint16 green,
  178. guint16 blue);
  179. PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough);
  180. PangoAttribute *pango_attr_strikethrough_color_new (guint16 red,
  181. guint16 green,
  182. guint16 blue);
  183. PangoAttribute *pango_attr_rise_new (int rise);
  184. PangoAttribute *pango_attr_scale_new (double scale_factor);
  185. PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback);
  186. PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing);
  187. PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect,
  188. const PangoRectangle *logical_rect);
  189. PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect,
  190. const PangoRectangle *logical_rect,
  191. gpointer data,
  192. PangoAttrDataCopyFunc copy_func,
  193. GDestroyNotify destroy_func);
  194. PangoAttribute *pango_attr_gravity_new (PangoGravity gravity);
  195. PangoAttribute *pango_attr_gravity_hint_new (PangoGravityHint hint);
  196. GType pango_attr_list_get_type (void) G_GNUC_CONST;
  197. PangoAttrList * pango_attr_list_new (void);
  198. PangoAttrList * pango_attr_list_ref (PangoAttrList *list);
  199. void pango_attr_list_unref (PangoAttrList *list);
  200. PangoAttrList * pango_attr_list_copy (PangoAttrList *list);
  201. void pango_attr_list_insert (PangoAttrList *list,
  202. PangoAttribute *attr);
  203. void pango_attr_list_insert_before (PangoAttrList *list,
  204. PangoAttribute *attr);
  205. void pango_attr_list_change (PangoAttrList *list,
  206. PangoAttribute *attr);
  207. void pango_attr_list_splice (PangoAttrList *list,
  208. PangoAttrList *other,
  209. gint pos,
  210. gint len);
  211. PangoAttrList *pango_attr_list_filter (PangoAttrList *list,
  212. PangoAttrFilterFunc func,
  213. gpointer data);
  214. PangoAttrIterator *pango_attr_list_get_iterator (PangoAttrList *list);
  215. void pango_attr_iterator_range (PangoAttrIterator *iterator,
  216. gint *start,
  217. gint *end);
  218. gboolean pango_attr_iterator_next (PangoAttrIterator *iterator);
  219. PangoAttrIterator *pango_attr_iterator_copy (PangoAttrIterator *iterator);
  220. void pango_attr_iterator_destroy (PangoAttrIterator *iterator);
  221. PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator,
  222. PangoAttrType type);
  223. void pango_attr_iterator_get_font (PangoAttrIterator *iterator,
  224. PangoFontDescription *desc,
  225. PangoLanguage **language,
  226. GSList **extra_attrs);
  227. GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
  228. gboolean pango_parse_markup (const char *markup_text,
  229. int length,
  230. gunichar accel_marker,
  231. PangoAttrList **attr_list,
  232. char **text,
  233. gunichar *accel_char,
  234. GError **error);
  235. G_END_DECLS
  236. #endif /* __PANGO_ATTRIBUTES_H__ */