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 );
71 private: // From Control
74 * @copydoc Control::OnInitialize()
76 virtual void OnInitialize();
79 * @copydoc Control::OnStyleChange()
81 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
84 * @copydoc Control::GetNaturalSize()
86 virtual Vector3 GetNaturalSize();
89 * @copydoc Control::GetHeightForWidth()
91 virtual float GetHeightForWidth( float width );
94 * @copydoc Control::OnInitialize()
96 virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
99 * Received for single & double taps
101 virtual void OnTap( const TapGesture& tap );
104 * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
106 virtual bool OnKeyEvent(const KeyEvent& event);
109 * @copydoc Text::ControlInterface::RequestTextRelayout()
111 virtual void RequestTextRelayout();
113 private: // Implementation
116 * @brief Enable or disable clipping.
118 * @param[in] clipping True if clipping should be enabled.
119 * @param[in] size The area to clip within.
121 void EnableClipping( bool clipping, const Vector2& size );
124 * Construct a new TextField.
129 * A reference counted object may only be deleted by calling Unreference()
131 virtual ~TextField();
135 // Undefined copy constructor and assignment operators
136 TextField(const TextField&);
137 TextField& operator=(const TextField& rhs);
141 Text::ControllerPtr mController;
142 Text::RendererPtr mRenderer;
143 Text::DecoratorPtr mDecorator;
144 Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
146 RenderableActor mRenderableActor;
148 int mRenderingBackend;
152 } // namespace Internal
154 // Helpers for public-api forwarding methods
156 inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
158 DALI_ASSERT_ALWAYS(textField);
160 Dali::RefObject& handle = textField.GetImplementation();
162 return static_cast<Toolkit::Internal::TextField&>(handle);
165 inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
167 DALI_ASSERT_ALWAYS(textField);
169 const Dali::RefObject& handle = textField.GetImplementation();
171 return static_cast<const Toolkit::Internal::TextField&>(handle);
174 } // namespace Toolkit
178 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__