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.
20 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
24 #include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
33 const char* const TextView::SIGNAL_TEXT_SCROLLED = "scrolled";
35 TextView::CharacterLayoutInfo::CharacterLayoutInfo()
38 mIsNewLineChar( false ),
39 mIsRightToLeftCharacter( false ),
45 TextView::CharacterLayoutInfo::~CharacterLayoutInfo()
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 )
59 TextView::CharacterLayoutInfo& TextView::CharacterLayoutInfo::operator=( const TextView::CharacterLayoutInfo& characterLayoutInfo )
61 mSize = characterLayoutInfo.mSize;
62 mPosition = characterLayoutInfo.mPosition;
63 mIsNewLineChar = characterLayoutInfo.mIsNewLineChar;
64 mIsRightToLeftCharacter = characterLayoutInfo.mIsRightToLeftCharacter;
65 mIsVisible = characterLayoutInfo.mIsVisible;
66 mDescender = characterLayoutInfo.mDescender;
71 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
72 const Vector3& position,
74 bool isRightToLeftCharacter,
78 mPosition( position ),
79 mIsNewLineChar( isNewLineChar ),
80 mIsRightToLeftCharacter( isRightToLeftCharacter ),
81 mIsVisible( isVisible ),
82 mDescender( descender )
86 TextView::TextLayoutInfo::TextLayoutInfo()
87 : mCharacterLayoutInfoTable(),
89 mCharacterLogicalToVisualMap(),
90 mCharacterVisualToLogicalMap(),
96 TextView::TextLayoutInfo::~TextLayoutInfo()
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 )
110 TextView::TextLayoutInfo& TextView::TextLayoutInfo::operator=( const TextView::TextLayoutInfo& textLayoutInfo )
112 mCharacterLayoutInfoTable = textLayoutInfo.mCharacterLayoutInfoTable;
113 mLines = textLayoutInfo.mLines;
114 mCharacterLogicalToVisualMap = textLayoutInfo.mCharacterLogicalToVisualMap;
115 mCharacterVisualToLogicalMap = textLayoutInfo.mCharacterVisualToLogicalMap;
116 mTextSize = textLayoutInfo.mTextSize;
117 mScrollOffset = textLayoutInfo.mScrollOffset;
122 TextView::FadeBoundary::FadeBoundary()
130 TextView::FadeBoundary::FadeBoundary( PixelSize left, PixelSize right, PixelSize top, PixelSize bottom )
142 TextView::TextView( const TextView& handle )
147 TextView::TextView( Dali::Internal::CustomActor* internal )
148 : Control( internal )
150 VerifyCustomActorPointer<Internal::TextView>(internal);
153 TextView& TextView::operator=( const TextView& handle )
155 if( &handle != this )
157 Control::operator=( handle );
162 TextView TextView::New()
164 return Internal::TextView::New();
167 TextView TextView::New( const std::string& text )
169 TextView textView = Internal::TextView::New();
170 textView.SetText( text );
174 TextView TextView::New( const MarkupProcessor::StyledTextArray& text )
176 TextView textView = Internal::TextView::New();
177 textView.SetText( text );
181 TextView TextView::DownCast( BaseHandle handle )
183 return Control::DownCast<TextView, Internal::TextView>(handle);
186 TextView::~TextView()
190 void TextView::SetText( const std::string& text )
192 GetImpl( *this ).SetText( text );
195 void TextView::SetText( const MarkupProcessor::StyledTextArray& text )
197 GetImpl( *this ).SetText( text );
200 void TextView::InsertTextAt( std::size_t position, const std::string& text )
202 GetImpl( *this ).InsertTextAt( position, text );
205 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
207 GetImpl( *this ).InsertTextAt( position, text );
210 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
212 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
215 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
217 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
220 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
222 GetImpl( *this ).RemoveTextFrom( position, numberOfCharacters );
225 std::string TextView::GetText() const
227 return GetImpl( *this ).GetText();
230 void TextView::SetLineHeightOffset( PointSize offset )
232 GetImpl( *this ).SetLineHeightOffset( offset );
235 PointSize TextView::GetLineHeightOffset() const
237 return GetImpl( *this ).GetLineHeightOffset();
240 void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask mask )
242 GetImpl( *this ).SetStyleToCurrentText( style, mask );
245 void TextView::SetTextAlignment( Alignment::Type align )
247 GetImpl( *this ).SetTextAlignment( align );
250 Alignment::Type TextView::GetTextAlignment() const
252 return GetImpl( *this ).GetTextAlignment();
255 void TextView::SetMultilinePolicy( TextView::MultilinePolicy policy )
257 GetImpl( *this ).SetMultilinePolicy( policy );
260 TextView::MultilinePolicy TextView::GetMultilinePolicy() const
262 return GetImpl( *this ).GetMultilinePolicy();
265 void TextView::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
267 GetImpl( *this ).SetWidthExceedPolicy( policy );
270 TextView::ExceedPolicy TextView::GetWidthExceedPolicy() const
272 return GetImpl( *this ).GetWidthExceedPolicy();
275 void TextView::SetHeightExceedPolicy( ExceedPolicy policy )
277 GetImpl( *this ).SetHeightExceedPolicy( policy );
280 TextView::ExceedPolicy TextView::GetHeightExceedPolicy() const
282 return GetImpl( *this ).GetHeightExceedPolicy();
285 void TextView::SetLineJustification( TextView::LineJustification justification )
287 GetImpl( *this ).SetLineJustification( justification );
290 TextView::LineJustification TextView::GetLineJustification() const
292 return GetImpl( *this ).GetLineJustification();
295 void TextView::SetFadeBoundary( const TextView::FadeBoundary& fadeBoundary )
297 GetImpl( *this ).SetFadeBoundary( fadeBoundary );
300 const TextView::FadeBoundary& TextView::GetFadeBoundary() const
302 return GetImpl( *this ).GetFadeBoundary();
305 void TextView::SetEllipsizeText( const std::string& ellipsizeText )
307 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
310 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
312 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
315 std::string TextView::GetEllipsizeText() const
317 return GetImpl( *this ).GetEllipsizeText();
320 void TextView::GetTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
322 GetImpl( *this ).GetTextLayoutInfo( textLayoutInfo );
325 void TextView::SetSortModifier( float depthOffset )
327 GetImpl( *this ).SetSortModifier( depthOffset );
330 void TextView::SetSnapshotModeEnabled( bool enable )
332 GetImpl( *this ).SetSnapshotModeEnabled( enable );
335 bool TextView::IsSnapshotModeEnabled() const
337 return GetImpl( *this ).IsSnapshotModeEnabled();
340 void TextView::SetScrollEnabled( bool enable )
342 GetImpl( *this ).SetScrollEnabled( enable );
345 bool TextView::IsScrollEnabled() const
347 return GetImpl( *this ).IsScrollEnabled();
350 void TextView::SetScrollPosition( const Vector2& position )
352 GetImpl( *this ).SetScrollPosition( position );
355 const Vector2& TextView::GetScrollPosition() const
357 return GetImpl( *this ).GetScrollPosition();
360 bool TextView::IsScrollPositionTrimmed() const
362 return GetImpl( *this ).IsScrollPositionTrimmed();
365 TextView::ScrolledSignalV2& TextView::ScrolledSignal()
367 return GetImpl( *this ).ScrolledSignal();
370 void TextView::SetMarkupProcessingEnabled( bool enable )
372 return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
375 bool TextView::IsMarkupProcessingEnabled() const
377 return GetImpl( *this ).IsMarkupProcessingEnabled();
380 TextView::TextView( Internal::TextView& implementation )
381 : Control( implementation )
385 } // namespace Toolkit