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