1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
27 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
28 #include <dali-toolkit/internal/text/text-control-interface.h>
29 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
30 #include <dali-toolkit/internal/text/text-controller.h>
31 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
43 * @brief A control which renders a long text string with styles.
45 class TextEditor : public Control, public Text::ControlInterface, public Text::EditableControlInterface
50 * @copydoc Dali::Toollkit::TextEditor::New()
52 static Toolkit::TextEditor New();
57 * @brief Called when a property of an object of this type is set.
59 * @param[in] object The object whose property is set.
60 * @param[in] index The property index.
61 * @param[in] value The new property value.
63 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
66 * @brief Called to retrieve a property of an object of this type.
68 * @param[in] object The object whose property is to be retrieved.
69 * @param[in] index The property index.
70 * @return The current value of the property.
72 static Property::Value GetProperty( BaseObject* object, Property::Index index );
75 * Connects a callback function with the object's signals.
76 * @param[in] object The object providing the signal.
77 * @param[in] tracker Used to disconnect the signal.
78 * @param[in] signalName The signal to connect to.
79 * @param[in] functor A newly allocated FunctorDelegate.
80 * @return True if the signal was connected.
81 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
83 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
86 * @copydoc TextEditor::TextChangedSignal()
88 Toolkit::TextEditor::TextChangedSignalType& TextChangedSignal();
91 * @copydoc TextEditor::TextChangedSignal()
93 Toolkit::TextEditor::InputStyleChangedSignalType& InputStyleChangedSignal();
95 private: // From Control
98 * @copydoc Control::OnInitialize()
100 virtual void OnInitialize();
103 * @copydoc Control::OnStyleChange()
105 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
108 * @copydoc Control::GetNaturalSize()
110 virtual Vector3 GetNaturalSize();
113 * @copydoc Control::GetHeightForWidth()
115 virtual float GetHeightForWidth( float width );
118 * @copydoc Control::OnInitialize()
120 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
123 * @copydoc Control::OnKeyInputFocusGained()
125 virtual void OnKeyInputFocusGained();
128 * @copydoc Control::OnKeyInputFocusLost()
130 virtual void OnKeyInputFocusLost();
133 * @copydoc Control::OnTap()
135 virtual void OnTap( const TapGesture& tap );
138 * @copydoc Control::OnPan()
140 virtual void OnPan( const PanGesture& gesture );
143 * @copydoc Control::OnLongPress()
145 virtual void OnLongPress( const LongPressGesture& gesture );
148 * @copydoc Control::OnStageConnection()
150 virtual void OnStageConnection( int depth );
153 * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
155 virtual bool OnKeyEvent(const KeyEvent& event);
157 // From ControlInterface
160 * @copydoc Text::ControlInterface::RequestTextRelayout()
162 virtual void RequestTextRelayout();
164 // From EditableControlInterface
167 * @copydoc Text::ControlInterface::TextChanged()
169 virtual void TextChanged();
172 * @copydoc Text::ControlInterface::MaxLengthReached()
174 virtual void MaxLengthReached();
177 * @copydoc Text::ControlInterface::InputStyleChanged()
179 virtual void InputStyleChanged( Text::InputStyle::Mask inputStyleMask );
182 * @copydoc Text::ControlInterface::AddDecoration()
184 virtual void AddDecoration( Actor& actor, bool needsClipping );
186 private: // Implementation
189 * @copydoc Dali::Toolkit::Text::Controller::(ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent)
191 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
194 * @brief Callback when Clipboard signals an item should be pasted
195 * @param[in] clipboard handle to Clipboard Event Notifier
197 void OnClipboardTextSelected( ClipboardEventNotifier& clipboard );
200 * @brief Get a Property Map for the image used for the required Handle Image
201 * @param[out] value the returned image property
202 * @param[in] handleType the type of handle
203 * @param[in] handleImageType the type of image for the given handleType
205 void GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType );
208 * @brief Callback when keyboard is shown/hidden.
210 * @param[in] keyboardShown True if keyboard is shown.
212 void KeyboardStatusChanged( bool keyboardShown );
215 * @brief Callback when TextEditor is touched
217 * @param[in] actor TextEditor touched
218 * @param[in] touch Touch information
220 bool OnTouched( Actor actor, const TouchData& touch );
223 * @brief Callbacks called on idle.
225 * If there are notifications of change of input style on the queue, Toolkit::TextEditor::InputStyleChangedSignal() are emitted.
230 * Construct a new TextEditor.
235 * A reference counted object may only be deleted by calling Unreference()
237 virtual ~TextEditor();
239 // Undefined copy constructor and assignment operators
240 TextEditor(const TextEditor&);
241 TextEditor& operator=(const TextEditor& rhs);
244 * @brief Render view, create and attach actor(s) to this text editor.
246 void RenderText( Text::Controller::UpdateTextType updateTextType );
248 // Connection needed to re-render text, when a text editor returns to the stage.
249 void OnStageConnect( Dali::Actor actor );
254 Toolkit::TextEditor::TextChangedSignalType mTextChangedSignal;
255 Toolkit::TextEditor::InputStyleChangedSignalType mInputStyleChangedSignal;
257 Text::ControllerPtr mController;
258 Text::RendererPtr mRenderer;
259 Text::DecoratorPtr mDecorator;
260 Toolkit::Control mStencil;
261 std::vector<Actor> mClippingDecorationActors; ///< Decoration actors which need clipping.
263 Actor mRenderableActor;
264 CallbackBase* mIdleCallback;
266 float mAlignmentOffset;
267 int mRenderingBackend;
268 bool mHasBeenStaged:1;
271 } // namespace Internal
273 // Helpers for public-api forwarding methods
275 inline Toolkit::Internal::TextEditor& GetImpl( Toolkit::TextEditor& textEditor )
277 DALI_ASSERT_ALWAYS(textEditor);
279 Dali::RefObject& handle = textEditor.GetImplementation();
281 return static_cast<Toolkit::Internal::TextEditor&>(handle);
284 inline const Toolkit::Internal::TextEditor& GetImpl( const Toolkit::TextEditor& textEditor )
286 DALI_ASSERT_ALWAYS(textEditor);
288 const Dali::RefObject& handle = textEditor.GetImplementation();
290 return static_cast<const Toolkit::Internal::TextEditor&>(handle);
293 } // namespace Toolkit
297 #endif // DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H