Merge "Fix for selection handles." into devel/master
[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 struct BidirectionalLineInfoRun;
42 struct BidirectionalParagraphInfoRun;
43 struct FontRun;
44 class LogicalModel;
45 typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
46 struct ScriptRun;
47
48 /**
49  * @brief A logical text model contains layout independent information.
50  *
51  * This includes:
52  * - A series of UTF-32 characters in logical order
53  */
54 class LogicalModel : public RefObject
55 {
56 public:
57
58   /**
59    * @brief Create a new instance of a LogicalModel.
60    *
61    * @return A pointer to a new LogicalModel.
62    */
63   static LogicalModelPtr New();
64
65   // Language support interface.
66
67   /**
68    * @brief Retrieves the script for the given character index.
69    *
70    * @param[in] characterIndex Index to the character.
71    *
72    * @return The character's script.
73    */
74   Script GetScript( CharacterIndex characterIndex ) const;
75
76   // Bidirectional support interface.
77
78   /**
79    * @brief Retrieves the direction of a characters.
80    *
81    * See GetCharacterDirections().
82    *
83    * @param[in] characterIndex Index to a character.
84    *
85    * @return The character's direction.
86    */
87   CharacterDirection GetCharacterDirection( CharacterIndex characterIndex ) const;
88
89   // Visual <--> Logical conversion tables.
90
91   /**
92    * @brief Sets the visual to logical and the logical to visual map tables.
93    *
94    * Replaces any map tables previously set.
95    *
96    * @note If the number of runs is zero the bidirectional info buffer is cleared.
97    *
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    */
101   void SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
102                               Length numberOfRuns );
103
104   /**
105    * @brief Retrieves the logical character index for the given visual character index.
106    *
107    * @param[in] visualCharacterIndex The visual character index.
108    *
109    * @return The logical character index.
110    */
111   CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
112
113 protected:
114
115   /**
116    * @brief A reference counted object may only be deleted by calling Unreference().
117    */
118   virtual ~LogicalModel();
119
120 private:
121
122   /**
123    * @brief Private constructor.
124    */
125   LogicalModel();
126
127   // Undefined
128   LogicalModel( const LogicalModel& handle );
129
130   // Undefined
131   LogicalModel& operator=( const LogicalModel& handle );
132
133 public:
134
135   Vector<Character>                     mText;
136   Vector<ScriptRun>                     mScriptRuns;
137   Vector<FontRun>                       mFontRuns;
138   Vector<LineBreakInfo>                 mLineBreakInfo;
139   Vector<WordBreakInfo>                 mWordBreakInfo;
140   Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
141   Vector<CharacterDirection>            mCharacterDirections;        ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ).
142   Vector<BidirectionalLineInfoRun>      mBidirectionalLineInfo;
143   Vector<CharacterIndex>                mLogicalToVisualMap;         ///< Bidirectional logical to visual conversion table.
144   Vector<CharacterIndex>                mVisualToLogicalMap;         ///< Bidirectional visual to logical conversion table.
145   Vector<CharacterIndex>                mVisualToLogicalCursorMap;   ///< Bidirectional visual to logical cursor conversion table.
146 };
147
148 } // namespace Text
149
150 } // namespace Toolkit
151
152 } // namespace Dali
153
154 #endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__