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