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;
188 // Break info interface.
191 * Sets the line break info.
193 * See GetLineBreakInfo() to get how the line break info is encoded.
195 * Replaces any line break info previously set.
197 * @param[in] lineBreakInfo Pointer to a buffer with the line break info.
198 * @param[in] length The size of the buffer.
200 void SetLineBreakInfo( const LineBreakInfo* const lineBreakInfo,
204 * Retrieves the line break info in the given buffer.
206 * The size of the @p lineBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
208 * Possible values for LineBreakInfo are:
210 * - 0 is a LINE_MUST_BREAK. Text must be broken into a new line.
211 * - 1 is a LINE_ALLOW_BREAK. Is possible to break the text into a new line.
212 * - 2 is a LINE_NO_BREAK. Text can't be broken into a new line.
215 i.e. Hello big\nworld produces:
219 * @param[out] lineBreakInfo Pointer to a buffer where the line break info is copied.
220 * @param[in] characterIndex Index to the first line break info item.
221 * @param[in] numberOfItems The number of items to be copied.
223 void GetLineBreakInfo( LineBreakInfo* lineBreakInfo,
224 CharacterIndex characterIndex,
225 Length numberOfItems ) const;
228 * Retrieves the line break info for the given item index.
230 * @param[in] characterIndex Index to the line break info item.
232 LineBreakInfo GetLineBreakInfo( CharacterIndex characterIndex ) const;
235 * Sets the word break info.
237 * See GetWordBreakInfo() to get how the word break info is encoded.
239 * Replaces any word break info previously set.
241 * @param[in] wordBreakInfo Pointer to a buffer with the word break info.
242 * @param[in] length The size of the buffer.
244 void SetWordBreakInfo( const WordBreakInfo* const wordBreakInfo,
248 * Retrieves the word break info in the given buffer.
250 * The size of the @p wordBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
252 * The size of the buffer has to be big enough to store the whole word break info per character.
253 * Call GetNumberOfCharacters() to get the number of characters.
255 * Possible values for WordBreakInfo are:
257 * - 0 is a WORD_BREAK. Text can be broken into a new word.
258 * - 1 is a WORD_NO_BREAK. Text can't be broken into a new word.
261 i.e. Hello big\nworld produces:
265 * @param[out] wordBreakInfo Pointer to a buffer where the word break info is copied.
266 * @param[in] characterIndex Index to the first word break info item.
267 * @param[in] numberOfItems The number of items to be copied.
269 void GetWordBreakInfo( WordBreakInfo* wordBreakInfo,
270 CharacterIndex characterIndex,
271 Length numberOfItems ) const;
274 * Retrieves the word break info for the given item index.
276 * @param[in] characterIndex Index to the word break info item.
278 WordBreakInfo GetWordBreakInfo( CharacterIndex characterIndex ) const;
283 * @brief A reference counted object may only be deleted by calling Unreference().
285 virtual ~LogicalModel();
290 * @brief Private constructor.
295 LogicalModel( const LogicalModel& handle );
298 LogicalModel& operator=( const LogicalModel& handle );
308 } // namespace Toolkit
312 #endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__