Set focusable to true when touched in default.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-anchor-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/atspi-interfaces/hyperlink.h>
23
24 // INTERNAL INCLUDES
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>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Internal
35 {
36 /**
37  * @brief A control which renders anchor (hyperlink) in hypertext.
38  */
39 class TextAnchor : public Control
40 {
41 public:
42   /**
43    * @copydoc Dali::Toollkit::TextAnchor::New()
44    */
45   static Toolkit::TextAnchor New();
46
47   // Properties
48
49   /**
50    * @brief Called when a property of an object of this type is set.
51    *
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.
55    */
56   static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
57
58   /**
59    * @brief Called to retrieve a property of an object of this type.
60    *
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.
64    */
65   static Property::Value GetProperty(BaseObject* object, Property::Index index);
66
67 private: // From Control
68   /**
69    * @copydoc Control::OnInitialize()
70    */
71   void OnInitialize() override;
72
73   /**
74    * @copydoc Control::OnPropertySet()
75    */
76   // void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
77
78   /**
79    * @copydoc Control::OnAccessibilityActivated()
80    */
81   bool OnAccessibilityActivated() override;
82
83 private: // Implementation
84   /**
85    * Construct a new TextAnchor.
86    */
87   TextAnchor();
88
89   /**
90    * A reference counted object may only be deleted by calling Unreference()
91    */
92   virtual ~TextAnchor();
93
94 private:
95   // Undefined copy constructor and assignment operators
96   TextAnchor(const TextAnchor&);
97   TextAnchor& operator=(const TextAnchor& rhs);
98
99   //Data
100   int         mStartCharacterIndex;
101   int         mEndCharacterIndex;
102   std::string mUri;
103
104 protected:
105   /**
106    * @brief This structure is to connect TextAnchor with Accessible functions.
107    */
108   struct AccessibleImpl : public DevelControl::AccessibleImpl,
109                           public virtual Dali::Accessibility::Hyperlink
110   {
111     using DevelControl::AccessibleImpl::AccessibleImpl;
112     /**
113      * @copydoc Dali::Accessibility::Hyperlink::GetEndIndex()
114      */
115     int32_t GetEndIndex() const override;
116
117     /**
118      * @copydoc Dali::Accessibility::Hyperlink::GetStartIndex()
119      */
120     int32_t GetStartIndex() const override;
121
122     /**
123      * @copydoc Dali::Accessibility::Hyperlink::GetAnchorCount()
124      */
125     int32_t GetAnchorCount() const override;
126
127     /**
128      * @copydoc Dali::Accessibility::Hyperlink::GetAnchorAccessible()
129      */
130     Accessible* GetAnchorAccessible(int32_t anchorIndex) const override;
131
132     /**
133      * @copydoc Dali::Accessibility::Hyperlink::GetAnchorUri()
134      */
135     std::string GetAnchorUri(int32_t anchorIndex) const override;
136
137     /**
138      * @copydoc Dali::Accessibility::Hyperlink::IsValid()
139      */
140     bool IsValid() const override;
141   };
142 };
143
144 inline Toolkit::Internal::TextAnchor& GetImpl(Toolkit::TextAnchor& textAnchor)
145 {
146   DALI_ASSERT_ALWAYS(textAnchor);
147
148   Dali::RefObject& handle = textAnchor.GetImplementation();
149
150   return static_cast<Toolkit::Internal::TextAnchor&>(handle);
151 }
152
153 inline const Toolkit::Internal::TextAnchor& GetImpl(const Toolkit::TextAnchor& textAnchor)
154 {
155   DALI_ASSERT_ALWAYS(textAnchor);
156
157   const Dali::RefObject& handle = textAnchor.GetImplementation();
158
159   return static_cast<const Toolkit::Internal::TextAnchor&>(handle);
160 }
161
162 } // namespace Internal
163
164 } // namespace Toolkit
165
166 } // namespace Dali
167
168 #endif // DALI_TOOLKIT_INTERNAL_TEXT_ANCHOR_H