Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

292 рядки
12 KiB

  1. /* Pango
  2. * pango-layout.h: High-level layout driver
  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_LAYOUT_H__
  22. #define __PANGO_LAYOUT_H__
  23. #include <pango/pango-attributes.h>
  24. #include <pango/pango-context.h>
  25. #include <pango/pango-glyph-item.h>
  26. #include <pango/pango-tabs.h>
  27. G_BEGIN_DECLS
  28. typedef struct _PangoLayout PangoLayout;
  29. typedef struct _PangoLayoutClass PangoLayoutClass;
  30. typedef struct _PangoLayoutLine PangoLayoutLine;
  31. typedef PangoGlyphItem PangoLayoutRun;
  32. typedef enum {
  33. PANGO_ALIGN_LEFT,
  34. PANGO_ALIGN_CENTER,
  35. PANGO_ALIGN_RIGHT
  36. } PangoAlignment;
  37. typedef enum {
  38. PANGO_WRAP_WORD,
  39. PANGO_WRAP_CHAR,
  40. PANGO_WRAP_WORD_CHAR
  41. } PangoWrapMode;
  42. /**
  43. * PangoEllipsizeMode
  44. * @PANGO_ELLIPSIZE_NONE: No ellipsization
  45. * @PANGO_ELLIPSIZE_START: Omit characters at the start of the text
  46. * @PANGO_ELLIPSIZE_MIDDLE: Omit characters in the middle of the text
  47. * @PANGO_ELLIPSIZE_END: Omit characters at the end of the text
  48. *
  49. * The #PangoEllipsizeMode type describes what sort of (if any)
  50. * ellipsization should be applied to a line of text. In
  51. * the ellipsization process characters are removed from the
  52. * text in order to make it fit to a given width and replaced
  53. * with an ellipsis.
  54. */
  55. typedef enum {
  56. PANGO_ELLIPSIZE_NONE,
  57. PANGO_ELLIPSIZE_START,
  58. PANGO_ELLIPSIZE_MIDDLE,
  59. PANGO_ELLIPSIZE_END
  60. } PangoEllipsizeMode;
  61. struct _PangoLayoutLine
  62. {
  63. PangoLayout *layout;
  64. gint start_index; /* start of line as byte index into layout->text */
  65. gint length; /* length of line in bytes */
  66. GSList *runs;
  67. guint is_paragraph_start : 1; /* TRUE if this is the first line of the paragraph */
  68. guint resolved_dir : 3; /* Resolved PangoDirection of line */
  69. };
  70. #define PANGO_TYPE_LAYOUT (pango_layout_get_type ())
  71. #define PANGO_LAYOUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_LAYOUT, PangoLayout))
  72. #define PANGO_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_LAYOUT, PangoLayoutClass))
  73. #define PANGO_IS_LAYOUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_LAYOUT))
  74. #define PANGO_IS_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_LAYOUT))
  75. #define PANGO_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_LAYOUT, PangoLayoutClass))
  76. /* The PangoLayout and PangoLayoutClass structs are private; if you
  77. * need to create a subclass of these, file a bug.
  78. */
  79. GType pango_layout_get_type (void) G_GNUC_CONST;
  80. PangoLayout *pango_layout_new (PangoContext *context);
  81. PangoLayout *pango_layout_copy (PangoLayout *src);
  82. PangoContext *pango_layout_get_context (PangoLayout *layout);
  83. void pango_layout_set_attributes (PangoLayout *layout,
  84. PangoAttrList *attrs);
  85. PangoAttrList *pango_layout_get_attributes (PangoLayout *layout);
  86. void pango_layout_set_text (PangoLayout *layout,
  87. const char *text,
  88. int length);
  89. const char *pango_layout_get_text (PangoLayout *layout);
  90. void pango_layout_set_markup (PangoLayout *layout,
  91. const char *markup,
  92. int length);
  93. void pango_layout_set_markup_with_accel (PangoLayout *layout,
  94. const char *markup,
  95. int length,
  96. gunichar accel_marker,
  97. gunichar *accel_char);
  98. void pango_layout_set_font_description (PangoLayout *layout,
  99. const PangoFontDescription *desc);
  100. G_CONST_RETURN PangoFontDescription *pango_layout_get_font_description (PangoLayout *layout);
  101. void pango_layout_set_width (PangoLayout *layout,
  102. int width);
  103. int pango_layout_get_width (PangoLayout *layout);
  104. void pango_layout_set_height (PangoLayout *layout,
  105. int height);
  106. int pango_layout_get_height (PangoLayout *layout);
  107. void pango_layout_set_wrap (PangoLayout *layout,
  108. PangoWrapMode wrap);
  109. PangoWrapMode pango_layout_get_wrap (PangoLayout *layout);
  110. gboolean pango_layout_is_wrapped (PangoLayout *layout);
  111. void pango_layout_set_indent (PangoLayout *layout,
  112. int indent);
  113. int pango_layout_get_indent (PangoLayout *layout);
  114. void pango_layout_set_spacing (PangoLayout *layout,
  115. int spacing);
  116. int pango_layout_get_spacing (PangoLayout *layout);
  117. void pango_layout_set_justify (PangoLayout *layout,
  118. gboolean justify);
  119. gboolean pango_layout_get_justify (PangoLayout *layout);
  120. void pango_layout_set_auto_dir (PangoLayout *layout,
  121. gboolean auto_dir);
  122. gboolean pango_layout_get_auto_dir (PangoLayout *layout);
  123. void pango_layout_set_alignment (PangoLayout *layout,
  124. PangoAlignment alignment);
  125. PangoAlignment pango_layout_get_alignment (PangoLayout *layout);
  126. void pango_layout_set_tabs (PangoLayout *layout,
  127. PangoTabArray *tabs);
  128. PangoTabArray* pango_layout_get_tabs (PangoLayout *layout);
  129. void pango_layout_set_single_paragraph_mode (PangoLayout *layout,
  130. gboolean setting);
  131. gboolean pango_layout_get_single_paragraph_mode (PangoLayout *layout);
  132. void pango_layout_set_ellipsize (PangoLayout *layout,
  133. PangoEllipsizeMode ellipsize);
  134. PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout);
  135. gboolean pango_layout_is_ellipsized (PangoLayout *layout);
  136. int pango_layout_get_unknown_glyphs_count (PangoLayout *layout);
  137. void pango_layout_context_changed (PangoLayout *layout);
  138. void pango_layout_get_log_attrs (PangoLayout *layout,
  139. PangoLogAttr **attrs,
  140. gint *n_attrs);
  141. void pango_layout_index_to_pos (PangoLayout *layout,
  142. int index_,
  143. PangoRectangle *pos);
  144. void pango_layout_index_to_line_x (PangoLayout *layout,
  145. int index_,
  146. gboolean trailing,
  147. int *line,
  148. int *x_pos);
  149. void pango_layout_get_cursor_pos (PangoLayout *layout,
  150. int index_,
  151. PangoRectangle *strong_pos,
  152. PangoRectangle *weak_pos);
  153. void pango_layout_move_cursor_visually (PangoLayout *layout,
  154. gboolean strong,
  155. int old_index,
  156. int old_trailing,
  157. int direction,
  158. int *new_index,
  159. int *new_trailing);
  160. gboolean pango_layout_xy_to_index (PangoLayout *layout,
  161. int x,
  162. int y,
  163. int *index_,
  164. int *trailing);
  165. void pango_layout_get_extents (PangoLayout *layout,
  166. PangoRectangle *ink_rect,
  167. PangoRectangle *logical_rect);
  168. void pango_layout_get_pixel_extents (PangoLayout *layout,
  169. PangoRectangle *ink_rect,
  170. PangoRectangle *logical_rect);
  171. void pango_layout_get_size (PangoLayout *layout,
  172. int *width,
  173. int *height);
  174. void pango_layout_get_pixel_size (PangoLayout *layout,
  175. int *width,
  176. int *height);
  177. int pango_layout_get_baseline (PangoLayout *layout);
  178. int pango_layout_get_line_count (PangoLayout *layout);
  179. PangoLayoutLine *pango_layout_get_line (PangoLayout *layout,
  180. int line);
  181. PangoLayoutLine *pango_layout_get_line_readonly (PangoLayout *layout,
  182. int line);
  183. GSList * pango_layout_get_lines (PangoLayout *layout);
  184. GSList * pango_layout_get_lines_readonly (PangoLayout *layout);
  185. #define PANGO_TYPE_LAYOUT_LINE (pango_layout_line_get_type ())
  186. GType pango_layout_line_get_type (void) G_GNUC_CONST;
  187. PangoLayoutLine *pango_layout_line_ref (PangoLayoutLine *line);
  188. void pango_layout_line_unref (PangoLayoutLine *line);
  189. gboolean pango_layout_line_x_to_index (PangoLayoutLine *line,
  190. int x_pos,
  191. int *index_,
  192. int *trailing);
  193. void pango_layout_line_index_to_x (PangoLayoutLine *line,
  194. int index_,
  195. gboolean trailing,
  196. int *x_pos);
  197. void pango_layout_line_get_x_ranges (PangoLayoutLine *line,
  198. int start_index,
  199. int end_index,
  200. int **ranges,
  201. int *n_ranges);
  202. void pango_layout_line_get_extents (PangoLayoutLine *line,
  203. PangoRectangle *ink_rect,
  204. PangoRectangle *logical_rect);
  205. void pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line,
  206. PangoRectangle *ink_rect,
  207. PangoRectangle *logical_rect);
  208. typedef struct _PangoLayoutIter PangoLayoutIter;
  209. #define PANGO_TYPE_LAYOUT_ITER (pango_layout_iter_get_type ())
  210. GType pango_layout_iter_get_type (void) G_GNUC_CONST;
  211. PangoLayoutIter *pango_layout_get_iter (PangoLayout *layout);
  212. PangoLayoutIter *pango_layout_iter_copy (PangoLayoutIter *iter);
  213. void pango_layout_iter_free (PangoLayoutIter *iter);
  214. int pango_layout_iter_get_index (PangoLayoutIter *iter);
  215. PangoLayoutRun *pango_layout_iter_get_run (PangoLayoutIter *iter);
  216. PangoLayoutRun *pango_layout_iter_get_run_readonly (PangoLayoutIter *iter);
  217. PangoLayoutLine *pango_layout_iter_get_line (PangoLayoutIter *iter);
  218. PangoLayoutLine *pango_layout_iter_get_line_readonly (PangoLayoutIter *iter);
  219. gboolean pango_layout_iter_at_last_line (PangoLayoutIter *iter);
  220. PangoLayout *pango_layout_iter_get_layout (PangoLayoutIter *iter);
  221. gboolean pango_layout_iter_next_char (PangoLayoutIter *iter);
  222. gboolean pango_layout_iter_next_cluster (PangoLayoutIter *iter);
  223. gboolean pango_layout_iter_next_run (PangoLayoutIter *iter);
  224. gboolean pango_layout_iter_next_line (PangoLayoutIter *iter);
  225. void pango_layout_iter_get_char_extents (PangoLayoutIter *iter,
  226. PangoRectangle *logical_rect);
  227. void pango_layout_iter_get_cluster_extents (PangoLayoutIter *iter,
  228. PangoRectangle *ink_rect,
  229. PangoRectangle *logical_rect);
  230. void pango_layout_iter_get_run_extents (PangoLayoutIter *iter,
  231. PangoRectangle *ink_rect,
  232. PangoRectangle *logical_rect);
  233. void pango_layout_iter_get_line_extents (PangoLayoutIter *iter,
  234. PangoRectangle *ink_rect,
  235. PangoRectangle *logical_rect);
  236. /* All the yranges meet, unlike the logical_rect's (i.e. the yranges
  237. * assign between-line spacing to the nearest line)
  238. */
  239. void pango_layout_iter_get_line_yrange (PangoLayoutIter *iter,
  240. int *y0_,
  241. int *y1_);
  242. void pango_layout_iter_get_layout_extents (PangoLayoutIter *iter,
  243. PangoRectangle *ink_rect,
  244. PangoRectangle *logical_rect);
  245. int pango_layout_iter_get_baseline (PangoLayoutIter *iter);
  246. G_END_DECLS
  247. #endif /* __PANGO_LAYOUT_H__ */