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