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