+ if( impl.mController )
+ {
+ // LINE_SPACING isn't implemented for the TextEditor. Returning
+ // only shadowed value, not the real one.
+ value = impl.mLineSpacing;
+ }
+ break;
+ }
+ case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetInputLineSpacing();
+ }
+ break;
+ }
+ case Toolkit::TextEditor::Property::UNDERLINE:
+ {
+ GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
+ {
+ GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::SHADOW:
+ {
+ GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::INPUT_SHADOW:
+ {
+ GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::EMBOSS:
+ {
+ GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::INPUT_EMBOSS:
+ {
+ GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::OUTLINE:
+ {
+ GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::INPUT_OUTLINE:
+ {
+ GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextEditor::Property::SMOOTH_SCROLL:
+ {
+ value = impl.mScrollAnimationEnabled;
+ break;
+ }
+ case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION:
+ {
+ value = impl.mScrollAnimationDuration;
+ break;
+ }
+ case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR:
+ {
+ value = impl.mScrollBarEnabled;
+ break;
+ }
+ case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION:
+ {
+ value = impl.mAnimationPeriod.delaySeconds;
+ break;
+ }
+ case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION:
+ {
+ value = impl.mAnimationPeriod.durationSeconds;
+ break;
+ }
+ case Toolkit::TextEditor::Property::PIXEL_SIZE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE );
+ }
+ break;
+ }
+ case Toolkit::TextEditor::Property::LINE_COUNT:
+ {
+ if( impl.mController )
+ {
+ float width = textEditor.GetProperty( Actor::Property::SIZE_WIDTH ).Get<float>();
+ value = impl.mController->GetLineCount( width );
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT:
+ {
+ if( impl.mController )
+ {
+ std::string text;
+ impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
+ value = text;
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetPlaceholderTextColor();
+ }
+ break;
+ }
+ case Toolkit::TextEditor::Property::ENABLE_SELECTION:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsSelectionEnabled();
+ }
+ break;
+ }
+ case Toolkit::TextEditor::Property::PLACEHOLDER:
+ {
+ Property::Map map;
+ impl.mController->GetPlaceholderProperty( map );
+ value = map;
+ break;
+ }
+ case Toolkit::TextEditor::Property::LINE_WRAP_MODE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetLineWrapMode();
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsShiftSelectionEnabled();
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsGrabHandleEnabled();
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsMatchSystemLanguageDirection();
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetMaximumNumberOfCharacters();
+ }
+ break;
+ }
+ } //switch
+ }
+
+ return value;
+}
+
+InputMethodContext TextEditor::GetInputMethodContext()
+{
+ return mInputMethodContext;
+}
+
+DevelTextEditor::MaxLengthReachedSignalType& TextEditor::MaxLengthReachedSignal()
+{
+ return mMaxLengthReachedSignal;
+}
+
+bool TextEditor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ Dali::BaseHandle handle( object );
+
+ bool connected( true );
+ Toolkit::TextEditor editor = Toolkit::TextEditor::DownCast( handle );
+
+ if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
+ {
+ editor.TextChangedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED ) )
+ {
+ editor.InputStyleChangedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) )
+ {
+ if( editor )
+ {
+ Internal::TextEditor& editorImpl( GetImpl( editor ) );
+ editorImpl.MaxLengthReachedSignal().Connect( tracker, functor );
+ }
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+}
+
+Toolkit::TextEditor::TextChangedSignalType& TextEditor::TextChangedSignal()
+{
+ return mTextChangedSignal;
+}
+
+Toolkit::TextEditor::InputStyleChangedSignalType& TextEditor::InputStyleChangedSignal()
+{
+ return mInputStyleChangedSignal;
+}
+
+Toolkit::TextEditor::ScrollStateChangedSignalType& TextEditor::ScrollStateChangedSignal()
+{
+ return mScrollStateChangedSignal;
+}
+
+void TextEditor::OnInitialize()
+{
+ Actor self = Self();
+
+ mController = Text::Controller::New( this, this );
+
+ mDecorator = Text::Decorator::New( *mController,
+ *mController );
+
+ mInputMethodContext = InputMethodContext::New( self );
+
+ mController->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
+
+ // Enables the text input.
+ mController->EnableTextInput( mDecorator, mInputMethodContext );
+
+ // Enables the vertical scrolling after the text input has been enabled.
+ mController->SetVerticalScrollEnabled( true );
+
+ // Disables the horizontal scrolling.
+ mController->SetHorizontalScrollEnabled( false );
+
+ // Sets the maximum number of characters.
+ mController->SetMaximumNumberOfCharacters( std::numeric_limits<Length>::max() );
+
+ // Enable the smooth handle panning.
+ mController->SetSmoothHandlePanEnabled( true );
+
+ mController->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT );
+ mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
+
+ // Sets layoutDirection value
+ Dali::Stage stage = Dali::Stage::GetCurrent();
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ mController->SetLayoutDirection( layoutDirection );
+
+ // Forward input events to controller
+ EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
+ GetTapGestureDetector().SetMaximumTapsRequired( 2 );
+
+ self.TouchSignal().Connect( this, &TextEditor::OnTouched );
+
+ // Set BoundingBox to stage size if not already set.
+ Rect<int> boundingBox;
+ mDecorator->GetBoundingBox( boundingBox );
+
+ if( boundingBox.IsEmpty() )
+ {
+ Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
+ mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
+ }
+
+ // Whether to flip the selection handles as soon as they cross.
+ mDecorator->FlipSelectionHandlesOnCrossEnabled( true );
+
+ // Set the default scroll speed.
+ mDecorator->SetScrollSpeed( DEFAULT_SCROLL_SPEED );
+
+ // Fill-parent area by default
+ self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
+ self.OnSceneSignal().Connect( this, &TextEditor::OnSceneConnect );
+
+ DevelControl::SetInputMethodContext( *this, mInputMethodContext );
+
+ // Creates an extra control to be used as stencil buffer.
+ mStencil = Control::New();
+ mStencil.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ mStencil.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+
+ // Creates a background visual. Even if the color is transparent it updates the stencil.
+ mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR ).
+ Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
+
+ // Enable the clipping property.
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
+ mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ self.Add( mStencil );
+}
+
+void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n");
+
+ switch ( change )
+ {
+ case StyleChange::DEFAULT_FONT_CHANGE:
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n");
+ const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
+ // Property system did not set the font so should update it.
+ mController->UpdateAfterFontChange( newFont );
+ RelayoutRequest();