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 const char* const TextActor::SIGNAL_TEXT_LOADING_FINISHED = "text-loading-finished";
34 TextActor::TextActor()
38 TextActor TextActor::New()
40 TextActorParameters parameters;
41 Internal::TextActorPtr internal = Internal::TextActor::New( Internal::TextArray(), parameters );
43 return TextActor( internal.Get() );
46 TextActor TextActor::New( const Text& text )
48 TextActorParameters parameters( TextStyle(), TextActorParameters::FONT_DETECTION_ON );
49 return New( text, parameters );
52 TextActor TextActor::New( const Text& text, const TextActorParameters& parameters )
54 Internal::TextActorPtr internal = Internal::TextActor::New( Internal::GetTextArray( text ), parameters );
56 return TextActor( internal.Get() );
59 TextActor TextActor::DownCast( BaseHandle handle )
61 return TextActor( dynamic_cast<Dali::Internal::TextActor*>(handle.GetObjectPtr()) );
64 TextActor::~TextActor()
68 TextActor::TextActor(const TextActor& copy)
69 : RenderableActor(copy)
73 TextActor& TextActor::operator=(const TextActor& rhs)
75 BaseHandle::operator=(rhs);
79 TextActor& TextActor::operator=(BaseHandle::NullType* rhs)
81 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
86 string TextActor::GetText() const
88 return GetImplementation(*this).GetText();
91 void TextActor::SetText(const Text& text)
93 GetImplementation(*this).SetText( Internal::GetTextArray( text ) );
96 void TextActor::SetToNaturalSize()
98 GetImplementation(*this).SetToNaturalSize();
101 Font TextActor::GetFont() const
103 Internal::Font* font = GetImplementation(*this).GetFont();
108 void TextActor::SetFont(Font& font)
110 GetImplementation(*this).SetFont(GetImplementation(font));
113 void TextActor::SetGradientColor( const Vector4& color )
115 GetImplementation(*this).SetGradientColor( color );
118 Vector4 TextActor::GetGradientColor() const
120 return GetImplementation(*this).GetGradientColor();
123 void TextActor::SetGradientStartPoint( const Vector2& position )
125 GetImplementation(*this).SetGradientStartPoint( position );
128 Vector2 TextActor::GetGradientStartPoint() const
130 return GetImplementation(*this).GetGradientStartPoint();
133 void TextActor::SetGradientEndPoint( const Vector2& position )
135 GetImplementation(*this).SetGradientEndPoint( position );
138 Vector2 TextActor::GetGradientEndPoint() const
140 return GetImplementation(*this).GetGradientEndPoint();
143 void TextActor::SetTextStyle( const TextStyle& style )
145 GetImplementation(*this).SetTextStyle( style );
148 TextStyle TextActor::GetTextStyle() const
150 return GetImplementation(*this).GetTextStyle();
153 void TextActor::SetTextColor( const Vector4& color )
155 GetImplementation(*this).SetTextColor(color);
158 Vector4 TextActor::GetTextColor() const
160 return GetImplementation(*this).GetTextColor();
163 void TextActor::SetSmoothEdge( float smoothEdge )
165 GetImplementation(*this).SetSmoothEdge(smoothEdge);
168 void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
170 GetImplementation(*this).SetOutline(enable, color, thickness);
173 void TextActor::SetGlow( bool enable, const Vector4& color, float intensity )
175 GetImplementation(*this).SetGlow(enable, color, intensity);
178 void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
180 GetImplementation(*this).SetShadow(enable, color, offset, size);
183 void TextActor::SetItalics( bool enabled, Degree angle )
185 GetImplementation(*this).SetItalics( enabled ? Radian(angle) : Radian( 0.0f ) );
188 void TextActor::SetItalics( bool enabled, Radian angle )
190 GetImplementation(*this).SetItalics( enabled ? angle : Radian( 0.0f ) );
193 bool TextActor::GetItalics() const
195 return GetImplementation(*this).GetItalics();
198 Radian TextActor::GetItalicsAngle() const
200 return GetImplementation(*this).GetItalicsAngle();
203 void TextActor::SetUnderline( bool enable )
205 GetImplementation(*this).SetUnderline( enable, 0.f, 0.f );
208 bool TextActor::GetUnderline() const
210 return GetImplementation(*this).GetUnderline();
213 void TextActor::SetWeight( TextStyle::Weight weight )
215 GetImplementation(*this).SetWeight( weight );
218 TextStyle::Weight TextActor::GetWeight() const
220 return GetImplementation(*this).GetWeight();
223 void TextActor::SetFontDetectionAutomatic(bool value)
225 GetImplementation(*this).SetFontDetectionAutomatic(value);
228 bool TextActor::IsFontDetectionAutomatic() const
230 return GetImplementation(*this).IsFontDetectionAutomatic();
233 LoadingState TextActor::GetLoadingState() const
235 return GetImplementation(*this).GetLoadingState();
238 TextActor::TextActor(Internal::TextActor* internal)
239 : RenderableActor(internal)