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 mIsRightToLeftCharacter( false ),
43 TextView::CharacterLayoutInfo::~CharacterLayoutInfo()
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 )
57 TextView::CharacterLayoutInfo& TextView::CharacterLayoutInfo::operator=( const TextView::CharacterLayoutInfo& characterLayoutInfo )
59 mSize = characterLayoutInfo.mSize;
60 mPosition = characterLayoutInfo.mPosition;
61 mIsNewLineChar = characterLayoutInfo.mIsNewLineChar;
62 mIsRightToLeftCharacter = characterLayoutInfo.mIsRightToLeftCharacter;
63 mIsVisible = characterLayoutInfo.mIsVisible;
64 mDescender = characterLayoutInfo.mDescender;
69 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
70 const Vector3& position,
72 bool isRightToLeftCharacter,
76 mPosition( position ),
77 mIsNewLineChar( isNewLineChar ),
78 mIsRightToLeftCharacter( isRightToLeftCharacter ),
79 mIsVisible( isVisible ),
80 mDescender( descender )
84 TextView::TextLayoutInfo::TextLayoutInfo()
85 : mCharacterLayoutInfoTable(),
87 mCharacterLogicalToVisualMap(),
88 mCharacterVisualToLogicalMap(),
94 TextView::TextLayoutInfo::~TextLayoutInfo()
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 )
108 TextView::TextLayoutInfo& TextView::TextLayoutInfo::operator=( const TextView::TextLayoutInfo& textLayoutInfo )
110 mCharacterLayoutInfoTable = textLayoutInfo.mCharacterLayoutInfoTable;
111 mLines = textLayoutInfo.mLines;
112 mCharacterLogicalToVisualMap = textLayoutInfo.mCharacterLogicalToVisualMap;
113 mCharacterVisualToLogicalMap = textLayoutInfo.mCharacterVisualToLogicalMap;
114 mTextSize = textLayoutInfo.mTextSize;
115 mScrollOffset = textLayoutInfo.mScrollOffset;
120 TextView::FadeBoundary::FadeBoundary()
128 TextView::FadeBoundary::FadeBoundary( PixelSize left, PixelSize right, PixelSize top, PixelSize bottom )
140 TextView::TextView( const TextView& handle )
145 TextView::TextView( Dali::Internal::CustomActor* internal )
146 : Control( internal )
148 VerifyCustomActorPointer<Internal::TextView>(internal);
151 TextView& TextView::operator=( const TextView& handle )
153 if( &handle != this )
155 Control::operator=( handle );
160 TextView TextView::New()
162 return Internal::TextView::New();
165 TextView TextView::New( const std::string& text )
167 TextView textView = Internal::TextView::New();
168 textView.SetText( text );
172 TextView TextView::New( const MarkupProcessor::StyledTextArray& text )
174 TextView textView = Internal::TextView::New();
175 textView.SetText( text );
179 TextView TextView::DownCast( BaseHandle handle )
181 return Control::DownCast<TextView, Internal::TextView>(handle);
184 TextView::~TextView()
188 void TextView::SetText( const std::string& text )
190 GetImpl( *this ).SetText( text );
193 void TextView::SetText( const MarkupProcessor::StyledTextArray& text )
195 GetImpl( *this ).SetText( text );
198 void TextView::InsertTextAt( std::size_t position, const std::string& text )
200 GetImpl( *this ).InsertTextAt( position, text );
203 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
205 GetImpl( *this ).InsertTextAt( position, text );
208 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
210 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
213 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
215 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
218 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
220 GetImpl( *this ).RemoveTextFrom( position, numberOfCharacters );
223 std::string TextView::GetText() const
225 return GetImpl( *this ).GetText();
228 void TextView::SetLineHeightOffset( PointSize offset )
230 GetImpl( *this ).SetLineHeightOffset( offset );
233 PointSize TextView::GetLineHeightOffset() const
235 return GetImpl( *this ).GetLineHeightOffset();
238 void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask mask )
240 GetImpl( *this ).SetStyleToCurrentText( style, mask );
243 void TextView::SetTextAlignment( Alignment::Type align )
245 GetImpl( *this ).SetTextAlignment( align );
248 Alignment::Type TextView::GetTextAlignment() const
250 return GetImpl( *this ).GetTextAlignment();
253 void TextView::SetMultilinePolicy( TextView::MultilinePolicy policy )
255 GetImpl( *this ).SetMultilinePolicy( policy );
258 TextView::MultilinePolicy TextView::GetMultilinePolicy() const
260 return GetImpl( *this ).GetMultilinePolicy();
263 void TextView::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
265 GetImpl( *this ).SetWidthExceedPolicy( policy );
268 TextView::ExceedPolicy TextView::GetWidthExceedPolicy() const
270 return GetImpl( *this ).GetWidthExceedPolicy();
273 void TextView::SetHeightExceedPolicy( ExceedPolicy policy )
275 GetImpl( *this ).SetHeightExceedPolicy( policy );
278 TextView::ExceedPolicy TextView::GetHeightExceedPolicy() const
280 return GetImpl( *this ).GetHeightExceedPolicy();
283 void TextView::SetLineJustification( TextView::LineJustification justification )
285 GetImpl( *this ).SetLineJustification( justification );
288 TextView::LineJustification TextView::GetLineJustification() const
290 return GetImpl( *this ).GetLineJustification();
293 void TextView::SetFadeBoundary( const TextView::FadeBoundary& fadeBoundary )
295 GetImpl( *this ).SetFadeBoundary( fadeBoundary );
298 const TextView::FadeBoundary& TextView::GetFadeBoundary() const
300 return GetImpl( *this ).GetFadeBoundary();
303 void TextView::SetEllipsizeText( const std::string& ellipsizeText )
305 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
308 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
310 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
313 std::string TextView::GetEllipsizeText() const
315 return GetImpl( *this ).GetEllipsizeText();
318 void TextView::GetTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
320 GetImpl( *this ).GetTextLayoutInfo( textLayoutInfo );
323 void TextView::SetSortModifier( float depthOffset )
325 GetImpl( *this ).SetSortModifier( depthOffset );
328 void TextView::SetSnapshotModeEnabled( bool enable )
330 GetImpl( *this ).SetSnapshotModeEnabled( enable );
333 bool TextView::IsSnapshotModeEnabled() const
335 return GetImpl( *this ).IsSnapshotModeEnabled();
338 void TextView::SetScrollEnabled( bool enable )
340 GetImpl( *this ).SetScrollEnabled( enable );
343 bool TextView::IsScrollEnabled() const
345 return GetImpl( *this ).IsScrollEnabled();
348 void TextView::SetScrollPosition( const Vector2& position )
350 GetImpl( *this ).SetScrollPosition( position );
353 const Vector2& TextView::GetScrollPosition() const
355 return GetImpl( *this ).GetScrollPosition();
358 bool TextView::IsScrollPositionTrimmed() const
360 return GetImpl( *this ).IsScrollPositionTrimmed();
363 TextView::ScrolledSignalV2& TextView::ScrolledSignal()
365 return GetImpl( *this ).ScrolledSignal();
368 void TextView::SetMarkupProcessingEnabled( bool enable )
370 return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
373 bool TextView::IsMarkupProcessingEnabled() const
375 return GetImpl( *this ).IsMarkupProcessingEnabled();
378 TextView::TextView( Internal::TextView& implementation )
379 : Control( implementation )
383 } // namespace Toolkit