Spannable-Core: Add SpannableString and ForegroundColorSpan
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / spannable / spans / base-span-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_BASE_SPAN_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_BASE_SPAN_IMPL_H
3
4 /*
5  * Copyright (c) 2022 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 <memory>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/devel-api/text/spans/base-span.h>
26 #include <dali-toolkit/internal/text/text-definitions.h>
27 #include <dali/public-api/object/base-object.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Text
34 {
35 class LogicalModel;
36 struct AbstractStyleCharacterRun;
37
38 namespace Internal
39 {
40 class BaseSpan;
41
42 using BaseSpanPtr      = IntrusivePtr<BaseSpan>;
43 using BaseSpanConstPtr = const BaseSpan*;
44
45 /**
46  * @copydoc Dali::Toolkit::Text::BaseSpan
47  */
48 class BaseSpan : public BaseObject
49 {
50 public:
51   BaseSpan(const BaseSpan&) = delete;            ///< Deleted copy constructor
52   BaseSpan(BaseSpan&&)      = delete;            ///< Deleted move constructor
53   BaseSpan& operator=(const BaseSpan&) = delete; ///< Deleted copy assignment operator
54   BaseSpan& operator=(BaseSpan&&) = delete;      ///< Deleted move assignment operator
55
56 protected:
57   /**
58    * @brief Default Constructor
59    */
60   BaseSpan();
61
62   /**
63    * @brief Virtual destructor.
64    *
65    * A reference counted object may only be deleted by calling Unreference()
66    */
67   virtual ~BaseSpan();
68
69 }; // class BaseSpan
70
71 } // namespace Internal
72
73 /**
74  * Helper methods for public API.
75  */
76 inline Internal::BaseSpan& GetImplementation(Dali::Toolkit::Text::BaseSpan& baseSpan)
77 {
78   DALI_ASSERT_ALWAYS(baseSpan && "baseSpan handle is empty");
79
80   BaseObject& handle = baseSpan.GetBaseObject();
81
82   return static_cast<Internal::BaseSpan&>(handle);
83 }
84
85 inline const Internal::BaseSpan& GetImplementation(const Dali::Toolkit::Text::BaseSpan& baseSpan)
86 {
87   DALI_ASSERT_ALWAYS(baseSpan && "baseSpan handle is empty");
88
89   const BaseObject& handle = baseSpan.GetBaseObject();
90
91   return static_cast<const Internal::BaseSpan&>(handle);
92 }
93
94 } // namespace Text
95
96 } // namespace Toolkit
97
98 // Allow BaseSpan to be treated as a POD type
99 template<>
100 struct TypeTraits<Dali::Toolkit::Text::Internal::BaseSpan> : public Dali::BasicTypes<Dali::Toolkit::Text::Internal::BaseSpan>
101 {
102   enum
103   {
104     IS_TRIVIAL_TYPE = true
105   };
106 };
107
108 } // namespace Dali
109
110 #endif // DALI_TOOLKIT_INTERNAL_TEXT_BASE_SPAN_IMPL_H