Text Renderer base class & TextLabel skeleton
[platform/core/uifw/dali-toolkit.git] / base / 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
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 /**
35  * @brief A control which renders a short text string.
36  */
37 class TextLabel : public Control
38 {
39 public:
40
41   // Properties
42   enum
43   {
44     TEXTLABEL_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
45     TEXTLABEL_PROPERTY_END_INDEX = TEXTLABEL_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
46   };
47
48   /**
49    * @copydoc Dali::Toollkit::TextLabel::New()
50    */
51   static Toolkit::TextLabel New();
52
53   /**
54    * @copydoc Dali::Toollkit::TextLabel::SetRenderer()
55    */
56   void SetRenderer( Text::RendererPtr renderer );
57
58   // Properties
59
60   /**
61    * Called when a property of an object of this type is set.
62    * @param[in] object The object whose property is set.
63    * @param[in] index The property index.
64    * @param[in] value The new property value.
65    */
66   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
67
68   /**
69    * Called to retrieve a property of an object of this type.
70    * @param[in] object The object whose property is to be retrieved.
71    * @param[in] index The property index.
72    * @return The current value of the property.
73    */
74   static Property::Value GetProperty( BaseObject* object, Property::Index index );
75
76 private: // From Control
77
78   /**
79    * @copydoc Control::OnInitialize()
80    */
81   virtual void OnInitialize();
82
83 private: // Implementation
84
85   /**
86    * Construct a new TextLabel.
87    */
88   TextLabel();
89
90   /**
91    * A reference counted object may only be deleted by calling Unreference()
92    */
93   virtual ~TextLabel();
94
95 private:
96
97   // Undefined copy constructor and assignment operators
98   TextLabel(const TextLabel&);
99   TextLabel& operator=(const TextLabel& rhs);
100
101 private: // Data
102
103   // TODO - Use Controller/Model for storage
104   Text::RendererPtr mRenderer;
105   std::string mText;
106 };
107
108 } // namespace Internal
109
110 // Helpers for public-api forwarding methods
111
112 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
113 {
114   DALI_ASSERT_ALWAYS(textLabel);
115
116   Dali::RefObject& handle = textLabel.GetImplementation();
117
118   return static_cast<Toolkit::Internal::TextLabel&>(handle);
119 }
120
121 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
122 {
123   DALI_ASSERT_ALWAYS(textLabel);
124
125   const Dali::RefObject& handle = textLabel.GetImplementation();
126
127   return static_cast<const Toolkit::Internal::TextLabel&>(handle);
128 }
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__