2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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>
23 #include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
32 const char* const TextView::SIGNAL_TEXT_SCROLLED = "scrolled";
34 TextView::CharacterLayoutInfo::CharacterLayoutInfo()
37 mIsNewLineChar( 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.mIsNewLineChar ),
52 mIsRightToLeftCharacter( characterLayoutInfo.mIsRightToLeftCharacter ),
53 mIsVisible( characterLayoutInfo.mIsVisible ),
54 mDescender( characterLayoutInfo.mDescender )
58 TextView::CharacterLayoutInfo& TextView::CharacterLayoutInfo::operator=( const TextView::CharacterLayoutInfo& characterLayoutInfo )
60 mSize = characterLayoutInfo.mSize;
61 mPosition = characterLayoutInfo.mPosition;
62 mIsNewLineChar = characterLayoutInfo.mIsNewLineChar;
63 mIsRightToLeftCharacter = characterLayoutInfo.mIsRightToLeftCharacter;
64 mIsVisible = characterLayoutInfo.mIsVisible;
65 mDescender = characterLayoutInfo.mDescender;
70 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
71 const Vector3& position,
73 bool isRightToLeftCharacter,
77 mPosition( position ),
78 mIsNewLineChar( isNewLineChar ),
79 mIsRightToLeftCharacter( isRightToLeftCharacter ),
80 mIsVisible( isVisible ),
81 mDescender( descender )
85 TextView::TextLayoutInfo::TextLayoutInfo()
86 : mCharacterLayoutInfoTable(),
88 mCharacterLogicalToVisualMap(),
89 mCharacterVisualToLogicalMap(),
95 TextView::TextLayoutInfo::~TextLayoutInfo()
99 TextView::TextLayoutInfo::TextLayoutInfo( const TextView::TextLayoutInfo& textLayoutInfo )
100 : mCharacterLayoutInfoTable( textLayoutInfo.mCharacterLayoutInfoTable ),
101 mLines( textLayoutInfo.mLines ),
102 mCharacterLogicalToVisualMap( textLayoutInfo.mCharacterLogicalToVisualMap ),
103 mCharacterVisualToLogicalMap( textLayoutInfo.mCharacterVisualToLogicalMap ),
104 mTextSize( textLayoutInfo.mTextSize ),
105 mScrollOffset( textLayoutInfo.mScrollOffset )
109 TextView::TextLayoutInfo& TextView::TextLayoutInfo::operator=( const TextView::TextLayoutInfo& textLayoutInfo )
111 mCharacterLayoutInfoTable = textLayoutInfo.mCharacterLayoutInfoTable;
112 mLines = textLayoutInfo.mLines;
113 mCharacterLogicalToVisualMap = textLayoutInfo.mCharacterLogicalToVisualMap;
114 mCharacterVisualToLogicalMap = textLayoutInfo.mCharacterVisualToLogicalMap;
115 mTextSize = textLayoutInfo.mTextSize;
116 mScrollOffset = textLayoutInfo.mScrollOffset;
121 TextView::FadeBoundary::FadeBoundary()
129 TextView::FadeBoundary::FadeBoundary( PixelSize left, PixelSize right, PixelSize top, PixelSize bottom )
141 TextView::TextView( const TextView& handle )
146 TextView::TextView( Dali::Internal::CustomActor* internal )
147 : Control( internal )
149 VerifyCustomActorPointer<Internal::TextView>(internal);
152 TextView& TextView::operator=( const TextView& handle )
154 if( &handle != this )
156 Control::operator=( handle );
161 TextView TextView::New()
163 return Internal::TextView::New();
166 TextView TextView::New( const std::string& text )
168 TextView textView = Internal::TextView::New();
169 textView.SetText( text );
173 TextView TextView::New( const MarkupProcessor::StyledTextArray& text )
175 TextView textView = Internal::TextView::New();
176 textView.SetText( text );
180 TextView TextView::DownCast( BaseHandle handle )
182 return Control::DownCast<TextView, Internal::TextView>(handle);
185 TextView::~TextView()
189 void TextView::SetText( const std::string& text )
191 GetImpl( *this ).SetText( text );
194 void TextView::SetText( const MarkupProcessor::StyledTextArray& text )
196 GetImpl( *this ).SetText( text );
199 void TextView::InsertTextAt( std::size_t position, const std::string& text )
201 GetImpl( *this ).InsertTextAt( position, text );
204 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
206 GetImpl( *this ).InsertTextAt( position, text );
209 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
211 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
214 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
216 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
219 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
221 GetImpl( *this ).RemoveTextFrom( position, numberOfCharacters );
224 std::string TextView::GetText() const
226 return GetImpl( *this ).GetText();
229 void TextView::SetLineHeightOffset( PointSize offset )
231 GetImpl( *this ).SetLineHeightOffset( offset );
234 PointSize TextView::GetLineHeightOffset() const
236 return GetImpl( *this ).GetLineHeightOffset();
239 void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask mask )
241 GetImpl( *this ).SetStyleToCurrentText( style, mask );
244 void TextView::SetTextAlignment( Alignment::Type align )
246 GetImpl( *this ).SetTextAlignment( align );
249 Alignment::Type TextView::GetTextAlignment() const
251 return GetImpl( *this ).GetTextAlignment();
254 void TextView::SetMultilinePolicy( TextView::MultilinePolicy policy )
256 GetImpl( *this ).SetMultilinePolicy( policy );
259 TextView::MultilinePolicy TextView::GetMultilinePolicy() const
261 return GetImpl( *this ).GetMultilinePolicy();
264 void TextView::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
266 GetImpl( *this ).SetWidthExceedPolicy( policy );
269 TextView::ExceedPolicy TextView::GetWidthExceedPolicy() const
271 return GetImpl( *this ).GetWidthExceedPolicy();
274 void TextView::SetHeightExceedPolicy( ExceedPolicy policy )
276 GetImpl( *this ).SetHeightExceedPolicy( policy );
279 TextView::ExceedPolicy TextView::GetHeightExceedPolicy() const
281 return GetImpl( *this ).GetHeightExceedPolicy();
284 void TextView::SetLineJustification( TextView::LineJustification justification )
286 GetImpl( *this ).SetLineJustification( justification );
289 TextView::LineJustification TextView::GetLineJustification() const
291 return GetImpl( *this ).GetLineJustification();
294 void TextView::SetFadeBoundary( const TextView::FadeBoundary& fadeBoundary )
296 GetImpl( *this ).SetFadeBoundary( fadeBoundary );
299 const TextView::FadeBoundary& TextView::GetFadeBoundary() const
301 return GetImpl( *this ).GetFadeBoundary();
304 void TextView::SetEllipsizeText( const std::string& ellipsizeText )
306 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
309 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
311 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
314 std::string TextView::GetEllipsizeText() const
316 return GetImpl( *this ).GetEllipsizeText();
319 void TextView::GetTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
321 GetImpl( *this ).GetTextLayoutInfo( textLayoutInfo );
324 void TextView::SetSortModifier( float depthOffset )
326 GetImpl( *this ).SetSortModifier( depthOffset );
329 void TextView::SetSnapshotModeEnabled( bool enable )
331 GetImpl( *this ).SetSnapshotModeEnabled( enable );
334 bool TextView::IsSnapshotModeEnabled() const
336 return GetImpl( *this ).IsSnapshotModeEnabled();
339 void TextView::SetScrollEnabled( bool enable )
341 GetImpl( *this ).SetScrollEnabled( enable );
344 bool TextView::IsScrollEnabled() const
346 return GetImpl( *this ).IsScrollEnabled();
349 void TextView::SetScrollPosition( const Vector2& position )
351 GetImpl( *this ).SetScrollPosition( position );
354 const Vector2& TextView::GetScrollPosition() const
356 return GetImpl( *this ).GetScrollPosition();
359 bool TextView::IsScrollPositionTrimmed() const
361 return GetImpl( *this ).IsScrollPositionTrimmed();
364 TextView::ScrolledSignalV2& TextView::ScrolledSignal()
366 return GetImpl( *this ).ScrolledSignal();
369 void TextView::SetMarkupProcessingEnabled( bool enable )
371 return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
374 bool TextView::IsMarkupProcessingEnabled() const
376 return GetImpl( *this ).IsMarkupProcessingEnabled();
379 TextView::TextView( Internal::TextView& implementation )
380 : Control( implementation )
384 } // namespace Toolkit