+void Controller::AddDecoration( Actor& actor, bool needsClipping )
+{
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ mImpl->mEditableControlInterface->AddDecoration( actor, needsClipping );
+ }
+}
+
+void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
+{
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
+
+ if( NULL != mImpl->mEventData )
+ {
+ switch( handleType )
+ {
+ case GRAB_HANDLE:
+ {
+ Event event( Event::GRAB_HANDLE_EVENT );
+ event.p1.mUint = state;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+
+ mImpl->mEventData->mEventQueue.push_back( event );
+ break;
+ }
+ case LEFT_SELECTION_HANDLE:
+ {
+ Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
+ event.p1.mUint = state;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+
+ mImpl->mEventData->mEventQueue.push_back( event );
+ break;
+ }
+ case RIGHT_SELECTION_HANDLE:
+ {
+ Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
+ event.p1.mUint = state;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+
+ mImpl->mEventData->mEventQueue.push_back( event );
+ break;
+ }
+ case LEFT_SELECTION_HANDLE_MARKER:
+ case RIGHT_SELECTION_HANDLE_MARKER:
+ {
+ // Markers do not move the handles.
+ break;
+ }
+ case HANDLE_TYPE_COUNT:
+ {
+ DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
+ }
+ }
+
+ mImpl->RequestRelayout();
+ }
+}
+
+// protected : Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
+
+void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
+{
+ if( NULL == mImpl->mEventData )
+ {
+ return;
+ }
+
+ switch( button )
+ {
+ case Toolkit::TextSelectionPopup::CUT:
+ {
+ mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+
+ if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
+ !mImpl->IsPlaceholderAvailable() )
+ {
+ mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
+ }
+ else
+ {
+ ShowPlaceholderText();
+ }
+
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;
+
+ mImpl->RequestRelayout();
+
+ if( NULL != mImpl->mEditableControlInterface )
+ {
+ mImpl->mEditableControlInterface->TextChanged();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::COPY:
+ {
+ mImpl->SendSelectionToClipboard( false ); // Text not modified
+
+ mImpl->mEventData->mUpdateCursorPosition = true;
+
+ mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
+ break;
+ }
+ case Toolkit::TextSelectionPopup::PASTE:
+ {
+ mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
+ break;
+ }
+ case Toolkit::TextSelectionPopup::SELECT:
+ {
+ const Vector2& currentCursorPosition = mImpl->mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+
+ if( mImpl->mEventData->mSelectionEnabled )
+ {
+ // Creates a SELECT event.
+ SelectEvent( currentCursorPosition.x, currentCursorPosition.y, false );
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::SELECT_ALL:
+ {
+ // Creates a SELECT_ALL event
+ SelectEvent( 0.f, 0.f, true );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::CLIPBOARD:
+ {
+ mImpl->ShowClipboard();
+ break;
+ }
+ case Toolkit::TextSelectionPopup::NONE:
+ {
+ // Nothing to do.
+ break;
+ }
+ }
+}
+
+void Controller::DisplayTimeExpired()
+{
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ // Apply modifications to the model
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+
+ mImpl->RequestRelayout();
+}
+
+// private : Update.
+
+void Controller::InsertText( const std::string& text, Controller::InsertType type )
+{
+ bool removedPrevious = false;
+ bool removedSelected = false;
+ bool maxLengthReached = false;
+
+ DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" )
+
+ if( NULL == mImpl->mEventData )
+ {
+ return;
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n",
+ this, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"),
+ mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
+
+ // TODO: At the moment the underline runs are only for pre-edit.
+ mImpl->mModel->mVisualModel->mUnderlineRuns.Clear();
+
+ // Remove the previous IMF pre-edit.
+ if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) )
+ {
+ removedPrevious = RemoveText( -static_cast<int>( mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition ),
+ mImpl->mEventData->mPreEditLength,
+ DONT_UPDATE_INPUT_STYLE );
+
+ mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
+ mImpl->mEventData->mPreEditLength = 0u;
+ }