1 #ifndef __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__
2 #define __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/common/intrusive-ptr.h>
24 #include <dali/public-api/object/ref-object.h>
27 #include <dali-toolkit/internal/text/bidirectional-line-info-run.h>
28 #include <dali-toolkit/internal/text/bidirectional-paragraph-info-run.h>
29 #include <dali-toolkit/internal/text/color-run.h>
30 #include <dali-toolkit/internal/text/font-run.h>
31 #include <dali-toolkit/internal/text/font-description-run.h>
32 #include <dali-toolkit/internal/text/paragraph-run.h>
33 #include <dali-toolkit/internal/text/script-run.h>
45 typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
49 * @brief A logical text model contains layout independent information.
52 * - A series of UTF-32 characters in logical order
54 class LogicalModel : public RefObject
59 * @brief Create a new instance of a LogicalModel.
61 * @return A pointer to a new LogicalModel.
63 static LogicalModelPtr New();
65 // Language support interface.
68 * @brief Retrieves the script for the given character index.
70 * @param[in] characterIndex Index to the character.
72 * @return The character's script.
74 Script GetScript( CharacterIndex characterIndex ) const;
76 // Bidirectional support interface.
79 * @brief Retrieves the direction of a characters.
81 * See GetCharacterDirections().
83 * @param[in] characterIndex Index to a character.
85 * @return The character's direction.
87 CharacterDirection GetCharacterDirection( CharacterIndex characterIndex ) const;
89 // Visual <--> Logical conversion tables.
92 * @brief Sets the visual to logical and the logical to visual map tables.
94 * Replaces any map tables previously set.
96 * @note If the number of runs is zero the bidirectional info buffer is cleared.
98 * @param[in] bidirectionalInfo Pointer to a buffer with all the bidirectional info runs.
99 * @param[in] numberOfRuns The number of bidirectional info runs.
100 * @param[in] startIndex Character index from where the conversion tables are set.
101 * @param[in] numberOfCharacters The number of characters.
103 void SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
105 CharacterIndex startIndex,
106 Length numberOfCharacters );
109 * @brief Retrieves the logical character index for the given visual character index.
111 * @param[in] visualCharacterIndex The visual character index.
113 * @return The logical character index.
115 CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
120 * @brief Updates the text's style runs with the added or removed text.
122 * @param[in] index The character's index.
123 * @param[in] numberOfCharacters The number of characters added or removed. If the value is negative the characters are removed.
125 void UpdateTextStyleRuns( CharacterIndex index, int numberOfCharacters );
128 * @brief Retrieves the text's style for the given character index.
130 * @param[in] index The character index.
131 * @param[out] style The text's style in the given style.
133 void RetrieveStyle( CharacterIndex index, InputStyle& style );
136 * @brief Clears the font description runs.
138 void ClearFontDescriptionRuns();
143 * @brief Creates the paragraph info.
145 * @pre The line break info must be set.
147 * @param[in] startIndex The character from where the paragraph info is set.
148 * @param[in] numberOfCharacters The number of characters.
150 void CreateParagraphInfo( CharacterIndex startIndex,
151 Length numberOfCharacters );
154 * @brief Find the paragraphs which contains the given characters.
156 * @param[in] index The first character's index of the run.
157 * @param[in] numberOfCharacters The number of characters of the run.
158 * @param[out] paragraphs Indices to the paragraphs which contain the characters.
160 void FindParagraphs( CharacterIndex index,
161 Length numberOfCharacters,
162 Vector<ParagraphRunIndex>& paragraphs );
167 * @brief A reference counted object may only be deleted by calling Unreference().
169 virtual ~LogicalModel();
174 * @brief Private constructor.
179 LogicalModel( const LogicalModel& handle );
182 LogicalModel& operator=( const LogicalModel& handle );
186 Vector<Character> mText;
187 Vector<ScriptRun> mScriptRuns;
188 Vector<FontRun> mFontRuns;
189 Vector<ColorRun> mColorRuns;
190 Vector<FontDescriptionRun> mFontDescriptionRuns;
191 Vector<LineBreakInfo> mLineBreakInfo;
192 Vector<WordBreakInfo> mWordBreakInfo;
193 Vector<ParagraphRun> mParagraphInfo;
194 Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
195 Vector<CharacterDirection> mCharacterDirections; ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ).
196 Vector<BidirectionalLineInfoRun> mBidirectionalLineInfo;
197 Vector<CharacterIndex> mLogicalToVisualMap; ///< Bidirectional logical to visual conversion table.
198 Vector<CharacterIndex> mVisualToLogicalMap; ///< Bidirectional visual to logical conversion table.
199 Vector<CharacterIndex> mVisualToLogicalCursorMap; ///< Bidirectional visual to logical cursor conversion table.
204 } // namespace Toolkit
208 #endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__