1 #ifndef __DALI_TOOLKIT_TEXT_DECORATOR_H__
2 #define __DALI_TOOLKIT_TEXT_DECORATOR_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>
23 #include <dali/public-api/object/ref-object.h>
44 typedef IntrusivePtr<Decorator> DecoratorPtr;
46 // Used to set the cursor positions etc.
49 PRIMARY_CURSOR, ///< The primary cursor for bidirectional text (or the regular cursor for single-direction text)
50 SECONDARY_CURSOR, ///< The secondary cursor for bidirectional text
54 // Determines which of the cursors are active (if any).
57 ACTIVE_CURSOR_NONE, ///< Neither primary nor secondary cursor are active
58 ACTIVE_CURSOR_PRIMARY, ///< Primary cursor is active (only)
59 ACTIVE_CURSOR_BOTH ///< Both primary and secondary cursor are active
63 * @brief A Text Decorator is used to display cursors, handles, selection highlights and pop-ups.
65 * The decorator is responsible for clipping decorations which are positioned outside of the parent area.
66 * In some cases the decorations will be moved or flipped around, to maintain visibility on-screen.
68 class Decorator : public RefObject
73 * @brief Create a new instance of a Decorator.
75 * @param[in] parent Decorations will be added to this parent control.
76 * @return A pointer to a new Decorator.
78 static DecoratorPtr New( Dali::Toolkit::Internal::Control& parent );
81 * @brief The decorator waits until a relayout before creating actors etc.
83 * @param[in] size The size of the parent control after size-negotiation.
85 void Relayout( const Dali::Vector2& size );
88 * @brief Sets which of the cursors are active.
90 * @note Cursor will only be visible if within the parent area.
91 * @param[in] activeCursor Which of the cursors should be active (if any).
93 void SetActiveCursor( ActiveCursor activeCursor );
96 * @brief Sets whether a cursor should be visible.
98 * @return Which of the cursors are active (if any).
100 unsigned int GetActiveCursor() const;
103 * @brief Sets the position of a cursor.
105 * @param[in] cursor The cursor to set.
106 * @param[in] x The x position relative to the top-left of the parent control.
107 * @param[in] y The y position relative to the top-left of the parent control.
108 * @param[in] height The logical height of the cursor.
110 void SetPosition( Cursor cursor, float x, float y, float height );
113 * @brief Retrieves the position of a cursor.
115 * @param[in] cursor The cursor to get.
116 * @param[out] x The x position relative to the top-left of the parent control.
117 * @param[out] y The y position relative to the top-left of the parent control.
118 * @param[out] height The logical height of the cursor.
120 void GetPosition( Cursor cursor, float& x, float& y, float& height ) const;
123 * @brief Sets the image for a cursor.
125 * @param[in] image The image to use.
127 void SetCursorImage( Dali::Image image );
130 * @brief Retrieves the image for a cursor.
132 * @return The cursor image.
134 Dali::Image GetCursorImage() const;
137 * @brief Sets the color for a cursor.
139 * @param[in] cursor Whether this color is for the primary or secondary cursor.
140 * @param[in] color The color to use.
142 void SetColor( Cursor cursor, const Dali::Vector4& color );
145 * @brief Retrieves the color for a cursor.
147 * @param[in] cursor Whether this color is for the primary or secondary cursor.
148 * @return The cursor color.
150 const Dali::Vector4& GetColor( Cursor cursor ) const;
153 * @brief Start blinking the cursor; see also SetCursorBlinkDuration().
155 void StartCursorBlink();
158 * @brief Stop blinking the cursor.
160 void StopCursorBlink();
163 * @brief Set the interval between cursor blinks.
165 * @param[in] seconds The interval in seconds.
167 void SetCursorBlinkInterval( float seconds );
170 * @brief Retrieves the blink-interval for a cursor.
172 * @return The cursor blink-interval.
174 float GetCursorBlinkInterval() const;
177 * @brief The cursor will stop blinking after this duration.
179 * @param[in] seconds The duration in seconds.
181 void SetCursorBlinkDuration( float seconds );
184 * @brief Retrieves the blink-duration for a cursor.
186 * @return The cursor blink-duration.
188 float GetCursorBlinkDuration() const;
193 * @brief A reference counted object may only be deleted by calling Unreference().
195 virtual ~Decorator();
200 * @brief Private constructor.
201 * @param[in] parent Decorations will be added to this parent control.
203 Decorator(Dali::Toolkit::Internal::Control& parent);
206 Decorator( const Decorator& handle );
209 Decorator& operator=( const Decorator& handle );
218 } // namespace Toolkit
222 #endif // __DALI_TOOLKIT_TEXT_DECORATOR_H__