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