Added interface for queuing input events in TextController
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_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/public-api/text/decorator/text-decorator.h>
25 #include <dali-toolkit/public-api/text/text-control-interface.h>
26 #include <dali-toolkit/public-api/text/text-controller.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * @brief A control which renders a short text string.
39  */
40 class TextField : public Control, public Text::ControlInterface
41 {
42 public:
43
44   // Properties
45   enum
46   {
47     TEXTFIELD_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
48     TEXTFIELD_PROPERTY_END_INDEX = TEXTFIELD_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
49   };
50
51   /**
52    * @copydoc Dali::Toollkit::TextField::New()
53    */
54   static Toolkit::TextField New();
55
56   /**
57    * @copydoc Dali::Toollkit::TextField::SetRenderer()
58    */
59   void SetRenderer( Text::RendererPtr renderer );
60
61   // Properties
62
63   /**
64    * Called when a property of an object of this type is set.
65    * @param[in] object The object whose property is set.
66    * @param[in] index The property index.
67    * @param[in] value The new property value.
68    */
69   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
70
71   /**
72    * Called to retrieve a property of an object of this type.
73    * @param[in] object The object whose property is to be retrieved.
74    * @param[in] index The property index.
75    * @return The current value of the property.
76    */
77   static Property::Value GetProperty( BaseObject* object, Property::Index index );
78
79 private: // From Control
80
81   /**
82    * @copydoc Control::OnInitialize()
83    */
84   virtual void OnInitialize();
85
86   /**
87    * @copydoc Control::OnInitialize()
88    */
89   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
90
91   /**
92    * @copydoc Control::OnTap()
93    */
94   virtual void OnTap( const TapGesture& tap );
95
96   /**
97    * @copydoc Text::ControlInterface::RequestTextRelayout()
98    */
99   virtual void RequestTextRelayout();
100
101 private: // Implementation
102
103   /**
104    * Construct a new TextField.
105    */
106   TextField();
107
108   /**
109    * A reference counted object may only be deleted by calling Unreference()
110    */
111   virtual ~TextField();
112
113 private:
114
115   // Undefined copy constructor and assignment operators
116   TextField(const TextField&);
117   TextField& operator=(const TextField& rhs);
118
119 private: // Data
120
121   Text::ControllerPtr mController;
122   Text::RendererPtr mRenderer;
123   Text::DecoratorPtr mDecorator;
124 };
125
126 } // namespace Internal
127
128 // Helpers for public-api forwarding methods
129
130 inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textLabel )
131 {
132   DALI_ASSERT_ALWAYS(textLabel);
133
134   Dali::RefObject& handle = textLabel.GetImplementation();
135
136   return static_cast<Toolkit::Internal::TextField&>(handle);
137 }
138
139 inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textLabel )
140 {
141   DALI_ASSERT_ALWAYS(textLabel);
142
143   const Dali::RefObject& handle = textLabel.GetImplementation();
144
145   return static_cast<const Toolkit::Internal::TextField&>(handle);
146 }
147
148 } // namespace Toolkit
149
150 } // namespace Dali
151
152 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__