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>
41 typedef IntrusivePtr<Decorator> DecoratorPtr;
43 // Used to set the cursor positions etc.
46 PRIMARY_CURSOR, ///< The primary cursor for bidirectional text (or the regular cursor for single-direction text)
47 SECONDARY_CURSOR, ///< The secondary cursor for bidirectional text
51 // Determines which of the cursors are active (if any).
54 ACTIVE_CURSOR_NONE, ///< Neither primary nor secondary cursor are active
55 ACTIVE_CURSOR_PRIMARY, ///< Primary cursor is active (only)
56 ACTIVE_CURSOR_BOTH ///< Both primary and secondary cursor are active
60 * @brief A Text Decorator is used to display cursors, handles, selection highlights and pop-ups.
62 * The decorator is responsible for clipping decorations which are positioned outside of the parent area.
63 * In some cases the decorations will be moved or flipped around, to maintain visibility on-screen.
65 class Decorator : public RefObject
70 * @brief Create a new instance of a Decorator.
72 * @param[in] parent Decorations will be added to this parent control.
73 * @return A pointer to a new Decorator.
75 static DecoratorPtr New( ControlImpl& parent );
78 * @brief The decorator waits until a relayout before creating actors etc.
80 * @param[in] size The size of the parent control after size-negotiation.
82 void Relayout( const Dali::Vector2& size );
85 * @brief Sets which of the cursors are active.
87 * @note Cursor will only be visible if within the parent area.
88 * @param[in] activeCursor Which of the cursors should be active (if any).
90 void SetActiveCursor( ActiveCursor activeCursor );
93 * @brief Sets whether a cursor should be visible.
95 * @return Which of the cursors are active (if any).
97 unsigned int GetActiveCursor() const;
100 * @brief Sets the position of a cursor.
102 * @param[in] cursor The cursor to set.
103 * @param[in] x The x position relative to the top-left of the parent control.
104 * @param[in] y The y position relative to the top-left of the parent control.
105 * @param[in] height The logical height of the cursor.
107 void SetPosition( Cursor cursor, float x, float y, float height );
110 * @brief Retrieves the position of a cursor.
112 * @param[in] cursor The cursor to get.
113 * @param[out] x The x position relative to the top-left of the parent control.
114 * @param[out] y The y position relative to the top-left of the parent control.
115 * @param[out] height The logical height of the cursor.
117 void GetPosition( Cursor cursor, float& x, float& y, float& height ) const;
120 * @brief Sets the image for a cursor.
122 * @param[in] cursor The cursor to set.
123 * @param[in] image The image to use.
125 void SetImage( Cursor cursor, Dali::Image image );
128 * @brief Retrieves the image for a cursor.
130 * @return The cursor image.
132 Dali::Image GetImage( Cursor cursor ) const;
135 * @brief Sets the color for a cursor.
137 * @param[in] cursor The cursor to set.
138 * @param[in] color The color to use.
140 void SetColor( Cursor cursor, const Dali::Vector4& color );
143 * @brief Retrieves the color for a cursor.
145 * @return The cursor color.
147 const Dali::Vector4& GetColor( Cursor cursor ) const;
150 * @brief Start blinking the cursor; see also SetCursorBlinkDuration().
152 void StartCursorBlink();
155 * @brief Stop blinking the cursor.
157 void StopCursorBlink();
160 * @brief Set the interval between cursor blinks.
162 * @param[in] seconds The interval in seconds.
164 void SetCursorBlinkInterval( float seconds );
167 * @brief Retrieves the blink-interval for a cursor.
169 * @return The cursor blink-interval.
171 float GetCursorBlinkInterval() const;
174 * @brief The cursor will stop blinking after this duration.
176 * @param[in] seconds The duration in seconds.
178 void SetCursorBlinkDuration( float seconds );
181 * @brief Retrieves the blink-duration for a cursor.
183 * @return The cursor blink-duration.
185 float GetCursorBlinkDuration() const;
190 * @brief A reference counted object may only be deleted by calling Unreference().
192 virtual ~Decorator();
197 * @brief Private constructor.
198 * @param[in] parent Decorations will be added to this parent control.
200 Decorator(ControlImpl& parent);
203 Decorator( const Decorator& handle );
206 Decorator& operator=( const Decorator& handle );
215 } // namespace Toolkit
219 #endif // __DALI_TOOLKIT_TEXT_DECORATOR_H__