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