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/devel-api/atspi-interfaces/hyperlink.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>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
37 * @brief A control which renders anchor (hyperlink) in hypertext.
39 class TextAnchor : public Control
43 * @copydoc Dali::Toollkit::TextAnchor::New()
45 static Toolkit::TextAnchor New();
50 * @brief Called when a property of an object of this type is set.
52 * @param[in] object The object whose property is set.
53 * @param[in] index The property index.
54 * @param[in] value The new property value.
56 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
59 * @brief Called to retrieve a property of an object of this type.
61 * @param[in] object The object whose property is to be retrieved.
62 * @param[in] index The property index.
63 * @return The current value of the property.
65 static Property::Value GetProperty(BaseObject* object, Property::Index index);
67 private: // From Control
69 * @copydoc Control::OnInitialize()
71 void OnInitialize() override;
74 * @copydoc Toolkit::Internal::Control::CreateAccessibleObject()
76 DevelControl::ControlAccessible* CreateAccessibleObject() override;
79 * @copydoc Control::OnPropertySet()
81 // void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
84 * @copydoc Control::OnAccessibilityActivated()
86 bool OnAccessibilityActivated() override;
88 private: // Implementation
90 * Construct a new TextAnchor.
95 * A reference counted object may only be deleted by calling Unreference()
97 virtual ~TextAnchor();
100 // Undefined copy constructor and assignment operators
101 TextAnchor(const TextAnchor&);
102 TextAnchor& operator=(const TextAnchor& rhs);
105 int mStartCharacterIndex;
106 int mEndCharacterIndex;
111 * @brief This structure is to connect TextAnchor with Accessible functions.
113 class TextAnchorAccessible : public DevelControl::ControlAccessible,
114 public virtual Dali::Accessibility::Hyperlink
117 using DevelControl::ControlAccessible::ControlAccessible;
120 * @copydoc Dali::Accessibility::Hyperlink::GetEndIndex()
122 int32_t GetEndIndex() const override;
125 * @copydoc Dali::Accessibility::Hyperlink::GetStartIndex()
127 int32_t GetStartIndex() const override;
130 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorCount()
132 int32_t GetAnchorCount() const override;
135 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorAccessible()
137 Accessible* GetAnchorAccessible(int32_t anchorIndex) const override;
140 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorUri()
142 std::string GetAnchorUri(int32_t anchorIndex) const override;
145 * @copydoc Dali::Accessibility::Hyperlink::IsValid()
147 bool IsValid() const override;
151 inline Toolkit::Internal::TextAnchor& GetImpl(Toolkit::TextAnchor& textAnchor)
153 DALI_ASSERT_ALWAYS(textAnchor);
155 Dali::RefObject& handle = textAnchor.GetImplementation();
157 return static_cast<Toolkit::Internal::TextAnchor&>(handle);
160 inline const Toolkit::Internal::TextAnchor& GetImpl(const Toolkit::TextAnchor& textAnchor)
162 DALI_ASSERT_ALWAYS(textAnchor);
164 const Dali::RefObject& handle = textAnchor.GetImplementation();
166 return static_cast<const Toolkit::Internal::TextAnchor&>(handle);
169 } // namespace Internal
171 } // namespace Toolkit
175 #endif // DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H