Spannable: Add BackgroundSpan
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / text / spans / background-color-span.h
1 #ifndef DALI_TOOLKIT_TEXT_BACKGROUND_COLOR_SPAN_H
2 #define DALI_TOOLKIT_TEXT_BACKGROUND_COLOR_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 // INTERNAL INCLUDES
22 #include <dali-toolkit/devel-api/text/spans/base-span.h>
23 #include <dali/public-api/math/vector4.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Text
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 class BackgroundColorSpan;
34 }
35
36 /**
37  * @brief BackgroundColorSpan is a handle to an object that specifies the background-color for range of characters.
38  */
39 class DALI_TOOLKIT_API BackgroundColorSpan : public BaseSpan
40 {
41 public:
42   /**
43    * @brief Create an initialized BackgroundColorSpan.
44    *
45    * @param[in] color The background color.
46    *
47    * @return A handle to a newly allocated Dali resource
48    */
49   static BackgroundColorSpan New(const Vector4 &color);
50
51   /**
52    * @brief Creates an uninitialized BackgroundColorSpan handle.
53    *
54    * Calling member functions with an uninitialized BackgroundColorSpan handle is not allowed.
55    */
56   BackgroundColorSpan();
57
58   /**
59    * @brief Copy constructor.
60    * @param[in] rhs A reference to the copied handle
61    */
62   BackgroundColorSpan(const BackgroundColorSpan& rhs);
63
64   /**
65    * @brief Move constructor.
66    * @param[in] rhs A reference to the handle to move
67    */
68   BackgroundColorSpan(BackgroundColorSpan&& rhs);
69
70   /**
71    * @brief Assignment operator.
72    * @param[in] rhs A reference to the copied handle
73    * @return A reference to this
74    */
75   BackgroundColorSpan& operator=(const BackgroundColorSpan& rhs);
76
77   /**
78    * @brief Move assignment operator.
79    * @param[in] rhs A reference to the moved handle
80    * @return A reference to this
81    */
82   BackgroundColorSpan& operator=(BackgroundColorSpan&& rhs);
83
84   /**
85    * @brief Non virtual destructor.
86    */
87   ~BackgroundColorSpan();
88
89   /**
90    * @brief Downcasts to a BackgroundColorSpan handle.
91    * If handle is not a BackgroundColorSpan, the returned handle is left uninitialized.
92    *
93    * @param[in] handle Handle to an object
94    * @return BackgroundColorSpan handle or an uninitialized handle
95    */
96   static BackgroundColorSpan DownCast(BaseHandle handle);
97
98 public: //Methods
99   /**
100    * @brief Retrive the background-color.
101    *
102    * @return A background-color value.
103    */
104   const Vector4 GetBackgroundColor() const;
105
106   /**
107    * @brief Retrieve whether the background-color is defined.
108    *
109    * @return The return is true if background-color is defined, otherwise false.
110    */
111   bool IsBackgroundColorDefined() const;
112
113 public: // Not intended for application developers
114   /// @cond internal
115   /**
116    * @brief This constructor is used internally to Create an initialized BackgroundColorSpan handle.
117    *
118    * @param[in] colorSpan Pointer to internal BackgroundColorSpan
119    */
120   explicit DALI_INTERNAL BackgroundColorSpan(Internal::BackgroundColorSpan* colorSpan);
121   /// @endcond
122 };
123
124 } // namespace Text
125
126 } // namespace Toolkit
127
128 } // namespace Dali
129
130 #endif // DALI_TOOLKIT_TEXT_BACKGROUND_COLOR_SPAN_H