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-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/public-api/controls/text-controls/text-field.h>
24 #include <dali-toolkit/internal/text/clipping/text-clipper.h>
25 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
26 #include <dali-toolkit/internal/text/text-control-interface.h>
27 #include <dali-toolkit/internal/text/text-controller.h>
28 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
40 * @brief A control which renders a short text string.
42 class TextField : public Control, public Text::ControlInterface
47 * @copydoc Dali::Toollkit::TextField::New()
49 static Toolkit::TextField New();
54 * @brief Called when a property of an object of this type is set.
56 * @param[in] object The object whose property is set.
57 * @param[in] index The property index.
58 * @param[in] value The new property value.
60 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
63 * @brief Called to retrieve a property of an object of this type.
65 * @param[in] object The object whose property is to be retrieved.
66 * @param[in] index The property index.
67 * @return The current value of the property.
69 static Property::Value GetProperty( BaseObject* object, Property::Index index );
72 * Connects a callback function with the object's signals.
73 * @param[in] object The object providing the signal.
74 * @param[in] tracker Used to disconnect the signal.
75 * @param[in] signalName The signal to connect to.
76 * @param[in] functor A newly allocated FunctorDelegate.
77 * @return True if the signal was connected.
78 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
80 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
83 * @copydoc TextField::TextChangedSignal()
85 Toolkit::TextField::TextChangedSignalType& TextChangedSignal();
88 * @copydoc TextField::MaxLengthReachedSignal()
90 Toolkit::TextField::MaxLengthReachedSignalType& MaxLengthReachedSignal();
92 private: // From Control
95 * @copydoc Control::OnInitialize()
97 virtual void OnInitialize();
100 * @copydoc Control::OnStyleChange()
102 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
105 * @copydoc Control::GetNaturalSize()
107 virtual Vector3 GetNaturalSize();
110 * @copydoc Control::GetHeightForWidth()
112 virtual float GetHeightForWidth( float width );
115 * @copydoc Control::OnInitialize()
117 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
120 * @copydoc Control::OnKeyInputFocusGained()
122 virtual void OnKeyInputFocusGained();
125 * @copydoc Control::OnKeyInputFocusLost()
127 virtual void OnKeyInputFocusLost();
130 * @copydoc Control::OnTap()
132 virtual void OnTap( const TapGesture& tap );
135 * @copydoc Control::OnPan()
137 virtual void OnPan( const PanGesture& gesture );
140 * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
142 virtual bool OnKeyEvent(const KeyEvent& event);
145 * @copydoc Dali::Toolkit::Text::Controller::(ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent)
147 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
150 * @copydoc Text::ControlInterface::RequestTextRelayout()
152 virtual void RequestTextRelayout();
155 * @copydoc Text::ControlInterface::TextChanged()
157 virtual void TextChanged();
160 * @copydoc Text::ControlInterface::MaxLengthReached()
162 virtual void MaxLengthReached();
164 private: // Implementation
167 * @brief Enable or disable clipping.
169 * @param[in] clipping True if clipping should be enabled.
170 * @param[in] size The area to clip within.
172 void EnableClipping( bool clipping, const Vector2& size );
175 * @brief Callback when keyboard is shown/hidden.
177 * @param[in] keyboardShown True if keyboard is shown.
179 void KeyboardStatusChanged( bool keyboardShown );
182 * @brief Callback when Textfield is touched
184 * @param[in] actor TextField touched
185 * @param[in] event TouchEvent information
187 bool OnTouched( Actor actor, const TouchEvent& event );
190 * Construct a new TextField.
195 * A reference counted object may only be deleted by calling Unreference()
197 virtual ~TextField();
199 // Undefined copy constructor and assignment operators
200 TextField(const TextField&);
201 TextField& operator=(const TextField& rhs);
206 Toolkit::TextField::TextChangedSignalType mTextChangedSignal;
207 Toolkit::TextField::MaxLengthReachedSignalType mMaxLengthReachedSignal;
209 Text::ControllerPtr mController;
210 Text::RendererPtr mRenderer;
211 Text::DecoratorPtr mDecorator;
212 Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
214 Actor mRenderableActor;
216 int mRenderingBackend;
220 } // namespace Internal
222 // Helpers for public-api forwarding methods
224 inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
226 DALI_ASSERT_ALWAYS(textField);
228 Dali::RefObject& handle = textField.GetImplementation();
230 return static_cast<Toolkit::Internal::TextField&>(handle);
233 inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
235 DALI_ASSERT_ALWAYS(textField);
237 const Dali::RefObject& handle = textField.GetImplementation();
239 return static_cast<const Toolkit::Internal::TextField&>(handle);
242 } // namespace Toolkit
246 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__