1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
5 * Copyright (c) 2015 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/public-api/adaptor-framework/imf-manager.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/text-controls/text-field.h>
27 #include <dali-toolkit/internal/text/clipping/text-clipper.h>
28 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
29 #include <dali-toolkit/internal/text/text-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 short text string.
45 class TextField : public Control, public Text::ControlInterface
50 * @copydoc Dali::Toollkit::TextField::New()
52 static Toolkit::TextField 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 );
74 private: // From Control
77 * @copydoc Control::OnInitialize()
79 virtual void OnInitialize();
82 * @copydoc Control::OnStyleChange()
84 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
87 * @copydoc Control::GetNaturalSize()
89 virtual Vector3 GetNaturalSize();
92 * @copydoc Control::GetHeightForWidth()
94 virtual float GetHeightForWidth( float width );
97 * @copydoc Control::OnInitialize()
99 virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
102 * @copydoc Control::OnKeyInputFocusGained()
104 virtual void OnKeyInputFocusGained();
107 * @copydoc Control::OnKeyInputFocusLost()
109 virtual void OnKeyInputFocusLost();
112 * Received for single & double taps
114 virtual void OnTap( const TapGesture& tap );
117 * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
119 virtual bool OnKeyEvent(const KeyEvent& event);
122 * @brief Event received from IMF manager
124 * @param[in] imfManager The IMF manager.
125 * @param[in] imfEvent The event received.
126 * @return A data struture indicating if update is needed, cursor position and current text.
128 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
131 * @copydoc Text::ControlInterface::RequestTextRelayout()
133 virtual void RequestTextRelayout();
135 private: // Implementation
138 * @brief Enable or disable clipping.
140 * @param[in] clipping True if clipping should be enabled.
141 * @param[in] size The area to clip within.
143 void EnableClipping( bool clipping, const Vector2& size );
146 * @brief Callback when keyboard is shown/hidden.
148 * @param[in] keyboardShown True if keyboard is shown.
150 void KeyboardStatusChanged( bool keyboardShown );
153 * Construct a new TextField.
158 * A reference counted object may only be deleted by calling Unreference()
160 virtual ~TextField();
164 // Undefined copy constructor and assignment operators
165 TextField(const TextField&);
166 TextField& operator=(const TextField& rhs);
170 Text::ControllerPtr mController;
171 Text::RendererPtr mRenderer;
172 Text::DecoratorPtr mDecorator;
173 Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
175 RenderableActor mRenderableActor;
177 int mRenderingBackend;
181 } // namespace Internal
183 // Helpers for public-api forwarding methods
185 inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
187 DALI_ASSERT_ALWAYS(textField);
189 Dali::RefObject& handle = textField.GetImplementation();
191 return static_cast<Toolkit::Internal::TextField&>(handle);
194 inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
196 DALI_ASSERT_ALWAYS(textField);
198 const Dali::RefObject& handle = textField.GetImplementation();
200 return static_cast<const Toolkit::Internal::TextField&>(handle);
203 } // namespace Toolkit
207 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__