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 Control::OnPropertySet()
76 // void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
79 * @copydoc Control::OnAccessibilityActivated()
81 bool OnAccessibilityActivated() override;
83 private: // Implementation
85 * Construct a new TextAnchor.
90 * A reference counted object may only be deleted by calling Unreference()
92 virtual ~TextAnchor();
95 // Undefined copy constructor and assignment operators
96 TextAnchor(const TextAnchor&);
97 TextAnchor& operator=(const TextAnchor& rhs);
100 int mStartCharacterIndex;
101 int mEndCharacterIndex;
106 * @brief This structure is to connect TextAnchor with Accessible functions.
108 struct AccessibleImpl : public DevelControl::ControlAccessible,
109 public virtual Dali::Accessibility::Hyperlink
111 using DevelControl::ControlAccessible::ControlAccessible;
113 * @copydoc Dali::Accessibility::Hyperlink::GetEndIndex()
115 int32_t GetEndIndex() const override;
118 * @copydoc Dali::Accessibility::Hyperlink::GetStartIndex()
120 int32_t GetStartIndex() const override;
123 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorCount()
125 int32_t GetAnchorCount() const override;
128 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorAccessible()
130 Accessible* GetAnchorAccessible(int32_t anchorIndex) const override;
133 * @copydoc Dali::Accessibility::Hyperlink::GetAnchorUri()
135 std::string GetAnchorUri(int32_t anchorIndex) const override;
138 * @copydoc Dali::Accessibility::Hyperlink::IsValid()
140 bool IsValid() const override;
144 inline Toolkit::Internal::TextAnchor& GetImpl(Toolkit::TextAnchor& textAnchor)
146 DALI_ASSERT_ALWAYS(textAnchor);
148 Dali::RefObject& handle = textAnchor.GetImplementation();
150 return static_cast<Toolkit::Internal::TextAnchor&>(handle);
153 inline const Toolkit::Internal::TextAnchor& GetImpl(const Toolkit::TextAnchor& textAnchor)
155 DALI_ASSERT_ALWAYS(textAnchor);
157 const Dali::RefObject& handle = textAnchor.GetImplementation();
159 return static_cast<const Toolkit::Internal::TextAnchor&>(handle);
162 } // namespace Internal
164 } // namespace Toolkit
168 #endif // DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H