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/internal/text/text-controller.h>
25 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
37 * @brief A control which renders a short text string.
39 class TextLabel : public Control, public Text::ControlInterface
44 * @copydoc Dali::Toollkit::TextLabel::New()
46 static Toolkit::TextLabel New();
51 * @brief Called when a property of an object of this type is set.
53 * @param[in] object The object whose property is set.
54 * @param[in] index The property index.
55 * @param[in] value The new property value.
57 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
60 * @brief Called to retrieve a property of an object of this type.
62 * @param[in] object The object whose property is to be retrieved.
63 * @param[in] index The property index.
64 * @return The current value of the property.
66 static Property::Value GetProperty( BaseObject* object, Property::Index index );
68 private: // From Control
71 * @copydoc Control::OnInitialize()
73 virtual void OnInitialize();
76 * @copydoc Control::OnStyleChange()
78 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
81 * @copydoc Control::OnRelayout()
83 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
86 * @copydoc Control::GetNaturalSize()
88 virtual Vector3 GetNaturalSize();
91 * @copydoc Control::GetHeightForWidth()
93 virtual float GetHeightForWidth( float width );
96 * @copydoc Text::ControlInterface::AddDecoration()
98 virtual void AddDecoration( Actor& actor, bool needsClipping );
101 * @copydoc Control::OnStageConnection()
103 virtual void OnStageConnection( int depth );
106 * @copydoc Text::ControlInterface::RequestTextRelayout()
108 virtual void RequestTextRelayout();
111 * @copydoc Text::ControlInterface::TextChanged()
113 virtual void TextChanged();
116 * @copydoc Text::ControlInterface::MaxLengthReached()
118 virtual void MaxLengthReached();
120 private: // Implementation
123 * Construct a new TextLabel.
128 * A reference counted object may only be deleted by calling Unreference()
130 virtual ~TextLabel();
134 // Undefined copy constructor and assignment operators
135 TextLabel(const TextLabel&);
136 TextLabel& operator=(const TextLabel& rhs);
138 // Connection needed to re-render text, when a Text Label returns to the stage
139 void OnStageConnect( Dali::Actor actor );
142 * @brief Render view, create and attach actor(s) to this Text Label
148 Text::ControllerPtr mController;
149 Text::RendererPtr mRenderer;
150 Actor mRenderableActor;
151 int mRenderingBackend;
152 bool mHasBeenStaged:1;
155 } // namespace Internal
157 // Helpers for public-api forwarding methods
159 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
161 DALI_ASSERT_ALWAYS(textLabel);
163 Dali::RefObject& handle = textLabel.GetImplementation();
165 return static_cast<Toolkit::Internal::TextLabel&>(handle);
168 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
170 DALI_ASSERT_ALWAYS(textLabel);
172 const Dali::RefObject& handle = textLabel.GetImplementation();
174 return static_cast<const Toolkit::Internal::TextLabel&>(handle);
177 } // namespace Toolkit
181 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__