Merge branch 'master' into tizen
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / text-view / text-view.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18
19 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
20
21 // INTERNAL INCLUDES
22
23 #include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31
32 const char* const TextView::SIGNAL_TEXT_SCROLLED = "scrolled";
33
34 TextView::CharacterLayoutInfo::CharacterLayoutInfo()
35 : mSize(),
36   mPosition(),
37   mIsNewLineChar( false ),
38   mIsRightToLeftCharacter( false ),
39   mIsVisible( true ),
40   mDescender()
41 {
42 }
43
44 TextView::CharacterLayoutInfo::~CharacterLayoutInfo()
45 {
46 }
47
48 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const TextView::CharacterLayoutInfo& characterLayoutInfo )
49 : mSize( characterLayoutInfo.mSize ),
50   mPosition( characterLayoutInfo.mPosition ),
51   mIsNewLineChar( characterLayoutInfo.mIsNewLineChar ),
52   mIsRightToLeftCharacter( characterLayoutInfo.mIsRightToLeftCharacter ),
53   mIsVisible( characterLayoutInfo.mIsVisible ),
54   mDescender( characterLayoutInfo.mDescender )
55 {
56 }
57
58 TextView::CharacterLayoutInfo& TextView::CharacterLayoutInfo::operator=( const TextView::CharacterLayoutInfo& characterLayoutInfo )
59 {
60   mSize = characterLayoutInfo.mSize;
61   mPosition = characterLayoutInfo.mPosition;
62   mIsNewLineChar = characterLayoutInfo.mIsNewLineChar;
63   mIsRightToLeftCharacter = characterLayoutInfo.mIsRightToLeftCharacter;
64   mIsVisible = characterLayoutInfo.mIsVisible;
65   mDescender = characterLayoutInfo.mDescender;
66
67   return *this;
68 }
69
70 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
71                                                     const Vector3& position,
72                                                     bool isNewLineChar,
73                                                     bool isRightToLeftCharacter,
74                                                     bool isVisible,
75                                                     float descender )
76 : mSize( size ),
77   mPosition( position ),
78   mIsNewLineChar( isNewLineChar ),
79   mIsRightToLeftCharacter( isRightToLeftCharacter ),
80   mIsVisible( isVisible ),
81   mDescender( descender )
82 {
83 }
84
85 TextView::TextLayoutInfo::TextLayoutInfo()
86 : mCharacterLayoutInfoTable(),
87   mLines(),
88   mCharacterLogicalToVisualMap(),
89   mCharacterVisualToLogicalMap(),
90   mTextSize(),
91   mScrollOffset()
92 {
93 }
94
95 TextView::TextLayoutInfo::~TextLayoutInfo()
96 {
97 }
98
99 TextView::TextLayoutInfo::TextLayoutInfo( const TextView::TextLayoutInfo& textLayoutInfo )
100 : mCharacterLayoutInfoTable( textLayoutInfo.mCharacterLayoutInfoTable ),
101   mLines( textLayoutInfo.mLines ),
102   mCharacterLogicalToVisualMap( textLayoutInfo.mCharacterLogicalToVisualMap ),
103   mCharacterVisualToLogicalMap( textLayoutInfo.mCharacterVisualToLogicalMap ),
104   mTextSize( textLayoutInfo.mTextSize ),
105   mScrollOffset( textLayoutInfo.mScrollOffset )
106 {
107 }
108
109 TextView::TextLayoutInfo& TextView::TextLayoutInfo::operator=( const TextView::TextLayoutInfo& textLayoutInfo )
110 {
111   mCharacterLayoutInfoTable = textLayoutInfo.mCharacterLayoutInfoTable;
112   mLines = textLayoutInfo.mLines;
113   mCharacterLogicalToVisualMap = textLayoutInfo.mCharacterLogicalToVisualMap;
114   mCharacterVisualToLogicalMap = textLayoutInfo.mCharacterVisualToLogicalMap;
115   mTextSize = textLayoutInfo.mTextSize;
116   mScrollOffset = textLayoutInfo.mScrollOffset;
117
118   return *this;
119 }
120
121 TextView::FadeBoundary::FadeBoundary()
122 : mLeft( 0 ),
123   mRight( 0 ),
124   mTop( 0 ),
125   mBottom( 0 )
126 {
127 }
128
129 TextView::FadeBoundary::FadeBoundary( PixelSize left, PixelSize right, PixelSize top, PixelSize bottom )
130 : mLeft( left ),
131   mRight( right ),
132   mTop( top ),
133   mBottom( bottom )
134 {
135 }
136
137 TextView::TextView()
138 {
139 }
140
141 TextView::TextView( const TextView& handle )
142 : Control( handle )
143 {
144 }
145
146 TextView::TextView( Dali::Internal::CustomActor* internal )
147 : Control( internal )
148 {
149   VerifyCustomActorPointer<Internal::TextView>(internal);
150 }
151
152 TextView& TextView::operator=( const TextView& handle )
153 {
154   if( &handle != this )
155   {
156     Control::operator=( handle );
157   }
158   return *this;
159 }
160
161 TextView TextView::New()
162 {
163   return Internal::TextView::New();
164 }
165
166 TextView TextView::New( const std::string& text )
167 {
168   TextView textView = Internal::TextView::New();
169   textView.SetText( text );
170   return textView;
171 }
172
173 TextView TextView::New( const MarkupProcessor::StyledTextArray& text )
174 {
175   TextView textView = Internal::TextView::New();
176   textView.SetText( text );
177   return textView;
178 }
179
180 TextView TextView::DownCast( BaseHandle handle )
181 {
182   return Control::DownCast<TextView, Internal::TextView>(handle);
183 }
184
185 TextView::~TextView()
186 {
187 }
188
189 void TextView::SetText( const std::string& text )
190 {
191   GetImpl( *this ).SetText( text );
192 }
193
194 void TextView::SetText( const MarkupProcessor::StyledTextArray& text )
195 {
196   GetImpl( *this ).SetText( text );
197 }
198
199 void TextView::InsertTextAt( std::size_t position, const std::string& text )
200 {
201   GetImpl( *this ).InsertTextAt( position, text );
202 }
203
204 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
205 {
206   GetImpl( *this ).InsertTextAt( position, text );
207 }
208
209 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
210 {
211   GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
212 }
213
214 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
215 {
216   GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
217 }
218
219 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
220 {
221   GetImpl( *this ).RemoveTextFrom( position, numberOfCharacters );
222 }
223
224 std::string TextView::GetText() const
225 {
226   return GetImpl( *this ).GetText();
227 }
228
229 void TextView::SetLineHeightOffset( PointSize offset )
230 {
231   GetImpl( *this ).SetLineHeightOffset( offset );
232 }
233
234 PointSize TextView::GetLineHeightOffset() const
235 {
236   return GetImpl( *this ).GetLineHeightOffset();
237 }
238
239 void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask mask )
240 {
241   GetImpl( *this ).SetStyleToCurrentText( style, mask );
242 }
243
244 void TextView::SetTextAlignment( Alignment::Type align )
245 {
246   GetImpl( *this ).SetTextAlignment( align );
247 }
248
249 Alignment::Type TextView::GetTextAlignment() const
250 {
251   return GetImpl( *this ).GetTextAlignment();
252 }
253
254 void TextView::SetMultilinePolicy( TextView::MultilinePolicy policy )
255 {
256   GetImpl( *this ).SetMultilinePolicy( policy );
257 }
258
259 TextView::MultilinePolicy TextView::GetMultilinePolicy() const
260 {
261   return GetImpl( *this ).GetMultilinePolicy();
262 }
263
264 void TextView::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
265 {
266   GetImpl( *this ).SetWidthExceedPolicy( policy );
267 }
268
269 TextView::ExceedPolicy TextView::GetWidthExceedPolicy() const
270 {
271   return GetImpl( *this ).GetWidthExceedPolicy();
272 }
273
274 void TextView::SetHeightExceedPolicy( ExceedPolicy policy )
275 {
276   GetImpl( *this ).SetHeightExceedPolicy( policy );
277 }
278
279 TextView::ExceedPolicy TextView::GetHeightExceedPolicy() const
280 {
281   return GetImpl( *this ).GetHeightExceedPolicy();
282 }
283
284 void TextView::SetLineJustification( TextView::LineJustification justification )
285 {
286   GetImpl( *this ).SetLineJustification( justification );
287 }
288
289 TextView::LineJustification TextView::GetLineJustification() const
290 {
291   return GetImpl( *this ).GetLineJustification();
292 }
293
294 void TextView::SetFadeBoundary( const TextView::FadeBoundary& fadeBoundary )
295 {
296   GetImpl( *this ).SetFadeBoundary( fadeBoundary );
297 }
298
299 const TextView::FadeBoundary& TextView::GetFadeBoundary() const
300 {
301   return GetImpl( *this ).GetFadeBoundary();
302 }
303
304 void TextView::SetEllipsizeText( const std::string& ellipsizeText )
305 {
306   GetImpl( *this ).SetEllipsizeText( ellipsizeText );
307 }
308
309 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
310 {
311   GetImpl( *this ).SetEllipsizeText( ellipsizeText );
312 }
313
314 std::string TextView::GetEllipsizeText() const
315 {
316   return GetImpl( *this ).GetEllipsizeText();
317 }
318
319 void TextView::GetTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
320 {
321   GetImpl( *this ).GetTextLayoutInfo( textLayoutInfo );
322 }
323
324 void TextView::SetSortModifier( float depthOffset )
325 {
326   GetImpl( *this ).SetSortModifier( depthOffset );
327 }
328
329 void TextView::SetSnapshotModeEnabled( bool enable )
330 {
331   GetImpl( *this ).SetSnapshotModeEnabled( enable );
332 }
333
334 bool TextView::IsSnapshotModeEnabled() const
335 {
336   return GetImpl( *this ).IsSnapshotModeEnabled();
337 }
338
339 void TextView::SetScrollEnabled( bool enable )
340 {
341   GetImpl( *this ).SetScrollEnabled( enable );
342 }
343
344 bool TextView::IsScrollEnabled() const
345 {
346   return GetImpl( *this ).IsScrollEnabled();
347 }
348
349 void TextView::SetScrollPosition( const Vector2& position )
350 {
351   GetImpl( *this ).SetScrollPosition( position );
352 }
353
354 const Vector2& TextView::GetScrollPosition() const
355 {
356   return GetImpl( *this ).GetScrollPosition();
357 }
358
359 bool TextView::IsScrollPositionTrimmed() const
360 {
361   return GetImpl( *this ).IsScrollPositionTrimmed();
362 }
363
364 TextView::ScrolledSignalV2& TextView::ScrolledSignal()
365 {
366   return GetImpl( *this ).ScrolledSignal();
367 }
368
369 void TextView::SetMarkupProcessingEnabled( bool enable )
370 {
371   return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
372 }
373
374 bool TextView::IsMarkupProcessingEnabled() const
375 {
376   return GetImpl( *this ).IsMarkupProcessingEnabled();
377 }
378
379 TextView::TextView( Internal::TextView& implementation )
380 : Control( implementation )
381 {
382 }
383
384 } // namespace Toolkit
385
386 } // namespace Dali