Framework for Font styles
[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/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>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 /**
40  * @brief A control which renders a short text string.
41  */
42 class TextField : public Control, public Text::ControlInterface
43 {
44 public:
45
46   /**
47    * @copydoc Dali::Toollkit::TextField::New()
48    */
49   static Toolkit::TextField New();
50
51   // Properties
52
53   /**
54    * @brief Called when a property of an object of this type is set.
55    *
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.
59    */
60   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
61
62   /**
63    * @brief Called to retrieve a property of an object of this type.
64    *
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.
68    */
69   static Property::Value GetProperty( BaseObject* object, Property::Index index );
70
71 private: // From Control
72
73   /**
74    * @copydoc Control::OnInitialize()
75    */
76   virtual void OnInitialize();
77
78   /**
79    * @copydoc Control::OnStyleChange()
80    */
81   virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
82
83   /**
84    * @copydoc Control::GetNaturalSize()
85    */
86   virtual Vector3 GetNaturalSize();
87
88   /**
89    * @copydoc Control::GetHeightForWidth()
90    */
91   virtual float GetHeightForWidth( float width );
92
93   /**
94    * @copydoc Control::OnInitialize()
95    */
96   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
97
98   /**
99    * Received for single & double taps
100    */
101   virtual void OnTap( const TapGesture& tap );
102
103   /**
104    * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
105    */
106   virtual bool OnKeyEvent(const KeyEvent& event);
107
108   /**
109    * @copydoc Text::ControlInterface::RequestTextRelayout()
110    */
111   virtual void RequestTextRelayout();
112
113 private: // Implementation
114
115   /**
116    * @brief Enable or disable clipping.
117    *
118    * @param[in] clipping True if clipping should be enabled.
119    * @param[in] size The area to clip within.
120    */
121   void EnableClipping( bool clipping, const Vector2& size );
122
123   /**
124    * Construct a new TextField.
125    */
126   TextField();
127
128   /**
129    * A reference counted object may only be deleted by calling Unreference()
130    */
131   virtual ~TextField();
132
133 private:
134
135   // Undefined copy constructor and assignment operators
136   TextField(const TextField&);
137   TextField& operator=(const TextField& rhs);
138
139 private: // Data
140
141   Text::ControllerPtr mController;
142   Text::RendererPtr mRenderer;
143   Text::DecoratorPtr mDecorator;
144   Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
145
146   RenderableActor mRenderableActor;
147
148   int mRenderingBackend;
149   int mExceedPolicy;
150 };
151
152 } // namespace Internal
153
154 // Helpers for public-api forwarding methods
155
156 inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
157 {
158   DALI_ASSERT_ALWAYS(textField);
159
160   Dali::RefObject& handle = textField.GetImplementation();
161
162   return static_cast<Toolkit::Internal::TextField&>(handle);
163 }
164
165 inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
166 {
167   DALI_ASSERT_ALWAYS(textField);
168
169   const Dali::RefObject& handle = textField.GetImplementation();
170
171   return static_cast<const Toolkit::Internal::TextField&>(handle);
172 }
173
174 } // namespace Toolkit
175
176 } // namespace Dali
177
178 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__