Underline predictive text after updating the model.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / logical-model-impl.h
1 #ifndef __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__
2 #define __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
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>
25
26 // INTERNAL INCLUDES
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/font-run.h>
30 #include <dali-toolkit/internal/text/script-run.h>
31
32 namespace Dali
33 {
34
35 namespace Toolkit
36 {
37
38 namespace Text
39 {
40
41 class LogicalModel;
42 typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
43
44 /**
45  * @brief A logical text model contains layout independent information.
46  *
47  * This includes:
48  * - A series of UTF-32 characters in logical order
49  */
50 class LogicalModel : public RefObject
51 {
52 public:
53
54   /**
55    * @brief Create a new instance of a LogicalModel.
56    *
57    * @return A pointer to a new LogicalModel.
58    */
59   static LogicalModelPtr New();
60
61   // Language support interface.
62
63   /**
64    * @brief Retrieves the script for the given character index.
65    *
66    * @param[in] characterIndex Index to the character.
67    *
68    * @return The character's script.
69    */
70   Script GetScript( CharacterIndex characterIndex ) const;
71
72   // Bidirectional support interface.
73
74   /**
75    * @brief Retrieves the direction of a characters.
76    *
77    * See GetCharacterDirections().
78    *
79    * @param[in] characterIndex Index to a character.
80    *
81    * @return The character's direction.
82    */
83   CharacterDirection GetCharacterDirection( CharacterIndex characterIndex ) const;
84
85   // Visual <--> Logical conversion tables.
86
87   /**
88    * @brief Sets the visual to logical and the logical to visual map tables.
89    *
90    * Replaces any map tables previously set.
91    *
92    * @note If the number of runs is zero the bidirectional info buffer is cleared.
93    *
94    * @param[in] bidirectionalInfo Pointer to a buffer with all the bidirectional info runs.
95    * @param[in] numberOfRuns The number of bidirectional info runs.
96    */
97   void SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
98                               Length numberOfRuns );
99
100   /**
101    * @brief Retrieves the logical character index for the given visual character index.
102    *
103    * @param[in] visualCharacterIndex The visual character index.
104    *
105    * @return The logical character index.
106    */
107   CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
108
109 protected:
110
111   /**
112    * @brief A reference counted object may only be deleted by calling Unreference().
113    */
114   virtual ~LogicalModel();
115
116 private:
117
118   /**
119    * @brief Private constructor.
120    */
121   LogicalModel();
122
123   // Undefined
124   LogicalModel( const LogicalModel& handle );
125
126   // Undefined
127   LogicalModel& operator=( const LogicalModel& handle );
128
129 public:
130
131   Vector<Character>                     mText;
132   Vector<ScriptRun>                     mScriptRuns;
133   Vector<FontRun>                       mFontRuns;
134   Vector<LineBreakInfo>                 mLineBreakInfo;
135   Vector<WordBreakInfo>                 mWordBreakInfo;
136   Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
137   Vector<CharacterDirection>            mCharacterDirections;        ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ).
138   Vector<BidirectionalLineInfoRun>      mBidirectionalLineInfo;
139   Vector<CharacterIndex>                mLogicalToVisualMap;         ///< Bidirectional logical to visual conversion table.
140   Vector<CharacterIndex>                mVisualToLogicalMap;         ///< Bidirectional visual to logical conversion table.
141   Vector<CharacterIndex>                mVisualToLogicalCursorMap;   ///< Bidirectional visual to logical cursor conversion table.
142 };
143
144 } // namespace Text
145
146 } // namespace Toolkit
147
148 } // namespace Dali
149
150 #endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__