1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
36 * @brief A control which renders a short text string.
38 class TextLabel : public Control, public Text::ControlInterface
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
50 * @copydoc Dali::Toollkit::TextLabel::New()
52 static Toolkit::TextLabel New();
55 * @copydoc Dali::Toollkit::TextLabel::SetRenderer()
57 void SetRenderer( Text::RendererPtr renderer );
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.
67 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
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.
75 static Property::Value GetProperty( BaseObject* object, Property::Index index );
77 private: // From Control
80 * @copydoc Control::OnInitialize()
82 virtual void OnInitialize();
85 * @copydoc Control::OnInitialize()
87 virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
90 * @copydoc Control::GetNaturalSize()
92 virtual Vector3 GetNaturalSize();
95 * @copydoc Control::GetHeightForWidth()
97 virtual float GetHeightForWidth( float width );
100 * @copydoc Text::ControlInterface::RequestTextRelayout()
102 virtual void RequestTextRelayout();
104 private: // Implementation
107 * Helper for SetProperty.
108 * @param[in] text The new "text" property value.
110 void SetText( const std::string& text );
113 * Helper for SetProperty.
114 * @param[in] multiLine The new "multi-line" property value.
116 void SetMultiLine( bool multiLine );
119 * Construct a new TextLabel.
124 * A reference counted object may only be deleted by calling Unreference()
126 virtual ~TextLabel();
130 // Undefined copy constructor and assignment operators
131 TextLabel(const TextLabel&);
132 TextLabel& operator=(const TextLabel& rhs);
136 Text::ControllerPtr mController;
137 Text::RendererPtr mRenderer;
140 } // namespace Internal
142 // Helpers for public-api forwarding methods
144 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
146 DALI_ASSERT_ALWAYS(textLabel);
148 Dali::RefObject& handle = textLabel.GetImplementation();
150 return static_cast<Toolkit::Internal::TextLabel&>(handle);
153 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
155 DALI_ASSERT_ALWAYS(textLabel);
157 const Dali::RefObject& handle = textLabel.GetImplementation();
159 return static_cast<const Toolkit::Internal::TextLabel&>(handle);
162 } // namespace Toolkit
166 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__