1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__
5 * Copyright (c) 2014 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-toolkit/internal/controls/text-input/text-input-text-style-impl.h>
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
34 class TextInputTextStyle;
37 * Class which contains functions related to the TextView.
38 * Functions which are needed by various parts of the TextInput to determine the position of characters.
39 * Functions to Set the TextView so text justification, alignment and wrapping behaviour in the desired manner for text input.
40 * The functionality of this class may be divided in future.
42 class TextViewCharacterPositioning
50 * @param[in] displayedTextView TextView to be used with this class.
51 * @param[in] textStyle TextInputTextStyle to be used
53 TextViewCharacterPositioning( Toolkit::TextView displayedTextView, TextInputTextStyle& textStyle ):mTextStyle( textStyle ){};
58 ~TextViewCharacterPositioning(){};
61 * @brief Creates the TextView to be used within this class.
63 void CreateTextView(){};
66 * @brief Get a handle to the current text view object
67 * If one does not exist then it's create.
70 Toolkit::TextView GetTextView() const{return Toolkit::TextView();};
73 * @brief Get the TextLayoutInfo from the TextView so know the updated positions of characters.
75 void UpdateTextLayoutInfo(){};
79 * @brief Get the TextLayoutInfo structure for the TextView
80 * @return the TextLayoutInfo structure
82 const Toolkit::TextView::TextLayoutInfo& GetLayoutInfo() const{return mTextLayoutInfo;};
86 * @brief Get the number of characters visually represented in the text
87 * @return the number of characters
89 std::size_t GetNumberOfCharactersInText() const{return 0;};
92 * @brief Check if any text exists in TextView's character layout table
93 * @return bool true if empty
95 bool IsTextEmpty() const{return false;};
98 * @brief Get the height of the line at the given cursor position
100 * @return float the height of the line
102 float GetLineHeight( std::size_t position ) const{return 0.0f;};
105 * @brief Sets if the inputed text can exceed the text-input boundary.
106 * By default is enabled.
107 * @param[in] enable Whether the inputed text can exceed its boundary.
109 void SetTextExceedEnabled( bool enable ) {};
112 * @brief Retrieves whether inputed text can exceed the text-input boundary.
113 * @return \e true if text inputed can exceed the boundary, otherwise \e false.
115 bool IsTextExceedEnabled() const{ return false;};
118 * @brief From the given x and y vector the closest character position is returned
119 * @param[in] source the x and y position
120 * @return the position in the string of the character closest to the source.
122 std::size_t ReturnClosestIndex( const Vector2& source ){return 0;};
125 * @brief If no text exists then this function uses the text alignment to position cursor.
126 * @param[in] cursorPosition
128 void GetActualPositionFromCharacterPositionWhenNoText( Vector3& cursorPosition ) const{};
131 * @brief Function to position cursor when a word is wrapped to another line
132 * @param[in] characterPosition that actual position is required for
133 * @return the actual position of the cursor.
135 Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const{return Vector3::ZERO;};
138 * @brief Returns the x-position of the current line justification
139 * (relative to left of text-view container)
140 * @return x position for line justification
142 float GetLineJustificationPosition() const{return 0.0f;};
145 * @brief Retrieve the dimensions (and min-max) of this row of text that the character resides on.
146 * @param[in] characterPosition the position in the 'string' of characters.
147 * @param[out] min the top-left position of the rectangle representing this row
148 * @param[out] max the bottom-right position of the rectangle representing this row
149 * @return The size of the rectangle representing this row (max - min)
151 Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const{return Vector2::ZERO;};
154 * @brief Retrieve the character position of the first character on the row of text
155 * that this character resides on.
156 * @param[in] logicalPosition the position in the 'string' of characters.
157 * @return logical character position of start of row.
159 std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const{return 0;};
162 * @brief Gets the visual position of a logical position.
163 * @note This is preferred over directly accessing the Map, as it resolves visual
164 * positions outside of the character map range.
165 * @param[in] logicalPosition The logical position
166 * @return Visual position is returned.
168 std::size_t GetVisualPosition(std::size_t logicalPosition) const{return 0;};
171 * @brief Return a vector which is the actual position for the given character position
172 * The character position is where a cursor would be position for that character.
173 * @param[in] characterPosition the logical (input) position in the 'string' of characters.
175 * @return Vector3 the actual x,y,z position
177 Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const{return Vector3::ZERO;};
180 * @brief Return a vector which is the actual position for the given character position
181 * The character position is where a cursor would be positioned for that character to be inserted.
182 * An additional alternatePosition is also set in circumstances where the possible writing
183 * of characters would be in the opposite direction.
184 * e.g. "HelloشقشلاهؤEnglish"
187 * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
188 * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
190 * @param[in] characterPosition the logical (input) position in the 'string' of characters.
191 * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
192 * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
193 * in alternate direction to current flow of text.
194 * @param[out] alternatePositionValid whether this alternate position is valid.
195 * @return Vector3 the actual x,y,z position
197 Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const{return Vector3::ZERO;};
200 * @brief Get the currently displayed text.
201 * @return The currently displayed text.
203 std::string GetText() const{return std::string();};
206 * @brief Get the text currently being displayed together with mark-up tags.
207 * @return string, the currently displayed string with mark-up.
209 std::string GetMarkupText() const{return std::string();};
212 * @brief Sets whether markup processing should be carried out.
214 * @param[in] enable whether markup processing is carried out or not.
216 void SetMarkupProcessingEnabled( bool enable ){};
219 * @brief Returns whether markup processing is enabled or not
221 * @return true is markup processing is enabled
223 bool IsMarkupProcessingEnabled() const{ return false;};
228 * @brief Check if styled text is empty
229 * @return bool returns true if styled text is empty
231 bool IsStyledTextEmpty() const{ return false;};
234 * @brief The size of the style text
235 * @return std::size_t returns number of characters in styled text
237 std::size_t StyledTextSize() const{return 0;};
240 * @brief Get the styled text array
241 * @return reference to MarkupProcessor::StyledTextArray
243 MarkupProcessor::StyledTextArray& GetStyledTextArray(){return mStyledText;};
246 * @brief Get the style for the character at the given position
247 * @param[in] position of character style is required for
248 * @return a copy of the style structure for the character at the given position
250 TextStyle GetStyleAt( std::size_t position ) const{return TextStyle();};
253 * @briefApplies the given style to all text, selected or not selected.
254 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
255 * @param[in] style style to apply
256 * @param[in] mask mask style should be applied to
257 * @param[in] begin start position of range to apply style
258 * @param[in] end end position of range to apply style
260 void ApplyStyleToRange( const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end ){};
264 * @copydoc TextView::SetSnapshotModeEnabled()
266 void SetSnapshotModeEnabled( bool enable ){};
269 * @copydoc TextView::IsSnapshotModeEnabled()
271 bool IsSnapshotModeEnabled() const{ return false;};
275 * @copydoc TextView::SetScrollEnabled()
277 void SetScrollEnabled( bool enable ){};
280 * @copydoc TextView::SetScrollPosition()
282 void SetScrollPosition( const Vector2& position ){};
285 * @copydoc TextView::IsScrollEnabled()
287 bool IsScrollEnabled() const{ return false;};
290 * @copydoc TextView::GetScrollPosition()
292 Vector2 GetScrollPosition() const{return Vector2::ZERO;};
295 * @copydoc TextView::GetScrollPosition()
297 bool IsScrollPositionTrimmed() const{ return false;};
302 * @brief Copy Constructor
303 * @param[in] characterPositioning
306 TextViewCharacterPositioning(const TextViewCharacterPositioning& characterPositioning );
309 * @Assignment Constructor
313 TextViewCharacterPositioning& operator=(const TextViewCharacterPositioning& rhs);
317 Toolkit::TextView mDisplayedTextView; // A text view object used to display the text.
318 TextInputTextStyle& mTextStyle; // Holds the style object related to input style
320 MarkupProcessor::StyledTextArray mStyledText; // String currently displayed by TextView with style info.
322 Toolkit::TextView::TextLayoutInfo mTextLayoutInfo; // It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
323 // a reorder map that stores each character's visual (output) index according to its logical (input) index,
324 // a reorder map that stores each character's logical (input) index according to its visual (output) index
326 bool mExceedEnabled:1; // flag set by user to determine if text can exceed the control's size
327 bool mMarkUpEnabled:1; // If Markup is being passed with the text
331 } // namespace Internal
334 } // namespace Toolkit
338 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__