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>
25 #include <dali/dali.h>
26 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
37 class TextInputTextStyle;
40 * Class which contains functions related to the TextView.
41 * Functions which are needed by various parts of the TextInput to determine the position of characters.
42 * Functions to Set the TextView so text justification, alignment and wrapping behaviour in the desired manner for text input.
43 * The functionality of this class may be divided in future.
45 class TextViewCharacterPositioning
53 * @param[in] displayedTextView TextView to be used with this class.
54 * @param[in] textStyle TextInputTextStyle to be used
56 TextViewCharacterPositioning( Toolkit::TextView displayedTextView, TextInputTextStyle& textStyle ):mTextStyle( textStyle ){};
61 ~TextViewCharacterPositioning(){};
64 * @brief Creates the TextView to be used within this class.
66 void CreateTextView(){};
69 * @brief Get a handle to the current text view object
70 * If one does not exist then it's create.
73 Toolkit::TextView GetTextView() const{return Toolkit::TextView();};
76 * @brief Get the TextLayoutInfo from the TextView so know the updated positions of characters.
78 void UpdateTextLayoutInfo(){};
82 * @brief Get the TextLayoutInfo structure for the TextView
83 * @return the TextLayoutInfo structure
85 const Toolkit::TextView::TextLayoutInfo& GetLayoutInfo() const{return mTextLayoutInfo;};
89 * @brief Get the number of characters visually represented in the text
90 * @return the number of characters
92 std::size_t GetNumberOfCharactersInText() const{return 0;};
95 * @brief Check if any text exists in TextView's character layout table
96 * @return bool true if empty
98 bool IsTextEmpty() const{return false;};
101 * @brief Get the height of the line at the given cursor position
102 * @param[in] position
103 * @return float the height of the line
105 float GetLineHeight( std::size_t position ) const{return 0.0f;};
108 * @brief Sets if the inputed text can exceed the text-input boundary.
109 * By default is enabled.
110 * @param[in] enable Whether the inputed text can exceed its boundary.
112 void SetTextExceedEnabled( bool enable ) {};
115 * @brief Retrieves whether inputed text can exceed the text-input boundary.
116 * @return \e true if text inputed can exceed the boundary, otherwise \e false.
118 bool IsTextExceedEnabled() const{ return false;};
121 * @brief From the given x and y vector the closest character position is returned
122 * @param[in] source the x and y position
123 * @return the position in the string of the character closest to the source.
125 std::size_t ReturnClosestIndex( const Vector2& source ){return 0;};
128 * @brief If no text exists then this function uses the text alignment to position cursor.
129 * @param[in] cursorPosition
131 void GetActualPositionFromCharacterPositionWhenNoText( Vector3& cursorPosition ) const{};
134 * @brief Function to position cursor when a word is wrapped to another line
135 * @param[in] characterPosition that actual position is required for
136 * @return the actual position of the cursor.
138 Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const{return Vector3::ZERO;};
141 * @brief Returns the x-position of the current line justification
142 * (relative to left of text-view container)
143 * @return x position for line justification
145 float GetLineJustificationPosition() const{return 0.0f;};
148 * @brief Retrieve the dimensions (and min-max) of this row of text that the character resides on.
149 * @param[in] characterPosition the position in the 'string' of characters.
150 * @param[out] min the top-left position of the rectangle representing this row
151 * @param[out] max the bottom-right position of the rectangle representing this row
152 * @return The size of the rectangle representing this row (max - min)
154 Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const{return Vector2::ZERO;};
157 * @brief Retrieve the character position of the first character on the row of text
158 * that this character resides on.
159 * @param[in] logicalPosition the position in the 'string' of characters.
160 * @return logical character position of start of row.
162 std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const{return 0;};
165 * @brief Gets the visual position of a logical position.
166 * @note This is preferred over directly accessing the Map, as it resolves visual
167 * positions outside of the character map range.
168 * @param[in] logicalPosition The logical position
169 * @return Visual position is returned.
171 std::size_t GetVisualPosition(std::size_t logicalPosition) const{return 0;};
174 * @brief Return a vector which is the actual position for the given character position
175 * The character position is where a cursor would be position for that character.
176 * @param[in] characterPosition the logical (input) position in the 'string' of characters.
178 * @return Vector3 the actual x,y,z position
180 Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const{return Vector3::ZERO;};
183 * @brief Return a vector which is the actual position for the given character position
184 * The character position is where a cursor would be positioned for that character to be inserted.
185 * An additional alternatePosition is also set in circumstances where the possible writing
186 * of characters would be in the opposite direction.
187 * e.g. "HelloشقشلاهؤEnglish"
190 * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
191 * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
193 * @param[in] characterPosition the logical (input) position in the 'string' of characters.
194 * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
195 * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
196 * in alternate direction to current flow of text.
197 * @param[out] alternatePositionValid whether this alternate position is valid.
198 * @return Vector3 the actual x,y,z position
200 Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const{return Vector3::ZERO;};
203 * @brief Get the currently displayed text.
204 * @return The currently displayed text.
206 std::string GetText() const{return std::string();};
209 * @brief Get the text currently being displayed together with mark-up tags.
210 * @return string, the currently displayed string with mark-up.
212 std::string GetMarkupText() const{return std::string();};
215 * @brief Sets whether markup processing should be carried out.
217 * @param[in] enable whether markup processing is carried out or not.
219 void SetMarkupProcessingEnabled( bool enable ){};
222 * @brief Returns whether markup processing is enabled or not
224 * @return true is markup processing is enabled
226 bool IsMarkupProcessingEnabled() const{ return false;};
231 * @brief Check if styled text is empty
232 * @return bool returns true if styled text is empty
234 bool IsStyledTextEmpty() const{ return false;};
237 * @brief The size of the style text
238 * @return std::size_t returns number of characters in styled text
240 std::size_t StyledTextSize() const{return 0;};
243 * @brief Get the styled text array
244 * @return reference to MarkupProcessor::StyledTextArray
246 MarkupProcessor::StyledTextArray& GetStyledTextArray(){return mStyledText;};
249 * @brief Get the style for the character at the given position
250 * @param[in] position of character style is required for
251 * @return a copy of the style structure for the character at the given position
253 TextStyle GetStyleAt( std::size_t position ) const{return TextStyle();};
256 * @briefApplies the given style to all text, selected or not selected.
257 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
258 * @param[in] style style to apply
259 * @param[in] mask mask style should be applied to
260 * @param[in] begin start position of range to apply style
261 * @param[in] end end position of range to apply style
263 void ApplyStyleToRange( const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end ){};
267 * @copydoc TextView::SetSnapshotModeEnabled()
269 void SetSnapshotModeEnabled( bool enable ){};
272 * @copydoc TextView::IsSnapshotModeEnabled()
274 bool IsSnapshotModeEnabled() const{ return false;};
278 * @copydoc TextView::SetScrollEnabled()
280 void SetScrollEnabled( bool enable ){};
283 * @copydoc TextView::SetScrollPosition()
285 void SetScrollPosition( const Vector2& position ){};
288 * @copydoc TextView::IsScrollEnabled()
290 bool IsScrollEnabled() const{ return false;};
293 * @copydoc TextView::GetScrollPosition()
295 Vector2 GetScrollPosition() const{return Vector2::ZERO;};
298 * @copydoc TextView::GetScrollPosition()
300 bool IsScrollPositionTrimmed() const{ return false;};
305 * @brief Copy Constructor
306 * @param[in] characterPositioning
309 TextViewCharacterPositioning(const TextViewCharacterPositioning& characterPositioning );
312 * @Assignment Constructor
316 TextViewCharacterPositioning& operator=(const TextViewCharacterPositioning& rhs);
320 Toolkit::TextView mDisplayedTextView; // A text view object used to display the text.
321 TextInputTextStyle& mTextStyle; // Holds the style object related to input style
323 MarkupProcessor::StyledTextArray mStyledText; // String currently displayed by TextView with style info.
325 Toolkit::TextView::TextLayoutInfo mTextLayoutInfo; // It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
326 // a reorder map that stores each character's visual (output) index according to its logical (input) index,
327 // a reorder map that stores each character's logical (input) index according to its visual (output) index
329 bool mExceedEnabled:1; // flag set by user to determine if text can exceed the control's size
330 bool mMarkUpEnabled:1; // If Markup is being passed with the text
334 } // namespace Internal
337 } // namespace Toolkit
341 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_TEXTVIEW_CHARACTER_POSITIONS_H__