2 **********************************************************************
3 * Copyright (C) 1998-2006, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
8 #ifndef __LEINSERTIONLIST_H
9 #define __LEINSERTIONLIST_H
15 struct InsertionRecord
;
18 * This class encapsulates the callback used by <code>LEInsertionList</code>
19 * to apply an insertion from the insertion list.
23 class U_LAYOUT_API LEInsertionCallback
27 * This method will be called by <code>LEInsertionList::applyInsertions</code> for each
28 * entry on the insertion list.
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
34 * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
35 * stop after applying this insertion.
39 virtual le_bool
applyInsertion(le_int32 atPosition
, le_int32 count
, LEGlyphID newGlyphs
[]) = 0;
44 virtual ~LEInsertionCallback();
48 * This class is used to keep track of insertions to an array of
49 * <code>LEGlyphIDs</code>. The insertions are kept on a linked
50 * list of <code>InsertionRecords</code> so that the glyph array
51 * doesn't have to be grown for each insertion. The insertions are
52 * stored on the list from leftmost to rightmost to make it easier
53 * to do the insertions.
55 * The insertions are applied to the array by calling the
56 * <code>applyInsertions</code> method, which calls a client
57 * supplied <code>LEInsertionCallback</code> object to actually
58 * apply the individual insertions.
62 class LEInsertionList
: public UObject
66 * Construct an empty insertion list.
68 * @param rightToLeft <code>TRUE</code> if the glyphs are stored
69 * in the array in right to left order.
73 LEInsertionList(le_bool rightToLeft
);
81 * Add an entry to the insertion list.
83 * @param position the glyph at this position in the array will be
84 * replaced by the new glyphs.
85 * @param count the number of new glyphs
87 * @return the address of an array in which to store the new glyphs. This will
88 * <em>not</em> be in the glyph array.
92 LEGlyphID
*insert(le_int32 position
, le_int32 count
);
95 * Return the number of new glyphs that have been inserted.
97 * @return the number of new glyphs which have been inserted
101 le_int32
getGrowAmount();
104 * Call the <code>LEInsertionCallback</code> once for each
105 * entry on the insertion list.
107 * @param callback the <code>LEInsertionCallback</code> to call for each insertion.
109 * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
110 * terminate the insertion list processing.
114 le_bool
applyInsertions(LEInsertionCallback
*callback
);
117 * Empty the insertion list and free all associated
125 * ICU "poor man's RTTI", returns a UClassID for the actual class.
129 virtual UClassID
getDynamicClassID() const;
132 * ICU "poor man's RTTI", returns a UClassID for this class.
136 static UClassID
getStaticClassID();
141 * The head of the insertion list.
145 InsertionRecord
*head
;
148 * The tail of the insertion list.
152 InsertionRecord
*tail
;
155 * The total number of new glyphs on the insertion list.
162 * Set to <code>TRUE</code> if the glyphs are in right
163 * to left order. Since we want the rightmost insertion
164 * to be first on the list, we need to append the
165 * insertions in this case. Otherwise they're prepended.