3 // Open Service Platform
4 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
6 // Licensed under the Apache License, Version 2.0 (the License);
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0/
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
20 * @file FGrpTextElement.h
21 * @brief This is the header file for the %TextElement class.
23 * This header file contains the declarations of the %TextElement class.
26 #ifndef _FGRP_TEXT_ELEMENT_H_
27 #define _FGRP_TEXT_ELEMENT_H_
30 #include <FBaseUtilTypes.h>
32 #include <FGrpCanvas.h>
33 #include <FGrpColor.h>
35 namespace Tizen { namespace Graphics
39 * @brief This class provides methods for the text elements.
43 * @final This class is not intended for extension.
45 * The %TextElement class encapsulates the characteristics of a text, such as the constant string and font style.
46 * A text element draws the text on to a canvas.
48 * For more information on the attributes of %TextElement, see <a href="../org.tizen.native.appprogramming/html/guide/graphics/enriched_text.htm">EnrichedText</a>.
51 class _OSP_EXPORT_ TextElement
52 : public Tizen::Base::Object
56 * This is the default constructor for this class.
60 * @remarks After creating an instance of this class, one of the
61 * Construct() methods must be called explicitly to initialize this instance.
66 * This is the destructor for this class.
70 virtual ~TextElement(void);
73 * Initializes the current instance of %TextElement with the specified text. @n
74 * If the text is not specified, the default system font is set.
78 * @return An error code
79 * @param[in] text The text string
80 * @exception E_SUCCESS The method is successful.
81 * @exception E_OUT_OF_MEMORY The memory is insufficient.
82 * @exception E_INVALID_ARG The specified input parameter is invalid.
84 result Construct(const Tizen::Base::String& text);
87 * Initializes the current instance of %TextElement with the specified text. @n
88 * The canvas is used for initializing the font's color attributes, such as the foreground color and the background color.
92 * @return An error code
93 * @param[in] text The text string
94 * @param[in] canvas The canvas to initialize the text element @n
95 * It sets the foreground and background colors of the text element.
96 * @exception E_SUCCESS The method is successful.
97 * @exception E_OUT_OF_MEMORY The memory is insufficient.
98 * @exception E_INVALID_ARG A specified input parameter is invalid.
100 result Construct(const Tizen::Base::String& text, const Tizen::Graphics::Canvas& canvas);
103 * Initializes the current instance of %TextElement.
107 * @return An error code
108 * @exception E_SUCCESS The method is successful.
109 * @exception E_OUT_OF_MEMORY The memory is insufficient.
110 * @exception E_SYSTEM An unknown operating system error has occurred.
111 * @remarks To set the text, use the SetText() method.
113 result Construct(void);
116 * Initializes the current instance of %TextElement to represent a linked text with the specified link information. @n
117 * If the link information is not specified, the default system font is set.
121 * @return An error code
122 * @param[in] text The linked text string
123 * @param[in] linkType The link type
124 * @param[in] link The string that contains the actual link
125 * @exception E_SUCCESS The method is successful.
126 * @exception E_OUT_OF_MEMORY The memory is insufficient.
127 * @exception E_INVALID_ARG Either the specified @c text is an empty string or @c linkType is @c LINK_TYPE_NONE
128 * @exception E_SYSTEM An unknown operating system error has occurred.
129 * @see Tizen::Base::Utility::LinkInfo
131 result Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link);
134 * Initializes the current instance of %TextElement with the specified text and autolink mask. @n
135 * If the text and autolink mask are not specified, the default system font is set.
139 * @return An error code
140 * @param[in] text The text string
141 * @param[in] autoLink The autolink mask @n
142 * Multiple link types can be combined using the bitwise OR operator. @n
143 * For more information, see <a href="../org.tizen.native.appprogramming/html/guide/ui/auto_link_detection.htm">AutoLink Detection</a>.
144 * @exception E_SUCCESS The method is successful.
145 * @exception E_INVALID_ARG A specified input parameter is invalid.
146 * @exception E_OUT_OF_MEMORY The memory is insufficient.
147 * @exception E_SYSTEM An unknown operating system error has occurred.
148 * @remarks If @c text contains more than one detectable link, the first link is converted
149 * to a linked text and the rest of the links are ignored.
150 * @see Tizen::Base::Utility::LinkType
152 result Construct(const Tizen::Base::String& text, unsigned long autoLink);
155 * Initializes the current instance of %TextElement to represent a linked text with the specified link information. @n
156 * If the link information is not specified, the default system font is set.
160 * @return An error code
161 * @param[in] text The linked text string
162 * @param[in] linkType The link type
163 * @param[in] link The string that contains the actual link
164 * @param[in] canvas The canvas to initialize the text element @n
165 * It sets the foreground and background colors of the text element.
166 * @exception E_SUCCESS The method is successful.
167 * @exception E_OUT_OF_MEMORY The memory is insufficient.
168 * @exception E_INVALID_ARG Either the specified @c text is an empty string or @c linkType is @c LINK_TYPE_NONE.
169 * @exception E_SYSTEM An unknown operating system error has occurred.
171 result Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link, const Tizen::Graphics::Canvas& canvas);
174 * Initializes the current instance of %TextElement with the specified text, autolink mask, and graphics canvas. @n
175 * If the parameters are not specified, the default system font is set.
179 * @return An error code
180 * @param[in] text The text string @n
181 * If the text contains more than one detectable link, the first link is converted to a linked text and rest of the links are ignored.
182 * @param[in] autoLink The autolink mask @n
183 * Multiple link types can be combined using the bitwise OR operator. @n
184 * For more information, see <a href="../org.tizen.native.appprogramming/html/guide/ui/auto_link_detection.htm">AutoLink Detection</a>.
185 * @param[in] canvas The canvas to initialize the text element @n
186 * It sets the foreground and background colors of the text element.
187 * @exception E_SUCCESS The method is successful.
188 * @exception E_INVALID_ARG A specified input parameter is invalid.
189 * @exception E_OUT_OF_MEMORY The memory is insufficient.
190 * @exception E_SYSTEM An unknown operating system error has occurred.
191 * @see Tizen::Base::Utility::LinkType
193 result Construct(const Tizen::Base::String& text, unsigned long autoLink, const Tizen::Graphics::Canvas& canvas);
196 * Gets the string that contains the actual link.
200 * @return The string that contains the actual link @n
201 * If the text element contains no linked text, the method returns an empty string.
203 Tizen::Base::String GetLink(void) const;
206 * Gets the type of the link of the text element. @n
207 * The link type is the first auto-detected link.
211 * @return The string that contains the actual link @n
212 * If the text element contains no linked text, the method returns @c LINK_TYPE_NONE.
214 Tizen::Base::Utility::LinkType GetLinkType(void) const;
217 * Sets the text of %TextElement with the specified string.
221 * @return An error code
222 * @param[in] text The string to set
223 * @exception E_SUCCESS The method is successful.
225 result SetText(const Tizen::Base::String& text);
228 * Sets the font of %TextElement.
232 * @return An error code
233 * @param[in] font The font to set
234 * @exception E_SUCCESS The method is successful.
235 * @exception E_INVALID_ARG The specified input parameter is invalid.
237 result SetFont(const Tizen::Graphics::Font& font);
240 * Sets the text color of %TextElement.
244 * @return An error code
245 * @param[in] color The color to set
246 * @exception E_SUCCESS The method is successful.
248 result SetTextColor(const Tizen::Graphics::Color& color);
251 * Sets the background color of %TextElement.
255 * @return An error code
256 * @param[in] color The color to set
257 * @exception E_SUCCESS The method is successful.
259 result SetBackgroundColor(const Tizen::Graphics::Color& color);
262 * Sets the outline color of %TextElement.
266 * @return An error code
267 * @param[in] color The color to set
268 * @exception E_SUCCESS The method is successful.
270 result SetOutlineColor(const Tizen::Graphics::Color& color);
273 * Gets the text of %TextElement.
277 * @return A string containing the text
279 Tizen::Base::String GetText(void) const;
282 * Gets the text color of %TextElement.
286 * @return The foreground color
288 Tizen::Graphics::Color GetTextColor(void) const;
291 * Gets the background color of %TextElement.
295 * @return The background color
297 Tizen::Graphics::Color GetBackgroundColor(void) const;
300 * Gets the outline color of %TextElement.
304 * @return The outline color
306 Tizen::Graphics::Color GetOutlineColor(void) const;
309 friend class _TextElementImpl;
312 // This value is for internal use only. Using this value can cause behavioral, security-related,
313 // and consistency-related issues in the application.
318 class _TextElementImpl * __pImpl;
320 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
321 TextElement(const TextElement& font);
323 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
324 TextElement& operator =(const TextElement& rhs);
328 } } // Tizen::Graphics
330 #endif // _FGRP_TEXT_ELEMENT_H_