23fa0e9d2178dddfdfdfa10795c1ee0527bb4512
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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/decorator/text-decorator.h>
25 #include <dali-toolkit/internal/text/text-control-interface.h>
26 #include <dali-toolkit/internal/text/text-controller.h>
27 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal
36 {
37
38 /**
39  * @brief A control which renders a short text string.
40  */
41 class TextField : public Control, public Text::ControlInterface
42 {
43 public:
44
45   /**
46    * @copydoc Dali::Toollkit::TextField::New()
47    */
48   static Toolkit::TextField New();
49
50   // Properties
51
52   /**
53    * Called when a property of an object of this type is set.
54    * @param[in] object The object whose property is set.
55    * @param[in] index The property index.
56    * @param[in] value The new property value.
57    */
58   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
59
60   /**
61    * Called to retrieve a property of an object of this type.
62    * @param[in] object The object whose property is to be retrieved.
63    * @param[in] index The property index.
64    * @return The current value of the property.
65    */
66   static Property::Value GetProperty( BaseObject* object, Property::Index index );
67
68 private: // From Control
69
70   /**
71    * @copydoc Control::OnInitialize()
72    */
73   virtual void OnInitialize();
74
75   /**
76    * @copydoc Control::GetNaturalSize()
77    */
78   virtual Vector3 GetNaturalSize();
79
80   /**
81    * @copydoc Control::GetHeightForWidth()
82    */
83   virtual float GetHeightForWidth( float width );
84
85   /**
86    * @copydoc Control::OnInitialize()
87    */
88   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
89
90   /**
91    * Received for single & double taps
92    */
93   virtual void OnTap( const TapGesture& tap );
94
95   /**
96    * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
97    */
98   virtual bool OnKeyEvent(const KeyEvent& event);
99
100   /**
101    * @copydoc Text::ControlInterface::RequestTextRelayout()
102    */
103   virtual void RequestTextRelayout();
104
105 private: // Implementation
106
107   /**
108    * Construct a new TextField.
109    */
110   TextField();
111
112   /**
113    * A reference counted object may only be deleted by calling Unreference()
114    */
115   virtual ~TextField();
116
117 private:
118
119   // Undefined copy constructor and assignment operators
120   TextField(const TextField&);
121   TextField& operator=(const TextField& rhs);
122
123 private: // Data
124
125   Text::ControllerPtr mController;
126   Text::RendererPtr mRenderer;
127   Text::DecoratorPtr mDecorator;
128
129   unsigned int mRenderingBackend;
130 };
131
132 } // namespace Internal
133
134 // Helpers for public-api forwarding methods
135
136 inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
137 {
138   DALI_ASSERT_ALWAYS(textField);
139
140   Dali::RefObject& handle = textField.GetImplementation();
141
142   return static_cast<Toolkit::Internal::TextField&>(handle);
143 }
144
145 inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
146 {
147   DALI_ASSERT_ALWAYS(textField);
148
149   const Dali::RefObject& handle = textField.GetImplementation();
150
151   return static_cast<const Toolkit::Internal::TextField&>(handle);
152 }
153
154 } // namespace Toolkit
155
156 } // namespace Dali
157
158 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__