1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H
5 * Copyright (c) 2021 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>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-anchor-devel.h>
26 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
27 #include <dali-toolkit/internal/text/text-anchor-control-interface.h>
36 * @brief A control which renders anchor (hyperlink) in hypertext.
38 class TextAnchor : public Control
42 * @copydoc Dali::Toollkit::TextAnchor::New()
44 static Toolkit::TextAnchor New();
49 * @brief Called when a property of an object of this type is set.
51 * @param[in] object The object whose property is set.
52 * @param[in] index The property index.
53 * @param[in] value The new property value.
55 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
58 * @brief Called to retrieve a property of an object of this type.
60 * @param[in] object The object whose property is to be retrieved.
61 * @param[in] index The property index.
62 * @return The current value of the property.
64 static Property::Value GetProperty(BaseObject* object, Property::Index index);
66 private: // From Control
68 * @copydoc Control::OnInitialize()
70 void OnInitialize() override;
73 * @copydoc Control::OnPropertySet()
75 // void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
78 * @copydoc Control::OnAccessibilityActivated()
80 bool OnAccessibilityActivated() override;
82 private: // Implementation
84 * Construct a new TextAnchor.
89 * A reference counted object may only be deleted by calling Unreference()
91 virtual ~TextAnchor();
94 // Undefined copy constructor and assignment operators
95 TextAnchor(const TextAnchor&);
96 TextAnchor& operator=(const TextAnchor& rhs);
99 int mStartCharacterIndex;
100 int mEndCharacterIndex;
105 * @brief This structure is to connect TextAnchor with Accessible functions.
107 struct AccessibleImpl : public DevelControl::AccessibleImpl,
108 public virtual Dali::Accessibility::Hyperlink
110 using DevelControl::AccessibleImpl::AccessibleImpl;
112 * @copydoc Dali::Accessibility::Hyperlink::GetEndIndex()
114 int32_t GetEndIndex() const override;
117 * @copydoc Dali::Accessibility::Hyperlink::GetStartIndex()
119 int32_t GetStartIndex() const override;
122 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorCount()
124 int32_t GetAnchorCount() const override;
127 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorAccessible()
129 Accessible* GetAnchorAccessible(int32_t anchorIndex) const override;
132 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorUri()
134 std::string GetAnchorUri(int32_t anchorIndex) const override;
137 * @copydoc Dali::Accessibility::Hyperlink::IsValid()
139 bool IsValid() const override;
143 inline Toolkit::Internal::TextAnchor& GetImpl(Toolkit::TextAnchor& textAnchor)
145 DALI_ASSERT_ALWAYS(textAnchor);
147 Dali::RefObject& handle = textAnchor.GetImplementation();
149 return static_cast<Toolkit::Internal::TextAnchor&>(handle);
152 inline const Toolkit::Internal::TextAnchor& GetImpl(const Toolkit::TextAnchor& textAnchor)
154 DALI_ASSERT_ALWAYS(textAnchor);
156 const Dali::RefObject& handle = textAnchor.GetImplementation();
158 return static_cast<const Toolkit::Internal::TextAnchor&>(handle);
161 } // namespace Internal
163 } // namespace Toolkit
167 #endif // DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H