2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
22 #include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
31 const char* const TextView::SIGNAL_TEXT_SCROLLED = "scrolled";
33 TextView::CharacterLayoutInfo::CharacterLayoutInfo()
36 mIsNewLineChar( false ),
37 mIsNewParagraphChar( false ),
38 mIsRightToLeftCharacter( false ),
44 TextView::CharacterLayoutInfo::~CharacterLayoutInfo()
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 )
59 TextView::CharacterLayoutInfo& TextView::CharacterLayoutInfo::operator=( const TextView::CharacterLayoutInfo& characterLayoutInfo )
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;
72 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
73 const Vector3& position,
74 bool isNewParagraphChar,
75 bool isRightToLeftCharacter,
79 mPosition( position ),
80 mIsNewLineChar( isNewParagraphChar ),
81 mIsNewParagraphChar( isNewParagraphChar ),
82 mIsRightToLeftCharacter( isRightToLeftCharacter ),
83 mIsVisible( isVisible ),
84 mDescender( descender )
88 TextView::TextLayoutInfo::TextLayoutInfo()
89 : mCharacterLayoutInfoTable(),
91 mCharacterLogicalToVisualMap(),
92 mCharacterVisualToLogicalMap(),
98 TextView::TextLayoutInfo::~TextLayoutInfo()
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 )
112 TextView::TextLayoutInfo& TextView::TextLayoutInfo::operator=( const TextView::TextLayoutInfo& textLayoutInfo )
114 mCharacterLayoutInfoTable = textLayoutInfo.mCharacterLayoutInfoTable;
115 mLines = textLayoutInfo.mLines;
116 mCharacterLogicalToVisualMap = textLayoutInfo.mCharacterLogicalToVisualMap;
117 mCharacterVisualToLogicalMap = textLayoutInfo.mCharacterVisualToLogicalMap;
118 mTextSize = textLayoutInfo.mTextSize;
119 mScrollOffset = textLayoutInfo.mScrollOffset;
124 TextView::FadeBoundary::FadeBoundary()
132 TextView::FadeBoundary::FadeBoundary( PixelSize left, PixelSize right, PixelSize top, PixelSize bottom )
144 TextView::TextView( const TextView& handle )
149 TextView::TextView( Dali::Internal::CustomActor* internal )
150 : Control( internal )
152 VerifyCustomActorPointer<Internal::TextView>(internal);
155 TextView& TextView::operator=( const TextView& handle )
157 if( &handle != this )
159 Control::operator=( handle );
164 TextView TextView::New()
166 return Internal::TextView::New();
169 TextView TextView::New( const std::string& text )
171 TextView textView = Internal::TextView::New();
172 textView.SetText( text );
176 TextView TextView::New( const MarkupProcessor::StyledTextArray& text )
178 TextView textView = Internal::TextView::New();
179 textView.SetText( text );
183 TextView TextView::DownCast( BaseHandle handle )
185 return Control::DownCast<TextView, Internal::TextView>(handle);
188 TextView::~TextView()
192 void TextView::SetText( const std::string& text )
194 GetImpl( *this ).SetText( text );
197 void TextView::SetText( const MarkupProcessor::StyledTextArray& text )
199 GetImpl( *this ).SetText( text );
202 void TextView::InsertTextAt( std::size_t position, const std::string& text )
204 GetImpl( *this ).InsertTextAt( position, text );
207 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
209 GetImpl( *this ).InsertTextAt( position, text );
212 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
214 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
217 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
219 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
222 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
224 GetImpl( *this ).RemoveTextFrom( position, numberOfCharacters );
227 std::string TextView::GetText() const
229 return GetImpl( *this ).GetText();
232 void TextView::SetLineHeightOffset( PointSize offset )
234 GetImpl( *this ).SetLineHeightOffset( offset );
237 PointSize TextView::GetLineHeightOffset() const
239 return GetImpl( *this ).GetLineHeightOffset();
242 void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask mask )
244 GetImpl( *this ).SetStyleToCurrentText( style, mask );
247 void TextView::SetTextAlignment( Alignment::Type align )
249 GetImpl( *this ).SetTextAlignment( align );
252 Alignment::Type TextView::GetTextAlignment() const
254 return GetImpl( *this ).GetTextAlignment();
257 void TextView::SetMultilinePolicy( TextView::MultilinePolicy policy )
259 GetImpl( *this ).SetMultilinePolicy( policy );
262 TextView::MultilinePolicy TextView::GetMultilinePolicy() const
264 return GetImpl( *this ).GetMultilinePolicy();
267 void TextView::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
269 GetImpl( *this ).SetWidthExceedPolicy( policy );
272 TextView::ExceedPolicy TextView::GetWidthExceedPolicy() const
274 return GetImpl( *this ).GetWidthExceedPolicy();
277 void TextView::SetHeightExceedPolicy( ExceedPolicy policy )
279 GetImpl( *this ).SetHeightExceedPolicy( policy );
282 TextView::ExceedPolicy TextView::GetHeightExceedPolicy() const
284 return GetImpl( *this ).GetHeightExceedPolicy();
287 void TextView::SetLineJustification( TextView::LineJustification justification )
289 GetImpl( *this ).SetLineJustification( justification );
292 TextView::LineJustification TextView::GetLineJustification() const
294 return GetImpl( *this ).GetLineJustification();
297 void TextView::SetFadeBoundary( const TextView::FadeBoundary& fadeBoundary )
299 GetImpl( *this ).SetFadeBoundary( fadeBoundary );
302 const TextView::FadeBoundary& TextView::GetFadeBoundary() const
304 return GetImpl( *this ).GetFadeBoundary();
307 void TextView::SetEllipsizeText( const std::string& ellipsizeText )
309 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
312 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
314 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
317 std::string TextView::GetEllipsizeText() const
319 return GetImpl( *this ).GetEllipsizeText();
322 void TextView::GetTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
324 GetImpl( *this ).GetTextLayoutInfo( textLayoutInfo );
327 void TextView::SetSortModifier( float depthOffset )
329 GetImpl( *this ).SetSortModifier( depthOffset );
332 void TextView::SetSnapshotModeEnabled( bool enable )
334 GetImpl( *this ).SetSnapshotModeEnabled( enable );
337 bool TextView::IsSnapshotModeEnabled() const
339 return GetImpl( *this ).IsSnapshotModeEnabled();
342 void TextView::SetScrollEnabled( bool enable )
344 GetImpl( *this ).SetScrollEnabled( enable );
347 bool TextView::IsScrollEnabled() const
349 return GetImpl( *this ).IsScrollEnabled();
352 void TextView::SetScrollPosition( const Vector2& position )
354 GetImpl( *this ).SetScrollPosition( position );
357 const Vector2& TextView::GetScrollPosition() const
359 return GetImpl( *this ).GetScrollPosition();
362 bool TextView::IsScrollPositionTrimmed() const
364 return GetImpl( *this ).IsScrollPositionTrimmed();
367 TextView::ScrolledSignalV2& TextView::ScrolledSignal()
369 return GetImpl( *this ).ScrolledSignal();
372 void TextView::SetMarkupProcessingEnabled( bool enable )
374 return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
377 bool TextView::IsMarkupProcessingEnabled() const
379 return GetImpl( *this ).IsMarkupProcessingEnabled();
382 TextView::TextView( Internal::TextView& implementation )
383 : Control( implementation )
387 } // namespace Toolkit