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";
33 const char* const TextView::PROPERTY_TEXT = "text";
34 const char* const TextView::PROPERTY_MULTILINE_POLICY = "multiline-policy";
35 const char* const TextView::PROPERTY_WIDTH_EXCEED_POLICY = "width-exceed-policy";
36 const char* const TextView::PROPERTY_HEIGHT_EXCEED_POLICY = "height-exceed-policy";
37 const char* const TextView::PROPERTY_LINE_JUSTIFICATION = "line-justification";
38 const char* const TextView::PROPERTY_FADE_BOUNDARY_LEFT = "fade-boundary-left";
39 const char* const TextView::PROPERTY_FADE_BOUNDARY_RIGHT = "fade-boundary-right";
40 const char* const TextView::PROPERTY_FADE_BOUNDARY_TOP = "fade-boundary-top";
41 const char* const TextView::PROPERTY_FADE_BOUNDARY_BOTTOM = "fade-boundary-bottom";
42 const char* const TextView::PROPERTY_LINE_HEIGHT_OFFSET = "line-height-offset";
43 const char* const TextView::PROPERTY_HORIZONTAL_ALIGNMENT = "horizontal-alignment";
44 const char* const TextView::PROPERTY_VERTICAL_ALIGNMENT = "vertical-alignment";
46 TextView::CharacterLayoutInfo::CharacterLayoutInfo()
49 mIsNewLineChar( false ),
50 mIsRightToLeftCharacter( false ),
56 TextView::CharacterLayoutInfo::~CharacterLayoutInfo()
60 TextView::CharacterLayoutInfo::CharacterLayoutInfo( 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 )
70 TextView::CharacterLayoutInfo& TextView::CharacterLayoutInfo::operator=( const TextView::CharacterLayoutInfo& characterLayoutInfo )
72 mSize = characterLayoutInfo.mSize;
73 mPosition = characterLayoutInfo.mPosition;
74 mIsNewLineChar = characterLayoutInfo.mIsNewLineChar;
75 mIsRightToLeftCharacter = characterLayoutInfo.mIsRightToLeftCharacter;
76 mIsVisible = characterLayoutInfo.mIsVisible;
77 mDescender = characterLayoutInfo.mDescender;
82 TextView::CharacterLayoutInfo::CharacterLayoutInfo( const Size& size,
83 const Vector3& position,
84 const bool isNewLineChar,
85 const bool isRightToLeftCharacter,
87 const float descender )
89 mPosition( position ),
90 mIsNewLineChar( isNewLineChar ),
91 mIsRightToLeftCharacter( isRightToLeftCharacter ),
92 mIsVisible( isVisible ),
93 mDescender( descender )
97 TextView::TextLayoutInfo::TextLayoutInfo()
98 : mCharacterLayoutInfoTable(),
100 mCharacterLogicalToVisualMap(),
101 mCharacterVisualToLogicalMap(),
107 TextView::TextLayoutInfo::~TextLayoutInfo()
111 TextView::TextLayoutInfo::TextLayoutInfo( 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 )
121 TextView::TextLayoutInfo& TextView::TextLayoutInfo::operator=( const TextView::TextLayoutInfo& textLayoutInfo )
123 mCharacterLayoutInfoTable = textLayoutInfo.mCharacterLayoutInfoTable;
124 mLines = textLayoutInfo.mLines;
125 mCharacterLogicalToVisualMap = textLayoutInfo.mCharacterLogicalToVisualMap;
126 mCharacterVisualToLogicalMap = textLayoutInfo.mCharacterVisualToLogicalMap;
127 mTextSize = textLayoutInfo.mTextSize;
128 mScrollOffset = textLayoutInfo.mScrollOffset;
133 TextView::FadeBoundary::FadeBoundary()
141 TextView::FadeBoundary::FadeBoundary( const PixelSize left, const PixelSize right, const PixelSize top, const PixelSize bottom )
153 TextView::TextView( const TextView& handle )
158 TextView::TextView( Dali::Internal::CustomActor* internal )
159 : Control( internal )
161 VerifyCustomActorPointer<Internal::TextView>(internal);
164 TextView& TextView::operator=( const TextView& handle )
166 if( &handle != this )
168 Control::operator=( handle );
173 TextView TextView::New()
175 return Internal::TextView::New();
178 TextView TextView::New( const std::string& text )
180 TextView textView = Internal::TextView::New();
181 textView.SetText( text );
185 TextView TextView::New( const MarkupProcessor::StyledTextArray& text )
187 TextView textView = Internal::TextView::New();
188 textView.SetText( text );
192 TextView TextView::DownCast( BaseHandle handle )
194 return Control::DownCast<TextView, Internal::TextView>(handle);
197 TextView::~TextView()
201 void TextView::SetText( const std::string& text )
203 GetImpl( *this ).SetText( text );
206 void TextView::SetText( const MarkupProcessor::StyledTextArray& text )
208 GetImpl( *this ).SetText( text );
211 void TextView::InsertTextAt( const std::size_t position, const std::string& text )
213 GetImpl( *this ).InsertTextAt( position, text );
216 void TextView::InsertTextAt( const std::size_t position, const MarkupProcessor::StyledTextArray& text )
218 GetImpl( *this ).InsertTextAt( position, text );
221 void TextView::ReplaceTextFromTo( const std::size_t position, const std::size_t numberOfCharacters, const std::string& text )
223 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
226 void TextView::ReplaceTextFromTo( const std::size_t position, const std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
228 GetImpl( *this ).ReplaceTextFromTo( position, numberOfCharacters, text );
231 void TextView::RemoveTextFrom( const std::size_t position, const std::size_t numberOfCharacters )
233 GetImpl( *this ).RemoveTextFrom( position, numberOfCharacters );
236 std::string TextView::GetText() const
238 return GetImpl( *this ).GetText();
241 void TextView::SetLineHeightOffset( const PointSize offset )
243 GetImpl( *this ).SetLineHeightOffset( offset );
246 PointSize TextView::GetLineHeightOffset() const
248 return GetImpl( *this ).GetLineHeightOffset();
251 void TextView::SetStyleToCurrentText( const TextStyle& style, const TextStyle::Mask mask )
253 GetImpl( *this ).SetStyleToCurrentText( style, mask );
256 void TextView::SetTextAlignment( Alignment::Type align )
258 GetImpl( *this ).SetTextAlignment( align );
261 Alignment::Type TextView::GetTextAlignment() const
263 return GetImpl( *this ).GetTextAlignment();
266 void TextView::SetMultilinePolicy( TextView::MultilinePolicy policy )
268 GetImpl( *this ).SetMultilinePolicy( policy );
271 TextView::MultilinePolicy TextView::GetMultilinePolicy() const
273 return GetImpl( *this ).GetMultilinePolicy();
276 void TextView::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
278 GetImpl( *this ).SetWidthExceedPolicy( policy );
281 TextView::ExceedPolicy TextView::GetWidthExceedPolicy() const
283 return GetImpl( *this ).GetWidthExceedPolicy();
286 void TextView::SetHeightExceedPolicy( ExceedPolicy policy )
288 GetImpl( *this ).SetHeightExceedPolicy( policy );
291 TextView::ExceedPolicy TextView::GetHeightExceedPolicy() const
293 return GetImpl( *this ).GetHeightExceedPolicy();
296 void TextView::SetLineJustification( TextView::LineJustification justification )
298 GetImpl( *this ).SetLineJustification( justification );
301 TextView::LineJustification TextView::GetLineJustification() const
303 return GetImpl( *this ).GetLineJustification();
306 void TextView::SetFadeBoundary( const TextView::FadeBoundary& fadeBoundary )
308 GetImpl( *this ).SetFadeBoundary( fadeBoundary );
311 const TextView::FadeBoundary& TextView::GetFadeBoundary() const
313 return GetImpl( *this ).GetFadeBoundary();
316 void TextView::SetEllipsizeText( const std::string& ellipsizeText )
318 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
321 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
323 GetImpl( *this ).SetEllipsizeText( ellipsizeText );
326 std::string TextView::GetEllipsizeText() const
328 return GetImpl( *this ).GetEllipsizeText();
331 void TextView::GetTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
333 GetImpl( *this ).GetTextLayoutInfo( textLayoutInfo );
336 void TextView::SetSortModifier( float depthOffset )
338 GetImpl( *this ).SetSortModifier( depthOffset );
341 void TextView::SetSnapshotModeEnabled( bool enable )
343 GetImpl( *this ).SetSnapshotModeEnabled( enable );
346 bool TextView::IsSnapshotModeEnabled() const
348 return GetImpl( *this ).IsSnapshotModeEnabled();
351 void TextView::SetScrollEnabled( bool enable )
353 GetImpl( *this ).SetScrollEnabled( enable );
356 bool TextView::IsScrollEnabled() const
358 return GetImpl( *this ).IsScrollEnabled();
361 void TextView::SetScrollPosition( const Vector2& position )
363 GetImpl( *this ).SetScrollPosition( position );
366 const Vector2& TextView::GetScrollPosition() const
368 return GetImpl( *this ).GetScrollPosition();
371 bool TextView::IsScrollPositionTrimmed() const
373 return GetImpl( *this ).IsScrollPositionTrimmed();
376 TextView::ScrolledSignalV2& TextView::ScrolledSignal()
378 return GetImpl( *this ).ScrolledSignal();
381 TextView::TextView( Internal::TextView& implementation )
382 : Control( implementation )
386 } // namespace Toolkit