]>
Commit | Line | Data |
---|---|---|
374ca955 A |
1 | /* |
2 | ********************************************************************** | |
3 | * Copyright (C) 1998-2004, International Business Machines | |
4 | * Corporation and others. All Rights Reserved. | |
5 | ********************************************************************** | |
6 | */ | |
7 | ||
8 | #ifndef __LEINSERTIONLIST_H | |
9 | #define __LEINSERTIONLIST_H | |
10 | ||
11 | #include "LETypes.h" | |
12 | ||
13 | U_NAMESPACE_BEGIN | |
14 | ||
15 | struct InsertionRecord; | |
16 | ||
17 | /** | |
18 | * This class encapsulates the callback used by <code>LEInsertionList</code> | |
19 | * to apply an insertion from the insertion list. | |
20 | * | |
21 | * @internal | |
22 | */ | |
23 | class LEInsertionCallback | |
24 | { | |
25 | public: | |
26 | /** | |
27 | * This method will be called by <code>LEInsertionList::applyInsertions</code> for each | |
28 | * entry on the insertion list. | |
29 | * | |
30 | * @param atPosition the position of the insertion | |
31 | * @param count the number of glyphs to insert | |
32 | * @param newGlyphs the address of the glyphs to insert | |
33 | * | |
34 | * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should | |
35 | * stop after applying this insertion. | |
36 | * | |
37 | * @internal | |
38 | */ | |
39 | virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0; | |
40 | }; | |
41 | ||
42 | /** | |
43 | * This class is used to keep track of insertions to an array of | |
44 | * <code>LEGlyphIDs</code>. The insertions are kept on a linked | |
45 | * list of <code>InsertionRecords</code> so that the glyph array | |
46 | * doesn't have to be grown for each insertion. The insertions are | |
47 | * stored on the list from leftmost to rightmost to make it easier | |
48 | * to do the insertions. | |
49 | * | |
50 | * The insertions are applied to the array by calling the | |
51 | * <code>applyInsertions</code> method, which calls a client | |
52 | * supplied <code>LEInsertionCallback</code> object to actually | |
53 | * apply the individual insertions. | |
54 | * | |
55 | * @internal | |
56 | */ | |
57 | class LEInsertionList : public UObject | |
58 | { | |
59 | public: | |
60 | /** | |
61 | * Construct an empty insertion list. | |
62 | * | |
63 | * @param rightToLeft <code>TRUE</code> if the glyphs are stored | |
64 | * in the array in right to left order. | |
65 | * | |
66 | * @internal | |
67 | */ | |
68 | LEInsertionList(le_bool rightToLeft); | |
69 | ||
70 | /** | |
71 | * The destructor. | |
72 | */ | |
73 | ~LEInsertionList(); | |
74 | ||
75 | /** | |
76 | * Add an entry to the insertion list. | |
77 | * | |
78 | * @param position the glyph at this position in the array will be | |
79 | * replaced by the new glyphs. | |
80 | * @param count the number of new glyphs | |
81 | * | |
82 | * @return the address of an array in which to store the new glyphs. This will | |
83 | * <em>not</em> be in the glyph array. | |
84 | * | |
85 | * @internal | |
86 | */ | |
87 | LEGlyphID *insert(le_int32 position, le_int32 count); | |
88 | ||
89 | /** | |
90 | * Return the number of new glyphs that have been inserted. | |
91 | * | |
92 | * @return the number of new glyphs which have been inserted | |
93 | * | |
94 | * @internal | |
95 | */ | |
96 | le_int32 getGrowAmount(); | |
97 | ||
98 | /** | |
99 | * Call the <code>LEInsertionCallback</code> once for each | |
100 | * entry on the insertion list. | |
101 | * | |
102 | * @param callback the <code>LEInsertionCallback</code> to call for each insertion. | |
103 | * | |
104 | * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to | |
105 | * terminate the insertion list processing. | |
106 | * | |
107 | * @internal | |
108 | */ | |
109 | le_bool applyInsertions(LEInsertionCallback *callback); | |
110 | ||
111 | /** | |
112 | * Empty the insertion list and free all associated | |
113 | * storage. | |
114 | * | |
115 | * @internal | |
116 | */ | |
117 | void reset(); | |
118 | ||
119 | /** | |
120 | * ICU "poor man's RTTI", returns a UClassID for the actual class. | |
121 | * | |
122 | * @stable ICU 2.8 | |
123 | */ | |
124 | virtual UClassID getDynamicClassID() const; | |
125 | ||
126 | /** | |
127 | * ICU "poor man's RTTI", returns a UClassID for this class. | |
128 | * | |
129 | * @stable ICU 2.8 | |
130 | */ | |
131 | static UClassID getStaticClassID(); | |
132 | ||
133 | private: | |
134 | ||
135 | /** | |
136 | * The head of the insertion list. | |
137 | * | |
138 | * @internal | |
139 | */ | |
140 | InsertionRecord *head; | |
141 | ||
142 | /** | |
143 | * The tail of the insertion list. | |
144 | * | |
145 | * @internal | |
146 | */ | |
147 | InsertionRecord *tail; | |
148 | ||
149 | /** | |
150 | * The total number of new glyphs on the insertion list. | |
151 | * | |
152 | * @internal | |
153 | */ | |
154 | le_int32 growAmount; | |
155 | ||
156 | /** | |
157 | * Set to <code>TRUE</code> if the glyphs are in right | |
158 | * to left order. Since we want the rightmost insertion | |
159 | * to be first on the list, we need to append the | |
160 | * insertions in this case. Otherwise they're prepended. | |
161 | * | |
162 | * @internal | |
163 | */ | |
164 | le_bool append; | |
165 | }; | |
166 | ||
167 | U_NAMESPACE_END | |
168 | #endif | |
169 |