TextLabel property fixes
[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   // Properties
44   enum
45   {
46     TEXTLABEL_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
47     TEXTLABEL_PROPERTY_END_INDEX = TEXTLABEL_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
48   };
49
50   /**
51    * @copydoc Dali::Toollkit::TextLabel::New()
52    */
53   static Toolkit::TextLabel New();
54
55   // Properties
56
57   /**
58    * Called when a property of an object of this type is set.
59    * @param[in] object The object whose property is set.
60    * @param[in] index The property index.
61    * @param[in] value The new property value.
62    */
63   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
64
65   /**
66    * Called to retrieve a property of an object of this type.
67    * @param[in] object The object whose property is to be retrieved.
68    * @param[in] index The property index.
69    * @return The current value of the property.
70    */
71   static Property::Value GetProperty( BaseObject* object, Property::Index index );
72
73 private: // From Control
74
75   /**
76    * @copydoc Control::OnInitialize()
77    */
78   virtual void OnInitialize();
79
80   /**
81    * @copydoc Control::OnInitialize()
82    */
83   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
84
85   /**
86    * @copydoc Control::GetNaturalSize()
87    */
88   virtual Vector3 GetNaturalSize();
89
90   /**
91    * @copydoc Control::GetHeightForWidth()
92    */
93   virtual float GetHeightForWidth( float width );
94
95   /**
96    * @copydoc Text::ControlInterface::RequestTextRelayout()
97    */
98   virtual void RequestTextRelayout();
99
100 private: // Implementation
101
102   /**
103    * Construct a new TextLabel.
104    */
105   TextLabel();
106
107   /**
108    * A reference counted object may only be deleted by calling Unreference()
109    */
110   virtual ~TextLabel();
111
112 private:
113
114   // Undefined copy constructor and assignment operators
115   TextLabel(const TextLabel&);
116   TextLabel& operator=(const TextLabel& rhs);
117
118 private: // Data
119
120   Text::ControllerPtr mController;
121   Text::RendererPtr mRenderer;
122   RenderableActor mRenderableActor;
123
124   unsigned int mRenderingBackend;
125 };
126
127 } // namespace Internal
128
129 // Helpers for public-api forwarding methods
130
131 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
132 {
133   DALI_ASSERT_ALWAYS(textLabel);
134
135   Dali::RefObject& handle = textLabel.GetImplementation();
136
137   return static_cast<Toolkit::Internal::TextLabel&>(handle);
138 }
139
140 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
141 {
142   DALI_ASSERT_ALWAYS(textLabel);
143
144   const Dali::RefObject& handle = textLabel.GetImplementation();
145
146   return static_cast<const Toolkit::Internal::TextLabel&>(handle);
147 }
148
149 } // namespace Toolkit
150
151 } // namespace Dali
152
153 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__