Update keyboard focus direction enum for Control
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support-impl.h
1 #ifndef __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__
2 #define __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_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/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/multi-language-support.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Text
34 {
35
36 namespace Internal
37 {
38
39 /**
40  * @brief Stores valid font ids per script.
41  */
42 struct ValidateFontsPerScript
43 {
44   /**
45    * Default constructor.
46    */
47   ValidateFontsPerScript()
48   : mValidFonts()
49   {}
50
51   /**
52    * Default destructor.
53    */
54   ~ValidateFontsPerScript()
55   {}
56
57   /**
58    * @brief Whether the given @p fontId is in the vector of valid fonts.
59    *
60    * @param[in] fontId The font id.
61    *
62    * @return @e true if the font is in the vector of valid fonts.
63    */
64   bool FindValidFont( FontId fontId ) const;
65
66   Vector<FontId> mValidFonts;
67 };
68
69 /**
70  * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
71  */
72 class MultilanguageSupport : public BaseObject
73 {
74 public:
75
76   /**
77    * Constructor
78    */
79   MultilanguageSupport();
80
81   /**
82    * Destructor
83    *
84    * This is non-virtual since derived Handle types must not contain data or virtual methods.
85    */
86   ~MultilanguageSupport();
87
88   /**
89    * @copydoc Dali::MultilanguageSupport::Get()
90    */
91   static Text::MultilanguageSupport Get();
92
93   /**
94    * @copydoc Dali::MultilanguageSupport::SetScripts()
95    */
96   void SetScripts( const Vector<Character>& text,
97                    const Vector<LineBreakInfo>& lineBreakInfo,
98                    Vector<ScriptRun>& scripts );
99
100   /**
101    * @copydoc Dali::MultilanguageSupport::ReplaceScripts()
102    */
103   void ReplaceScripts( LogicalModel& model,
104                        CharacterIndex characterIndex,
105                        Length numberOfCharactersToRemove,
106                        Length numberOfCharactersToInsert );
107
108   /**
109    * @copydoc Dali::MultilanguageSupport::ValidateFonts( const Vector<Character>& text, const Vector<ScriptRun>& scripts, Vector<FontRun>& fonts )
110    */
111   void ValidateFonts( const Vector<Character>& text,
112                       const Vector<ScriptRun>& scripts,
113                       Vector<FontRun>& fonts );
114
115   /**
116    * @copydoc Dali::MultilanguageSupport::ValidateFonts( LogicalModel& model, CharacterIndex characterIndex, Length numberOfCharactersToRemove, Length numberOfCharactersToInsert )
117    */
118   void ValidateFonts( LogicalModel& model,
119                       CharacterIndex characterIndex,
120                       Length numberOfCharactersToRemove,
121                       Length numberOfCharactersToInsert );
122 private:
123   Vector<FontId>                  mDefaultFontPerScriptCache; ///< Caches the default font for a script.
124   Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache;  ///< Caches valid fonts for a script.
125 };
126
127 } // namespace Internal
128
129 inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport )
130 {
131   DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
132   BaseObject& handle = multilanguageSupport.GetBaseObject();
133   return static_cast<Internal::MultilanguageSupport&>( handle );
134 }
135
136 inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport )
137 {
138   DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
139   const BaseObject& handle = multilanguageSupport.GetBaseObject();
140   return static_cast<const Internal::MultilanguageSupport&>( handle );
141 }
142
143 } // namespace Text
144
145 } // namespace Toolkit
146
147 } // namespace Dali
148
149 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__