2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/public-api/text/decorator/text-decorator.h>
22 #include <dali/public-api/common/constants.h>
23 #include <dali/public-api/images/image.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/math/vector4.h>
36 struct Decorator::Impl
44 color(Dali::Color::WHITE)
55 Impl(Dali::Toolkit::Internal::Control& parent)
57 mActiveCursor(ACTIVE_CURSOR_NONE),
58 mCursorBlinkInterval(0.5f),
59 mCursorBlinkDuration(0.0f)
63 void Relayout( const Vector2& size )
68 Internal::Control& mParent;
70 unsigned int mActiveCursor;
72 CursorImpl mCursor[CURSOR_COUNT];
76 float mCursorBlinkInterval;
77 float mCursorBlinkDuration;
80 DecoratorPtr Decorator::New(Internal::Control& parent)
82 return DecoratorPtr( new Decorator(parent) );
85 void Decorator::Relayout( const Vector2& size )
87 mImpl->Relayout( size );
90 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
92 mImpl->mActiveCursor = activeCursor;
95 unsigned int Decorator::GetActiveCursor() const
97 return mImpl->mActiveCursor;
100 void Decorator::SetPosition( Cursor cursor, float x, float y, float height )
102 mImpl->mCursor[cursor].x = x;
103 mImpl->mCursor[cursor].y = y;
104 mImpl->mCursor[cursor].height = height;
107 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) const
109 x = mImpl->mCursor[cursor].x;
110 y = mImpl->mCursor[cursor].y;
111 height = mImpl->mCursor[cursor].height;
114 void Decorator::SetCursorImage( Dali::Image image )
116 mImpl->mCursorImage = image;
119 Dali::Image Decorator::GetCursorImage() const
121 return mImpl->mCursorImage;
124 void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
126 mImpl->mCursor[cursor].color = color;
129 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
131 return mImpl->mCursor[cursor].color;
134 void Decorator::StartCursorBlink()
139 void Decorator::StopCursorBlink()
144 void Decorator::SetCursorBlinkInterval( float seconds )
146 mImpl->mCursorBlinkInterval = seconds;
149 float Decorator::GetCursorBlinkInterval() const
151 return mImpl->mCursorBlinkInterval;
154 void Decorator::SetCursorBlinkDuration( float seconds )
156 mImpl->mCursorBlinkDuration = seconds;
159 float Decorator::GetCursorBlinkDuration() const
161 return mImpl->mCursorBlinkDuration;
164 Decorator::~Decorator()
169 Decorator::Decorator(Dali::Toolkit::Internal::Control& parent)
172 mImpl = new Decorator::Impl(parent);
177 } // namespace Toolkit