Merge "Added API to generate a MeshData object for a Dali::Path object" into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / actors / text-actor.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/actors/text-actor.h>
20
21 // INTERNAL INCLUDES
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>
26
27 namespace Dali
28 {
29
30 using std::string;
31
32 TextActor::TextActor()
33 {
34 }
35
36 TextActor TextActor::New()
37 {
38   TextActorParameters parameters;
39   Internal::TextActorPtr internal = Internal::TextActor::New( Integration::TextArray(), parameters );
40
41   return TextActor( internal.Get() );
42 }
43
44 TextActor TextActor::New( const Text& text )
45 {
46   TextActorParameters parameters( TextStyle(), TextActorParameters::FONT_DETECTION_ON );
47   return New( text, parameters );
48 }
49
50 TextActor TextActor::New( const Text& text, const TextActorParameters& parameters )
51 {
52   Internal::TextActorPtr internal = Internal::TextActor::New( Internal::GetTextArray( text ), parameters );
53
54   return TextActor( internal.Get() );
55 }
56
57 TextActor TextActor::DownCast( BaseHandle handle )
58 {
59   return TextActor( dynamic_cast<Dali::Internal::TextActor*>(handle.GetObjectPtr()) );
60 }
61
62 TextActor::~TextActor()
63 {
64 }
65
66 TextActor::TextActor(const TextActor& copy)
67 : RenderableActor(copy)
68 {
69 }
70
71 TextActor& TextActor::operator=(const TextActor& rhs)
72 {
73   BaseHandle::operator=(rhs);
74   return *this;
75 }
76
77 string TextActor::GetText() const
78 {
79   return GetImplementation(*this).GetText();
80 }
81
82 void TextActor::SetText(const Text& text)
83 {
84   GetImplementation(*this).SetText( Internal::GetTextArray( text ) );
85 }
86
87 void TextActor::SetToNaturalSize()
88 {
89   GetImplementation(*this).SetToNaturalSize();
90 }
91
92 Font TextActor::GetFont() const
93 {
94   Internal::Font* font = GetImplementation(*this).GetFont();
95
96   return Font(font);
97 }
98
99 void TextActor::SetFont(Font& font)
100 {
101   GetImplementation(*this).SetFont(GetImplementation(font));
102 }
103
104 void TextActor::SetGradientColor( const Vector4& color )
105 {
106   GetImplementation(*this).SetGradientColor( color );
107 }
108
109 Vector4 TextActor::GetGradientColor() const
110 {
111   return GetImplementation(*this).GetGradientColor();
112 }
113
114 void TextActor::SetGradientStartPoint( const Vector2& position )
115 {
116   GetImplementation(*this).SetGradientStartPoint( position );
117 }
118
119 Vector2 TextActor::GetGradientStartPoint() const
120 {
121   return GetImplementation(*this).GetGradientStartPoint();
122 }
123
124 void TextActor::SetGradientEndPoint( const Vector2& position )
125 {
126   GetImplementation(*this).SetGradientEndPoint( position );
127 }
128
129 Vector2 TextActor::GetGradientEndPoint() const
130 {
131   return GetImplementation(*this).GetGradientEndPoint();
132 }
133
134 void TextActor::SetTextStyle( const TextStyle& style )
135 {
136   GetImplementation(*this).SetTextStyle( style );
137 }
138
139 TextStyle TextActor::GetTextStyle() const
140 {
141   return GetImplementation(*this).GetTextStyle();
142 }
143
144 void TextActor::SetTextColor( const Vector4& color )
145 {
146   GetImplementation(*this).SetTextColor(color);
147 }
148
149 Vector4 TextActor::GetTextColor() const
150 {
151   return GetImplementation(*this).GetTextColor();
152 }
153
154 void TextActor::SetSmoothEdge( float smoothEdge )
155 {
156   GetImplementation(*this).SetSmoothEdge(smoothEdge);
157 }
158
159 void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
160 {
161   GetImplementation(*this).SetOutline(enable, color, thickness);
162 }
163
164 void TextActor::SetGlow( bool enable, const Vector4& color, float intensity )
165 {
166   GetImplementation(*this).SetGlow(enable, color, intensity);
167 }
168
169 void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
170 {
171   GetImplementation(*this).SetShadow(enable, color, offset, size);
172 }
173
174 void TextActor::SetItalics( bool enabled, Degree angle )
175 {
176   GetImplementation(*this).SetItalics( enabled ? Radian(angle) : Radian( 0.0f ) );
177 }
178
179 void TextActor::SetItalics( bool enabled, Radian angle )
180 {
181   GetImplementation(*this).SetItalics( enabled ? angle : Radian( 0.0f ) );
182 }
183
184 bool TextActor::GetItalics() const
185 {
186   return GetImplementation(*this).GetItalics();
187 }
188
189 Radian TextActor::GetItalicsAngle() const
190 {
191   return GetImplementation(*this).GetItalicsAngle();
192 }
193
194 void TextActor::SetUnderline( bool enable )
195 {
196   GetImplementation(*this).SetUnderline( enable, 0.f, 0.f );
197 }
198
199 bool TextActor::GetUnderline() const
200 {
201   return GetImplementation(*this).GetUnderline();
202 }
203
204 void TextActor::SetWeight( TextStyle::Weight weight )
205 {
206   GetImplementation(*this).SetWeight( weight );
207 }
208
209 TextStyle::Weight TextActor::GetWeight() const
210 {
211   return GetImplementation(*this).GetWeight();
212 }
213
214 void TextActor::SetFontDetectionAutomatic(bool value)
215 {
216   GetImplementation(*this).SetFontDetectionAutomatic(value);
217 }
218
219 bool TextActor::IsFontDetectionAutomatic() const
220 {
221   return GetImplementation(*this).IsFontDetectionAutomatic();
222 }
223
224 LoadingState TextActor::GetLoadingState() const
225 {
226   return GetImplementation(*this).GetLoadingState();
227 }
228
229 TextActor::TextActor(Internal::TextActor* internal)
230 : RenderableActor(internal)
231 {
232 }
233
234 } // namespace Dali