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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali-toolkit/internal/controls/text-input/text-input-text-style-impl.h>
24 #include <dali/dali.h>
25 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
36 class TextInputTextStyle;
39 * Class which contains functions related to the TextView.
40 * Functions which are needed by various parts of the TextInput to determine the position of characters.
41 * Functions to Set the TextView so text justification, alignment and wrapping behaviour in the desired manner for text input.
42 * The functionality of this class may be divided in future.
44 class TextViewCharacterPositioning
52 * @param[in] displayedTextView TextView to be used with this class.
53 * @param[in] textStyle TextInputTextStyle to be used
55 TextViewCharacterPositioning( Toolkit::TextView displayedTextView, TextInputTextStyle& textStyle ):mTextStyle( textStyle ){};
60 ~TextViewCharacterPositioning(){};
63 * @brief Creates the TextView to be used within this class.
65 void CreateTextView(){};
68 * @brief Get a handle to the current text view object
69 * If one does not exist then it's create.
72 Toolkit::TextView GetTextView() const{return Toolkit::TextView();};
75 * @brief Get the TextLayoutInfo from the TextView so know the updated positions of characters.
77 void UpdateTextLayoutInfo(){};
81 * @brief Get the TextLayoutInfo structure for the TextView
82 * @return the TextLayoutInfo structure
84 const Toolkit::TextView::TextLayoutInfo& GetLayoutInfo() const{return mTextLayoutInfo;};
88 * @brief Get the number of characters visually represented in the text
89 * @return the number of characters
91 std::size_t GetNumberOfCharactersInText() const{return 0;};
94 * @brief Check if any text exists in TextView's character layout table
95 * @return bool true if empty
97 bool IsTextEmpty() const{return false;};
100 * @brief Get the height of the line at the given cursor position
101 * @param[in] position
102 * @return float the height of the line
104 float GetLineHeight( std::size_t position ) const{return 0.0f;};
107 * @brief Sets if the inputed text can exceed the text-input boundary.
108 * By default is enabled.
109 * @param[in] enable Whether the inputed text can exceed its boundary.
111 void SetTextExceedEnabled( bool enable ) {};
114 * @brief Retrieves whether inputed text can exceed the text-input boundary.
115 * @return \e true if text inputed can exceed the boundary, otherwise \e false.
117 bool IsTextExceedEnabled() const{ return false;};
120 * @brief From the given x and y vector the closest character position is returned
121 * @param[in] source the x and y position
122 * @return the position in the string of the character closest to the source.
124 std::size_t ReturnClosestIndex( const Vector2& source ){return 0;};
127 * @brief If no text exists then this function uses the text alignment to position cursor.
128 * @param[in] cursorPosition
130 void GetActualPositionFromCharacterPositionWhenNoText( Vector3& cursorPosition ) const{};
133 * @brief Function to position cursor when a word is wrapped to another line
134 * @param[in] characterPosition that actual position is required for
135 * @return the actual position of the cursor.
137 Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const{return Vector3::ZERO;};
140 * @brief Returns the x-position of the current line justification
141 * (relative to left of text-view container)
142 * @return x position for line justification
144 float GetLineJustificationPosition() const{return 0.0f;};
147 * @brief Retrieve the dimensions (and min-max) of this row of text that the character resides on.
148 * @param[in] characterPosition the position in the 'string' of characters.
149 * @param[out] min the top-left position of the rectangle representing this row
150 * @param[out] max the bottom-right position of the rectangle representing this row
151 * @return The size of the rectangle representing this row (max - min)
153 Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const{return Vector2::ZERO;};
156 * @brief Retrieve the character position of the first character on the row of text
157 * that this character resides on.
158 * @param[in] logicalPosition the position in the 'string' of characters.
159 * @return logical character position of start of row.
161 std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const{return 0;};
164 * @brief Gets the visual position of a logical position.
165 * @note This is preferred over directly accessing the Map, as it resolves visual
166 * positions outside of the character map range.
167 * @param[in] logicalPosition The logical position
168 * @return Visual position is returned.
170 std::size_t GetVisualPosition(std::size_t logicalPosition) const{return 0;};
173 * @brief Return a vector which is the actual position for the given character position
174 * The character position is where a cursor would be position for that character.
175 * @param[in] characterPosition the logical (input) position in the 'string' of characters.
177 * @return Vector3 the actual x,y,z position
179 Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const{return Vector3::ZERO;};
182 * @brief Return a vector which is the actual position for the given character position
183 * The character position is where a cursor would be positioned for that character to be inserted.
184 * An additional alternatePosition is also set in circumstances where the possible writing
185 * of characters would be in the opposite direction.
186 * e.g. "HelloشقشلاهؤEnglish"
189 * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
190 * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
192 * @param[in] characterPosition the logical (input) position in the 'string' of characters.
193 * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
194 * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
195 * in alternate direction to current flow of text.
196 * @param[out] alternatePositionValid whether this alternate position is valid.
197 * @return Vector3 the actual x,y,z position
199 Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const{return Vector3::ZERO;};
202 * @brief Get the currently displayed text.
203 * @return The currently displayed text.
205 std::string GetText() const{return std::string();};
208 * @brief Get the text currently being displayed together with mark-up tags.
209 * @return string, the currently displayed string with mark-up.
211 std::string GetMarkupText() const{return std::string();};
214 * @brief Sets whether markup processing should be carried out.
216 * @param[in] enable whether markup processing is carried out or not.
218 void SetMarkupProcessingEnabled( bool enable ){};
221 * @brief Returns whether markup processing is enabled or not
223 * @return true is markup processing is enabled
225 bool IsMarkupProcessingEnabled() const{ return false;};
230 * @brief Check if styled text is empty
231 * @return bool returns true if styled text is empty
233 bool IsStyledTextEmpty() const{ return false;};
236 * @brief The size of the style text
237 * @return std::size_t returns number of characters in styled text
239 std::size_t StyledTextSize() const{return 0;};
242 * @brief Get the styled text array
243 * @return reference to MarkupProcessor::StyledTextArray
245 MarkupProcessor::StyledTextArray& GetStyledTextArray(){return mStyledText;};
248 * @brief Get the style for the character at the given position
249 * @param[in] position of character style is required for
250 * @return a copy of the style structure for the character at the given position
252 TextStyle GetStyleAt( std::size_t position ) const{return TextStyle();};
255 * @briefApplies the given style to all text, selected or not selected.
256 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
257 * @param[in] style style to apply
258 * @param[in] mask mask style should be applied to
259 * @param[in] begin start position of range to apply style
260 * @param[in] end end position of range to apply style
262 void ApplyStyleToRange( const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end ){};
266 * @copydoc TextView::SetSnapshotModeEnabled()
268 void SetSnapshotModeEnabled( bool enable ){};
271 * @copydoc TextView::IsSnapshotModeEnabled()
273 bool IsSnapshotModeEnabled() const{ return false;};
277 * @copydoc TextView::SetScrollEnabled()
279 void SetScrollEnabled( bool enable ){};
282 * @copydoc TextView::SetScrollPosition()
284 void SetScrollPosition( const Vector2& position ){};
287 * @copydoc TextView::IsScrollEnabled()
289 bool IsScrollEnabled() const{ return false;};
292 * @copydoc TextView::GetScrollPosition()
294 Vector2 GetScrollPosition() const{return Vector2::ZERO;};
297 * @copydoc TextView::GetScrollPosition()
299 bool IsScrollPositionTrimmed() const{ return false;};
304 * @brief Copy Constructor
305 * @param[in] characterPositioning
308 TextViewCharacterPositioning(const TextViewCharacterPositioning& characterPositioning );
311 * @Assignment Constructor
315 TextViewCharacterPositioning& operator=(const TextViewCharacterPositioning& rhs);
319 Toolkit::TextView mDisplayedTextView; // A text view object used to display the text.
320 TextInputTextStyle& mTextStyle; // Holds the style object related to input style
322 MarkupProcessor::StyledTextArray mStyledText; // String currently displayed by TextView with style info.
324 Toolkit::TextView::TextLayoutInfo mTextLayoutInfo; // It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
325 // a reorder map that stores each character's visual (output) index according to its logical (input) index,
326 // a reorder map that stores each character's logical (input) index according to its visual (output) index
328 bool mExceedEnabled:1; // flag set by user to determine if text can exceed the control's size
329 bool mMarkUpEnabled:1; // If Markup is being passed with the text
333 } // namespace Internal
336 } // namespace Toolkit
340 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__