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