Implemented the Handle assignment operators properly
[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 const char* const TextActor::SIGNAL_TEXT_LOADING_FINISHED = "text-loading-finished";
33
34 TextActor::TextActor()
35 {
36 }
37
38 TextActor TextActor::New()
39 {
40   TextActorParameters parameters;
41   Internal::TextActorPtr internal = Internal::TextActor::New( Internal::TextArray(), parameters );
42
43   return TextActor( internal.Get() );
44 }
45
46 TextActor TextActor::New( const Text& text )
47 {
48   TextActorParameters parameters( TextStyle(), TextActorParameters::FONT_DETECTION_ON );
49   return New( text, parameters );
50 }
51
52 TextActor TextActor::New( const Text& text, const TextActorParameters& parameters )
53 {
54   Internal::TextActorPtr internal = Internal::TextActor::New( Internal::GetTextArray( text ), parameters );
55
56   return TextActor( internal.Get() );
57 }
58
59 TextActor TextActor::DownCast( BaseHandle handle )
60 {
61   return TextActor( dynamic_cast<Dali::Internal::TextActor*>(handle.GetObjectPtr()) );
62 }
63
64 TextActor::~TextActor()
65 {
66 }
67
68 TextActor::TextActor(const TextActor& copy)
69 : RenderableActor(copy)
70 {
71 }
72
73 TextActor& TextActor::operator=(const TextActor& rhs)
74 {
75   BaseHandle::operator=(rhs);
76   return *this;
77 }
78
79 TextActor& TextActor::operator=(BaseHandle::NullType* rhs)
80 {
81   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
82   Reset();
83   return *this;
84 }
85
86 string TextActor::GetText() const
87 {
88   return GetImplementation(*this).GetText();
89 }
90
91 void TextActor::SetText(const Text& text)
92 {
93   GetImplementation(*this).SetText( Internal::GetTextArray( text ) );
94 }
95
96 void TextActor::SetToNaturalSize()
97 {
98   GetImplementation(*this).SetToNaturalSize();
99 }
100
101 Font TextActor::GetFont() const
102 {
103   Internal::Font* font = GetImplementation(*this).GetFont();
104
105   return Font(font);
106 }
107
108 void TextActor::SetFont(Font& font)
109 {
110   GetImplementation(*this).SetFont(GetImplementation(font));
111 }
112
113 void TextActor::SetGradientColor( const Vector4& color )
114 {
115   GetImplementation(*this).SetGradientColor( color );
116 }
117
118 Vector4 TextActor::GetGradientColor() const
119 {
120   return GetImplementation(*this).GetGradientColor();
121 }
122
123 void TextActor::SetGradientStartPoint( const Vector2& position )
124 {
125   GetImplementation(*this).SetGradientStartPoint( position );
126 }
127
128 Vector2 TextActor::GetGradientStartPoint() const
129 {
130   return GetImplementation(*this).GetGradientStartPoint();
131 }
132
133 void TextActor::SetGradientEndPoint( const Vector2& position )
134 {
135   GetImplementation(*this).SetGradientEndPoint( position );
136 }
137
138 Vector2 TextActor::GetGradientEndPoint() const
139 {
140   return GetImplementation(*this).GetGradientEndPoint();
141 }
142
143 void TextActor::SetTextStyle( const TextStyle& style )
144 {
145   GetImplementation(*this).SetTextStyle( style );
146 }
147
148 TextStyle TextActor::GetTextStyle() const
149 {
150   return GetImplementation(*this).GetTextStyle();
151 }
152
153 void TextActor::SetTextColor( const Vector4& color )
154 {
155   GetImplementation(*this).SetTextColor(color);
156 }
157
158 Vector4 TextActor::GetTextColor() const
159 {
160   return GetImplementation(*this).GetTextColor();
161 }
162
163 void TextActor::SetSmoothEdge( float smoothEdge )
164 {
165   GetImplementation(*this).SetSmoothEdge(smoothEdge);
166 }
167
168 void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
169 {
170   GetImplementation(*this).SetOutline(enable, color, thickness);
171 }
172
173 void TextActor::SetGlow( bool enable, const Vector4& color, float intensity )
174 {
175   GetImplementation(*this).SetGlow(enable, color, intensity);
176 }
177
178 void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size )
179 {
180   GetImplementation(*this).SetShadow(enable, color, offset, size);
181 }
182
183 void TextActor::SetItalics( bool enabled, Degree angle )
184 {
185   GetImplementation(*this).SetItalics( enabled ? Radian(angle) : Radian( 0.0f ) );
186 }
187
188 void TextActor::SetItalics( bool enabled, Radian angle )
189 {
190   GetImplementation(*this).SetItalics( enabled ? angle : Radian( 0.0f ) );
191 }
192
193 bool TextActor::GetItalics() const
194 {
195   return GetImplementation(*this).GetItalics();
196 }
197
198 Radian TextActor::GetItalicsAngle() const
199 {
200   return GetImplementation(*this).GetItalicsAngle();
201 }
202
203 void TextActor::SetUnderline( bool enable )
204 {
205   GetImplementation(*this).SetUnderline( enable, 0.f, 0.f );
206 }
207
208 bool TextActor::GetUnderline() const
209 {
210   return GetImplementation(*this).GetUnderline();
211 }
212
213 void TextActor::SetWeight( TextStyle::Weight weight )
214 {
215   GetImplementation(*this).SetWeight( weight );
216 }
217
218 TextStyle::Weight TextActor::GetWeight() const
219 {
220   return GetImplementation(*this).GetWeight();
221 }
222
223 void TextActor::SetFontDetectionAutomatic(bool value)
224 {
225   GetImplementation(*this).SetFontDetectionAutomatic(value);
226 }
227
228 bool TextActor::IsFontDetectionAutomatic() const
229 {
230   return GetImplementation(*this).IsFontDetectionAutomatic();
231 }
232
233 LoadingState TextActor::GetLoadingState() const
234 {
235   return GetImplementation(*this).GetLoadingState();
236 }
237
238 TextActor::TextActor(Internal::TextActor* internal)
239 : RenderableActor(internal)
240 {
241 }
242
243 } // namespace Dali