2 * Copyright (c) 2014 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/public-api/actors/text-actor.h>
22 #include <dali/public-api/text/text-actor-parameters.h>
23 #include <dali/internal/event/actors/text-actor-impl.h>
24 #include <dali/internal/event/text/font-impl.h>
25 #include <dali/internal/event/text/text-impl.h>
32 TextActor::TextActor()
36 TextActor TextActor::New()
38 TextActorParameters parameters;
39 Internal::TextActorPtr internal = Internal::TextActor::New( Integration::TextArray(), parameters );
41 return TextActor( internal.Get() );
44 TextActor TextActor::New( const Text& text )
46 TextActorParameters parameters( TextStyle(), TextActorParameters::FONT_DETECTION_ON );
47 return New( text, parameters );
50 TextActor TextActor::New( const Text& text, const TextActorParameters& parameters )
52 Internal::TextActorPtr internal = Internal::TextActor::New( Internal::GetTextArray( text ), parameters );
54 return TextActor( internal.Get() );
57 TextActor TextActor::DownCast( BaseHandle handle )
59 return TextActor( dynamic_cast<Dali::Internal::TextActor*>(handle.GetObjectPtr()) );
62 TextActor::~TextActor()
66 TextActor::TextActor(const TextActor& copy)
67 : RenderableActor(copy)
71 TextActor& TextActor::operator=(const TextActor& rhs)
73 BaseHandle::operator=(rhs);
77 string TextActor::GetText() const
79 return GetImplementation(*this).GetText();
82 void TextActor::SetText(const Text& text)
84 GetImplementation(*this).SetText( Internal::GetTextArray( text ) );
87 void TextActor::SetToNaturalSize()
89 GetImplementation(*this).SetToNaturalSize();
92 Font TextActor::GetFont() const
94 Internal::Font* font = GetImplementation(*this).GetFont();
99 void TextActor::SetFont(Font& font)
101 GetImplementation(*this).SetFont(GetImplementation(font));
104 void TextActor::SetGradientColor( const Vector4& color )
106 GetImplementation(*this).SetGradientColor( color );
109 Vector4 TextActor::GetGradientColor() const
111 return GetImplementation(*this).GetGradientColor();
114 void TextActor::SetGradientStartPoint( const Vector2& position )
116 GetImplementation(*this).SetGradientStartPoint( position );
119 Vector2 TextActor::GetGradientStartPoint() const
121 return GetImplementation(*this).GetGradientStartPoint();
124 void TextActor::SetGradientEndPoint( const Vector2& position )
126 GetImplementation(*this).SetGradientEndPoint( position );
129 Vector2 TextActor::GetGradientEndPoint() const
131 return GetImplementation(*this).GetGradientEndPoint();
134 void TextActor::SetTextStyle( const TextStyle& style )
136 GetImplementation(*this).SetTextStyle( style );
139 TextStyle TextActor::GetTextStyle() const
141 return GetImplementation(*this).GetTextStyle();
144 void TextActor::SetTextColor( const Vector4& color )
146 GetImplementation(*this).SetTextColor(color);
149 Vector4 TextActor::GetTextColor() const
151 return GetImplementation(*this).GetTextColor();
154 void TextActor::SetSmoothEdge( float smoothEdge )
156 GetImplementation(*this).SetSmoothEdge(smoothEdge);
159 void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
161 GetImplementation(*this).SetOutline(enable, color, thickness);
164 void TextActor::SetGlow( bool enable, const Vector4& color, float intensity )
166 GetImplementation(*this).SetGlow(enable, color, intensity);
169 void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
171 GetImplementation(*this).SetShadow(enable, color, offset, size);
174 void TextActor::SetItalics( bool enabled, Degree angle )
176 GetImplementation(*this).SetItalics( enabled ? Radian(angle) : Radian( 0.0f ) );
179 void TextActor::SetItalics( bool enabled, Radian angle )
181 GetImplementation(*this).SetItalics( enabled ? angle : Radian( 0.0f ) );
184 bool TextActor::GetItalics() const
186 return GetImplementation(*this).GetItalics();
189 Radian TextActor::GetItalicsAngle() const
191 return GetImplementation(*this).GetItalicsAngle();
194 void TextActor::SetUnderline( bool enable )
196 GetImplementation(*this).SetUnderline( enable, 0.f, 0.f );
199 bool TextActor::GetUnderline() const
201 return GetImplementation(*this).GetUnderline();
204 void TextActor::SetWeight( TextStyle::Weight weight )
206 GetImplementation(*this).SetWeight( weight );
209 TextStyle::Weight TextActor::GetWeight() const
211 return GetImplementation(*this).GetWeight();
214 void TextActor::SetFontDetectionAutomatic(bool value)
216 GetImplementation(*this).SetFontDetectionAutomatic(value);
219 bool TextActor::IsFontDetectionAutomatic() const
221 return GetImplementation(*this).IsFontDetectionAutomatic();
224 LoadingState TextActor::GetLoadingState() const
226 return GetImplementation(*this).GetLoadingState();
229 TextActor::TextActor(Internal::TextActor* internal)
230 : RenderableActor(internal)