X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=f9445b51539c6840d1d8b3b1bb96f50cf55b54a4;hp=28118048f2d3f542cd5ca95d641c9a50250c5d4d;hb=003fe1b0cb2900bd60063649e46fbbbb6e7d997d;hpb=e5149e02ac3595cc6f73cca7eb4682f7dbafe00b diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 2811804..f9445b5 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -512,6 +512,22 @@ void Controller::GetText( std::string& text ) const } } +void Controller::SetPlaceholderText( const std::string& text ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mPlaceholderText = text; + + // Update placeholder if there is no text + if( mImpl->IsShowingPlaceholderText() || + ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) ) + { + ShowPlaceholderText(); + } + } +} + +// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text ) { if( NULL != mImpl->mEventData ) @@ -534,6 +550,15 @@ void Controller::SetPlaceholderText( PlaceholderType type, const std::string& te } } +void Controller::GetPlaceholderText( std::string& text ) const +{ + if( NULL != mImpl->mEventData ) + { + text = mImpl->mEventData->mPlaceholderText; + } +} + +// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const { if( NULL != mImpl->mEventData ) @@ -1418,6 +1443,36 @@ Controller::NoTextTap::Action Controller::GetNoTextLongPressAction() const return action; } +bool Controller::IsUnderlineSetByString() +{ + return mImpl->mUnderlineSetByString; +} + +void Controller::UnderlineSetByString( bool setByString ) +{ + mImpl->mUnderlineSetByString = setByString; +} + +bool Controller::IsShadowSetByString() +{ + return mImpl->mShadowSetByString; +} + +void Controller::ShadowSetByString( bool setByString ) +{ + mImpl->mShadowSetByString = setByString; +} + +bool Controller::IsFontStyleSetByString() +{ + return mImpl->mFontStyleSetByString; +} + +void Controller::FontStyleSetByString( bool setByString ) +{ + mImpl->mFontStyleSetByString = setByString; +} + // public : Queries & retrieves. Layout::Engine& Controller::GetLayoutEngine() @@ -1569,6 +1624,13 @@ float Controller::GetHeightForWidth( float width ) return layoutSize.height; } +int Controller::GetLineCount( float width ) +{ + GetHeightForWidth( width ); + int numberofLines = mImpl->mModel->GetNumberOfLines(); + return numberofLines; +} + const ModelInterface* const Controller::GetTextModel() const { return mImpl->mModel.Get(); @@ -2661,12 +2723,12 @@ bool Controller::RemoveText( int cursorOffset, Vector& currentText = mImpl->mModel->mLogicalModel->mText; CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition; - CharacterIndex cursorIndex = oldCursorIndex; + CharacterIndex cursorIndex = 0; // Validate the cursor position & number of characters - if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex ) + if( ( static_cast< int >( mImpl->mEventData->mPrimaryCursorPosition ) + cursorOffset ) >= 0 ) { - cursorIndex = oldCursorIndex + cursorOffset; + cursorIndex = mImpl->mEventData->mPrimaryCursorPosition + cursorOffset; } if( ( cursorIndex + numberOfCharacters ) > currentText.Count() ) @@ -3165,17 +3227,27 @@ void Controller::ShowPlaceholderText() const char* text( NULL ); size_t size( 0 ); - // TODO - Switch placeholder text styles when changing state - if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && - ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) + if( !mImpl->mEventData->mPlaceholderTextActive.empty() || !mImpl->mEventData->mPlaceholderTextInactive.empty() ) { - text = mImpl->mEventData->mPlaceholderTextActive.c_str(); - size = mImpl->mEventData->mPlaceholderTextActive.size(); + if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && + ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) + { + text = mImpl->mEventData->mPlaceholderTextActive.c_str(); + size = mImpl->mEventData->mPlaceholderTextActive.size(); + } + else + { + text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); + size = mImpl->mEventData->mPlaceholderTextInactive.size(); + } } else { - text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); - size = mImpl->mEventData->mPlaceholderTextInactive.size(); + if( 0u != mImpl->mEventData->mPlaceholderText.c_str() ) + { + text = mImpl->mEventData->mPlaceholderText.c_str(); + size = mImpl->mEventData->mPlaceholderText.size(); + } } mImpl->mTextUpdateInfo.mCharacterIndex = 0u;