1 | /* Pango |
2 | * pango-layout-private.h: Internal structures of PangoLayout |
3 | * |
4 | * Copyright (C) 2004 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 | |
22 | #ifndef __PANGO_LAYOUT_PRIVATE_H__ |
23 | #define __PANGO_LAYOUT_PRIVATE_H__ |
24 | |
25 | #include <pango/pango-layout.h> |
26 | |
27 | G_BEGIN_DECLS |
28 | |
29 | struct _PangoLayout |
30 | { |
31 | GObject parent_instance; |
32 | |
33 | /* If you add fields to PangoLayout be sure to update _copy() |
34 | * unless you add a value between copy_begin and copy_end. |
35 | */ |
36 | |
37 | /* Referenced items */ |
38 | PangoContext *context; |
39 | PangoAttrList *attrs; |
40 | PangoFontDescription *font_desc; |
41 | PangoTabArray *tabs; |
42 | |
43 | /* Dupped */ |
44 | gchar *text; |
45 | |
46 | /* Value fields. These will be memcpy'd in _copy() */ |
47 | int copy_begin; |
48 | |
49 | guint serial; |
50 | guint context_serial; |
51 | |
52 | int length; /* length of text in bytes */ |
53 | int n_chars; /* number of characters in layout */ |
54 | int width; /* wrap/ellipsize width, in device units, or -1 if not set */ |
55 | int height; /* ellipsize width, in device units if positive, number of lines if negative */ |
56 | int indent; /* amount by which first line should be shorter */ |
57 | int spacing; /* spacing between lines */ |
58 | float line_spacing; /* factor to apply to line height */ |
59 | |
60 | guint justify : 1; |
61 | guint justify_last_line : 1; |
62 | guint alignment : 2; |
63 | guint single_paragraph : 1; |
64 | guint auto_dir : 1; |
65 | guint wrap : 2; /* PangoWrapMode */ |
66 | guint is_wrapped : 1; /* Whether the layout has any wrapped lines */ |
67 | guint ellipsize : 2; /* PangoEllipsizeMode */ |
68 | guint is_ellipsized : 1; /* Whether the layout has any ellipsized lines */ |
69 | int unknown_glyphs_count; /* number of unknown glyphs */ |
70 | |
71 | /* some caching */ |
72 | guint logical_rect_cached : 1; |
73 | guint ink_rect_cached : 1; |
74 | PangoRectangle logical_rect; |
75 | PangoRectangle ink_rect; |
76 | int tab_width; /* Cached width of a tab. -1 == not yet calculated */ |
77 | gunichar decimal; |
78 | |
79 | int copy_end; |
80 | |
81 | /* Not copied during _copy() */ |
82 | |
83 | PangoLogAttr *log_attrs; /* Logical attributes for layout's text */ |
84 | GSList *lines; |
85 | guint line_count; /* Number of lines in @lines. 0 if lines is %NULL */ |
86 | }; |
87 | |
88 | typedef struct _Extents Extents; |
89 | struct _Extents |
90 | { |
91 | /* Vertical position of the line's baseline in layout coords */ |
92 | int baseline; |
93 | |
94 | /* Line extents in layout coords */ |
95 | PangoRectangle ink_rect; |
96 | PangoRectangle logical_rect; |
97 | }; |
98 | |
99 | struct _PangoLayoutIter |
100 | { |
101 | PangoLayout *layout; |
102 | GSList *line_list_link; |
103 | PangoLayoutLine *line; |
104 | |
105 | /* If run is NULL, it means we're on a "virtual run" |
106 | * at the end of the line with 0 width |
107 | */ |
108 | GSList *run_list_link; |
109 | PangoLayoutRun *run; /* FIXME nuke this, just keep the link */ |
110 | int index; |
111 | |
112 | /* list of Extents for each line in layout coordinates */ |
113 | Extents *line_extents; |
114 | int line_index; |
115 | |
116 | /* Position of the current run */ |
117 | int run_x; |
118 | |
119 | /* Width and end offset of the current run */ |
120 | int run_width; |
121 | int end_x_offset; |
122 | |
123 | /* this run is left-to-right */ |
124 | gboolean ltr; |
125 | |
126 | /* X position of the left side of the current cluster */ |
127 | int cluster_x; |
128 | |
129 | /* The width of the current cluster */ |
130 | int cluster_width; |
131 | |
132 | /* glyph offset to the current cluster start */ |
133 | int cluster_start; |
134 | |
135 | /* first glyph in the next cluster */ |
136 | int next_cluster_glyph; |
137 | |
138 | /* number of Unicode chars in current cluster */ |
139 | int cluster_num_chars; |
140 | |
141 | /* visual position of current character within the cluster */ |
142 | int character_position; |
143 | |
144 | /* the real width of layout */ |
145 | int layout_width; |
146 | }; |
147 | |
148 | gboolean _pango_layout_line_ellipsize (PangoLayoutLine *line, |
149 | PangoAttrList *attrs, |
150 | PangoShapeFlags shape_flags, |
151 | int goal_width); |
152 | |
153 | void _pango_layout_get_iter (PangoLayout *layout, |
154 | PangoLayoutIter *iter); |
155 | |
156 | void _pango_layout_iter_destroy (PangoLayoutIter *iter); |
157 | |
158 | G_END_DECLS |
159 | |
160 | #endif /* __PANGO_LAYOUT_PRIVATE_H__ */ |
161 | |