1 #ifndef __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__
2 #define __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_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/intrusive-ptr.h>
25 #include <dali-toolkit/public-api/text/text-definitions.h>
38 typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
42 * @brief A logical text model contains layout independent information.
45 * - A series of UTF-32 characters in logical order
47 class LogicalModel : public RefObject
52 * @brief Create a new instance of a LogicalModel.
54 * @return A pointer to a new LogicalModel.
56 static LogicalModelPtr New();
61 * @brief Replaces any text previously set.
63 * @param[in] text An array of UTF-32 characters.
64 * @param[in] length The length of the array.
66 void SetText( const Character* text,
70 * @brief Retrieves the number of characters of the text.
72 * @return The number of characters.
74 Length GetNumberOfCharacters() const;
77 * @brief Retrieves characters from the text in the given buffer.
79 * @pre The size of the @p text buffer needs to be big enough to copy the @p numberOfCharacters.
80 * @param[in] characterIndex The index to the first character to copy.
81 * @param[out] text Pointer to a buffer where the text is copied.
82 * @param[in] numberOfCharacters The number of characters to be copied.
84 void GetText( CharacterIndex characterIndex,
86 Length numberOfCharacters ) const;
88 // Language support interface.
91 * Sets the script runs.
93 * Replaces any scripts previously set.
95 * A run is a group of consecutive characters. A script run contains the script for a run.
97 * @param[in] scripts Pointer to a buffer with all the script runs.
98 * @param[in] numberOfRuns The number of script runs.
100 void SetScripts( const ScriptRun* const scripts,
101 Length numberOfRuns );
104 * Retrieves the number of script runs for the given range of characters.
106 * A run is a group of consecutive characters. A script run contains the script for a run.
108 * @param[in] characterIndex Index to the first character.
109 * @param[in] numberOfCharacters The number of characters.
111 * @return The number of script runs.
113 Length GetNumberOfScriptRuns( CharacterIndex characterIndex,
114 Length numberOfCharacters ) const;
117 * Retrieves the script runs for the given range of characters.
119 * The @p scriptRuns buffer needs to be big enough to copy the number of script runs.
120 * Call GetNumberOfScriptRuns() to retrieve the number of script runs.
122 * @param[out] scriptRuns Pointer to a buffer where the script runs are copied.
123 * @param[in] characterIndex Index to the first character.
124 * @param[in] numberOfCharacters The number of characters.
126 void GetScriptRuns( ScriptRun* scriptRuns,
127 CharacterIndex characterIndex,
128 Length numberOfCharacters ) const;
131 * Retrieves the script for the given character index.
133 * @param[in] characterIndex Index to the character.
135 * @return The character's script.
137 Script GetScript( CharacterIndex characterIndex ) const;
140 * Sets the font runs.
142 * Replaces any fonts previously set.
144 * A run is a group of consecutive characters. A font run contains the font id for a run.
146 * @param[in] fonts Pointer to a buffer with all the font runs.
147 * @param[in] numberOfRuns The number of font runs.
149 void SetFonts( const FontRun* const fonts,
150 Length numberOfRuns );
153 * Retrieves the number of font runs for the given range of characters.
155 * A run is a group of consecutive characters. A font run contains the font id for a run.
157 * @param[in] characterIndex Index to the first character.
158 * @param[in] numberOfCharacters The number of characters.
160 * @return The number of font runs.
162 Length GetNumberOfFontRuns( CharacterIndex characterIndex,
163 Length numberOfCharacters ) const;
166 * Retrieves the font runs for the given range of characters.
168 * The @p fontRuns buffer needs to be big enough to copy the number of font runs.
169 * Call GetNumberOfFontRuns() to retrieve the number of font runs.
171 * @param[out] fontRuns Pointer to a buffer where the font runs are copied.
172 * @param[in] characterIndex Index to the first character.
173 * @param[in] numberOfCharacters The number of characters.
175 void GetFontRuns( FontRun* fontRuns,
176 CharacterIndex characterIndex,
177 Length numberOfCharacters ) const;
180 * Retrieves the font id for the given character index.
182 * @param[in] characterIndex Index to the first character.
184 * @return The font id.
186 FontId GetFont( CharacterIndex characterIndex ) const;
191 * @brief A reference counted object may only be deleted by calling Unreference().
193 virtual ~LogicalModel();
198 * @brief Private constructor.
203 LogicalModel( const LogicalModel& handle );
206 LogicalModel& operator=( const LogicalModel& handle );
216 } // namespace Toolkit
220 #endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__