1 #ifndef DALI_TOOLKIT_TEXT_SPANNABLE_H
2 #define DALI_TOOLKIT_TEXT_SPANNABLE_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/devel-api/text/range.h>
23 #include <dali-toolkit/devel-api/text/spanned.h>
24 #include <dali-toolkit/devel-api/text/spans/base-span.h>
32 namespace Internal DALI_INTERNAL
38 * @brief Interface for text to which spans objects can be attached and detached.
39 * It provides uniform APIs for mutable formatted character sequences.
41 * @note An instance of this class cannot be created.
44 class DALI_TOOLKIT_API Spannable : public Spanned
48 * @brief Creates an uninitialized Spannable handle.
50 * Calling member functions with an uninitialized Spannable handle is not allowed.
55 * @brief Copy constructor.
57 * @param[in] rhs A reference to the copied handle
59 Spannable(const Spannable& rhs);
62 * @brief Move constructor.
64 * @param[in] rhs A reference to the handle to move
66 Spannable(Spannable&& rhs);
69 * @brief Assignment operator.
71 * @param[in] handle A reference to the copied handle
72 * @return A reference to this
74 Spannable& operator=(const Spannable& handle);
77 * @brief Move assignment operator.
79 * @param[in] rhs A reference to the handle to move
80 * @return A reference to this handle
82 Spannable& operator=(Spannable&& rhs);
85 * @brief Non virtual destructor.
91 * @brief Add the given style span on the given range of text.
93 * @param[in] styleSpan The span of style to apply it on range @p range
94 * @param[in] range The range.
96 * @return true if the @p range is valid on text. Otherwise false
98 bool AttachSpan(BaseSpan styleSpan, Range range);
101 * @brief Remove the given style span on all ranges of text.
102 * checks if @p styleSpan exists, and if it does, it's to be removed.
104 * @param[in] styleSpan The span of style to remove with ranges.
106 * @return true if the @p styleSpan was exist and removed. Otherwise false
108 bool DetachSpan(const BaseSpan& styleSpan);
112 * @brief Downcasts to a Spannable handle.
113 * If handle is not a Spannable, the returned handle is left uninitialized.
115 * @param[in] handle Handle to an object
116 * @return Spannable handle or an uninitialized handle
118 static Spannable DownCast(BaseHandle handle);
120 public: // Not intended for application developers
123 * @brief Internal constructor.
125 * @param[in] spannable Pointer to internal Spannable
127 explicit DALI_INTERNAL Spannable(Internal::Spannable* spannable);
133 } // namespace Toolkit
137 #endif // DALI_TOOLKIT_TEXT_SPANNABLE_H