+ // Convert text into UTF-32
+ Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
+ utf32Characters.Resize( textSize );
+
+ // Transform a text array encoded in utf8 into an array encoded in utf32.
+ // It returns the actual number of characters.
+ Length characterCount = Utf8ToUtf32( utf8, textSize, utf32Characters.Begin() );
+ utf32Characters.Resize( characterCount );
+
+ DALI_ASSERT_DEBUG( textSize >= characterCount && "Invalid UTF32 conversion length" );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mLogicalModel->mText.Count() );
+
+ // The characters to be added.
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
+
+ // To reset the cursor position
+ lastCursorIndex = characterCount;
+
+ // Update the rest of the model during size negotiation
+ mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
+
+ // The natural size needs to be re-calculated.
+ mImpl->mRecalculateNaturalSize = true;
+
+ // Apply modifications to the model
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+ }
+ else
+ {
+ ShowPlaceholderText();
+ }
+
+ // Resets the cursor position.
+ ResetCursorPosition( lastCursorIndex );
+
+ // Scrolls the text to make the cursor visible.
+ ResetScrollPosition();
+
+ mImpl->RequestRelayout();
+
+ if( NULL != mImpl->mEventData )
+ {
+ // Cancel previously queued events
+ mImpl->mEventData->mEventQueue.clear();
+ }
+
+ // Do this last since it provides callbacks into application code.
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ mImpl->mEditableControlInterface->TextChanged();
+ }
+}
+
+void Controller::GetText( std::string& text ) const
+{
+ if( !mImpl->IsShowingPlaceholderText() )
+ {
+ // Retrieves the text string.
+ mImpl->GetText( 0u, text );
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetText %p empty (but showing placeholder)\n", this );
+ }
+}
+
+void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( PLACEHOLDER_TYPE_INACTIVE == type )
+ {
+ mImpl->mEventData->mPlaceholderTextInactive = text;
+ }
+ else
+ {
+ mImpl->mEventData->mPlaceholderTextActive = text;
+ }
+
+ // Update placeholder if there is no text
+ if( mImpl->IsShowingPlaceholderText() ||
+ ( 0u == mImpl->mLogicalModel->mText.Count() ) )
+ {
+ ShowPlaceholderText();
+ }
+ }
+}
+
+void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( PLACEHOLDER_TYPE_INACTIVE == type )
+ {
+ text = mImpl->mEventData->mPlaceholderTextInactive;
+ }
+ else
+ {
+ text = mImpl->mEventData->mPlaceholderTextActive;
+ }
+ }
+}
+
+void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange\n");
+
+ if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
+ mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
+
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+ }
+}
+
+// public : Default style & Input style
+
+void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
+{
+ if( NULL == mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str());
+ mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty();
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+}
+
+const std::string& Controller::GetDefaultFontFamily() const
+{
+ if( NULL != mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontDescription.family;
+ }
+
+ return EMPTY_STRING;
+}
+
+void Controller::SetDefaultFontWeight( FontWeight weight )
+{
+ if( NULL == mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.weight = weight;
+ mImpl->mFontDefaults->weightDefined = true;
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+}
+
+bool Controller::IsDefaultFontWeightDefined() const
+{
+ return mImpl->mFontDefaults->weightDefined;
+}
+
+FontWeight Controller::GetDefaultFontWeight() const
+{
+ if( NULL != mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontDescription.weight;
+ }
+
+ return TextAbstraction::FontWeight::NORMAL;
+}
+
+void Controller::SetDefaultFontWidth( FontWidth width )
+{
+ if( NULL == mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.width = width;
+ mImpl->mFontDefaults->widthDefined = true;
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+}
+
+bool Controller::IsDefaultFontWidthDefined() const
+{
+ return mImpl->mFontDefaults->widthDefined;
+}
+
+FontWidth Controller::GetDefaultFontWidth() const
+{
+ if( NULL != mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontDescription.width;
+ }
+
+ return TextAbstraction::FontWidth::NORMAL;
+}
+
+void Controller::SetDefaultFontSlant( FontSlant slant )
+{
+ if( NULL == mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.slant = slant;
+ mImpl->mFontDefaults->slantDefined = true;
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+}
+
+bool Controller::IsDefaultFontSlantDefined() const
+{
+ return mImpl->mFontDefaults->slantDefined;
+}
+
+FontSlant Controller::GetDefaultFontSlant() const
+{
+ if( NULL != mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontDescription.slant;
+ }
+
+ return TextAbstraction::FontSlant::NORMAL;
+}
+
+void Controller::SetDefaultPointSize( float pointSize )
+{
+ if( NULL == mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mDefaultPointSize = pointSize;
+ mImpl->mFontDefaults->sizeDefined = true;
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+}
+
+float Controller::GetDefaultPointSize() const
+{
+ if( NULL != mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mDefaultPointSize;
+ }
+
+ return 0.0f;
+}
+
+void Controller::SetTextColor( const Vector4& textColor )
+{
+ mImpl->mTextColor = textColor;
+
+ if( !mImpl->IsShowingPlaceholderText() )
+ {
+ mImpl->mVisualModel->SetTextColor( textColor );
+
+ mImpl->RequestRelayout();
+ }
+}
+
+const Vector4& Controller::GetTextColor() const
+{
+ return mImpl->mTextColor;
+}
+
+void Controller::SetPlaceholderTextColor( const Vector4& textColor )
+{
+ if( NULL != mImpl->mEventData )