Merge "Spannable-Core: Add SpannableString and ForegroundColorSpan" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / text / spans / base-span.h
1 #ifndef DALI_TOOLKIT_TEXT_BASE_SPAN_H
2 #define DALI_TOOLKIT_TEXT_BASE_SPAN_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 <dali-toolkit/public-api/dali-toolkit-common.h>
23 #include <dali/public-api/object/base-handle.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Text
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 class BaseSpan;
34 }
35
36 /**
37  * @brief Base structure for different text-spans.
38  * The application can attach and detach spans on range of text for text-controller.
39  * Used to modify text style dynamically at runtime on character level.
40  *
41  * A text-span contains set of attributes of specific style for text.
42  *
43  * To receive a particular text-span, the application has to create span through its builder.
44  *
45  * @note An instance of this class cannot be created.
46  *
47  */
48 class DALI_TOOLKIT_API BaseSpan : public BaseHandle
49 {
50 public:
51   /**
52    * @brief Creates an uninitialized BaseSpan handle.
53    *
54    * Calling member functions with an uninitialized BaseSpan handle is not allowed.
55    */
56   BaseSpan();
57
58   /**
59    * @brief Copy constructor.
60    *
61    * @param[in] rhs A reference to the copied handle
62    */
63   BaseSpan(const BaseSpan& rhs);
64
65   /**
66    * @brief Move constructor.
67    *
68    * @param[in] rhs A reference to the handle to move
69    */
70   BaseSpan(BaseSpan&& rhs);
71
72   /**
73    * @brief Assignment operator.
74    *
75    * @param[in] handle A reference to the copied handle
76    * @return A reference to this
77    */
78   BaseSpan& operator=(const BaseSpan& handle);
79
80   /**
81    * @brief Move assignment operator.
82    *
83    * @param[in] rhs A reference to the handle to move
84    * @return A reference to this handle
85    */
86   BaseSpan& operator=(BaseSpan&& rhs);
87
88   /**
89    * @brief Non virtual destructor.
90    */
91   ~BaseSpan();
92
93   /**
94    * @brief Downcasts to a BaseSpan handle.
95    * If handle is not a BaseSpan, the returned handle is left uninitialized.
96    *
97    * @param[in] handle Handle to an object
98    * @return BaseSpan handle or an uninitialized handle
99    */
100   static BaseSpan DownCast(BaseHandle handle);
101
102 public: // Not intended for application developers
103   /// @cond internal
104   /**
105    * @brief Internal constructor.
106    *
107    * @param[in] baseSpan Pointer to internal BaseSpan
108    */
109   explicit DALI_INTERNAL BaseSpan(Internal::BaseSpan* baseSpan);
110   /// @endcond
111 };
112
113 } // namespace Text
114
115 } // namespace Toolkit
116
117 // Allow BaseSpan to be treated as a POD type
118 template<>
119 struct TypeTraits<Dali::Toolkit::Text::BaseSpan> : public BasicTypes<Dali::Toolkit::Text::BaseSpan>
120 {
121   enum
122   {
123     IS_TRIVIAL_TYPE = true
124   };
125 };
126
127 } // namespace Dali
128
129 #endif // DALI_TOOLKIT_TEXT_BASE_SPAN_H