2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_TextBoxImpl.h
20 * @brief This is the header file for the _TextBoxImpl class.
22 * This header file contains the declarations of the %_EditPresenter class.
25 #ifndef _FUI_CTRL_INTERNAL_TEXT_BOX_IMPL_H_
26 #define _FUI_CTRL_INTERNAL_TEXT_BOX_IMPL_H_
28 #include <FOspConfig.h>
29 #include <FUiCtrlTextBox.h>
30 #include <FUiCtrlEditTypes.h>
31 #include <FUiITouchEventListener.h>
32 #include "FUi_ControlImpl.h"
33 #include "FUiCtrl_Edit.h"
34 #include "FUiCtrl_ITextBlockEventListener.h"
35 #include "FUiCtrl_IUiLinkEventListener.h"
37 namespace Tizen { namespace Ui { namespace Controls
40 // forward declarations
41 class _PublicTextBlockEvent;
42 class _PublicLinkEvent;
46 , public _IUiLinkEventListener
47 , public _ITextBlockEventListener
48 , virtual public Tizen::Base::Runtime::IEventListener
52 * This is the default constructor for this class.
57 _TextBoxImpl(TextBox* pPublic, _Edit* pCore);
60 * This is destructor for this class.
64 virtual ~_TextBoxImpl(void);
67 * Creates this instance of the _TextBoxImpl with the specified parameters.
70 * @return An error code
71 * @param[in] pPublic The pointer of the TextBox control.
73 static _TextBoxImpl* CreateTextBoxImplN(TextBox* pPublic);
75 virtual const char* GetPublicClassName(void) const;
76 virtual const TextBox& GetPublic(void) const;
77 virtual TextBox& GetPublic(void);
78 virtual const _Edit& GetCore(void) const;
79 virtual _Edit& GetCore(void);
82 * Initializes this instance of the TextBox control with the specified parameters.
85 * @return An error code
86 * @param[in] border The border style
87 * @exception E_SUCCESS The method was successful.
88 * @exception E_OUT_OF_MEMORY Insufficient memory.
89 * @exception E_SYSTEM A system error occurred.
91 result Initialize(TextBoxBorder border = TEXT_BOX_BORDER_ROUNDED);
94 * Sets the auto-link mask.
97 * @return An error code
98 * @param[in] autoLinks The auto-link mask @n
99 * Multiple link types can be combined using the bitwise OR operator (see Tizen::Base::Utility::LinkType).
100 * For more information, refer to @ref linkAutoLinkDetection "here".
101 * @exception E_SUCCESS The method was successful.
102 * @exception E_SYSTEM A system error occurred.
103 * @remarks When @c autoLinks is set to zero, the auto-link detection is disabled.
104 * @see Tizen::Base::Utility::LinkType
105 * @see GetAutoLinkMask()
107 result SetAutoLinkMask(unsigned long autoLinks);
110 * Gets the auto-link mask.
113 * @return The auto-link mask
114 * @exception E_SUCCESS The method was successful.
115 * @exception E_SYSTEM A system error occurred.
116 * @remarks The specific error code can be accessed using the GetLastResult() method.
117 * @see SetAutoLinkMask()
119 unsigned long GetAutoLinkMask(void) const;
122 * Adds a link event listener.
125 * @param[in] listener The event listener to add
126 * @see RemoveUiLinkEventListener()
128 result AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener);
131 * Removes the specified link event listener. @n
132 * The removed listener cannot listen to events when they are fired.
135 * @param[in] listener The event listener to remove
136 * @see AddUiLinkEventListener()
138 result RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener);
142 * Appends the specified character at the end of the text.
145 * @return An error code
146 * @param[in] character The character to add
147 * @exception E_SUCCESS The method was successful.
148 * @exception E_SYSTEM A system error occurred.
149 * @remarks The method modifies the text buffer that is managed by the TextBox control.
150 * To display the changes, the control must be drawn again.
152 result AppendCharacter(const Tizen::Base::Character& character);
155 * Appends the specified text at the end of the text.
158 * @return An error code
159 * @param[in] text The text to append
160 * @exception E_SUCCESS The method was successful.
161 * @exception E_SYSTEM A system error occurred.
162 * @remarks To denote the end of a line use '\\n'. @n
163 * The method modifies the text buffer that is managed by the TextBox control.
164 * To display the changes, the control must be drawn again.
166 result AppendText(const Tizen::Base::String& text);
169 * Clears text that is displayed by the TextBox control.
172 * @return An error code
173 * @exception E_SUCCESS The method was successful.
174 * @exception E_SYSTEM A system error occurred.
175 * @remarks The method modifies the text buffer that is managed by the TextBox control.
176 * To display the changes, the control must be drawn again.
181 * Gets the number of the lines contained in the TextBox control.
184 * @return The line count of the text, @n
185 * else @c -1 if an error occurs
186 * @exception E_SUCCESS The method was successful.
187 * @remarks The specific error code can be accessed using the GetLastResult() method.
189 int GetLineCount(void) const;
192 * Gets the text that is displayed by the TextBox control.
195 * @return The text of the TextBox control, @n
196 * else an empty string if an error occurs
197 * @exception E_SUCCESS The method was successful.
198 * @exception E_OUT_OF_MEMORY Insufficient memory.
199 * @exception E_SYSTEM A system error occurred.
200 * @remarks The specific error code can be accessed using the GetLastResult() method.
203 Tizen::Base::String GetText(void) const;
206 * Gets a portion of the text that is displayed by the TextBox control.
209 * @return The specified portion of the text, @n
210 * else an empty string if an error occurs
211 * @param[in] start The starting index of range
212 * @param[in] end The last index of range
213 * @exception E_SUCCESS The method was successful.
214 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or the index is greater
215 * than the number of elements or less than zero.
216 * @exception E_SYSTEM A system error occurred.
217 * @remarks The specific error code can be accessed using the GetLastResult() method.
220 Tizen::Base::String GetText(int start, int end) const;
223 * Gets the length of the text that is displayed by the TextBox control.
226 * @return The length of the text, @n
227 * else @c -1 if an error occurs
228 * @exception E_SUCCESS The method was successful.
229 * @exception E_SYSTEM A system error occurred.
230 * @remarks The specific error code can be accessed using the GetLastResult() method.
232 int GetTextLength(void) const;
235 * Inserts the character at the specified index.
238 * @return An error code
239 * @param[in] index The position at which to insert the character
240 * @param[in] character The character to insert
241 * @exception E_SUCCESS The method was successful.
242 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure, or @c index is greater than the number of elements or less than zero.
243 * @exception E_SYSTEM A system error occurred.
245 result InsertCharacterAt(int index, const Tizen::Base::Character& character);
248 * Inserts the text at the specified index.
251 * @return An error code
252 * @param[in] index The position at which to insert the text
253 * @param[in] text The text to insert
254 * @exception E_SUCCESS The method was successful.
255 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure, or @c index is greater than the number of elements or less than zero.
256 * @exception E_SYSTEM A system error occurred.
258 result InsertTextAt(int index, const Tizen::Base::String& text);
261 * Sets the text to display.
264 * @return An error code
265 * @param[in] text The text to display
266 * @exception E_SUCCESS The method was successful.
267 * @exception E_SYSTEM A system error occurred.
268 * @remarks To denote the end of a line use '\\n'. @n
269 * The method modifies the text buffer that is managed by the TextBox control.
270 * To display the changes, the control must be drawn again.
272 result SetText(const Tizen::Base::String& text);
276 * Gets the line spacing.
279 * @return The line spacing, @n
280 * else @c -1 if an error occurs
281 * @exception E_SUCCESS The method was successful.
282 * @remarks The specific error code can be accessed using the GetLastResult() method.
283 * @see SetLineSpacing()
285 int GetLineSpacing(void) const;
288 * Sets the line spacing. @n
289 * The line spacing is determined by multiplying @c multiplier to the default line spacing and adding @c extra.
291 * The line spacing = (default line spacing) * multiplier + extra
294 * @return An error code
295 * @param[in] multiplier The line spacing multiplier
296 * @param[in] extra The extra line spacing
297 * @exception E_SUCCESS The method was successful.
298 * @exception E_INVALID_ARG A specified parameter is invalid. @n
299 * -- The specified line spacing value cannot be supported.
300 * @exception E_SYSTEM A system error occurred.
301 * @see GetLineSpacing()
303 result SetLineSpacing(int multiplier, int extra);
307 * Gets the horizontal text alignment.
310 * @return The horizontal text alignment
311 * @exception E_SUCCESS The method was successful.
312 * @exception E_SYSTEM A system error occurred.
313 * @remarks The specific error code can be accessed using the GetLastResult() method.
314 * @see SetTextAlignment()
316 HorizontalAlignment GetTextAlignment(void) const;
319 * Sets the horizontal text alignment.
322 * @return An error code
323 * @param[in] alignment The horizontal text alignment
324 * @exception E_SUCCESS The method was successful.
325 * @exception E_SYSTEM A system error occurred.
326 * @see GetTextAlignment()
328 result SetTextAlignment(HorizontalAlignment alignment);
332 * Gets the text size of the TextBox control.
335 * @return The size of the text, @n
336 * else @c -1 if an error occurs
337 * @exception E_SUCCESS The method was successful.
338 * @exception E_SYSTEM A system error occurred.
339 * @remarks The specific error code can be accessed using the GetLastResult() method.
342 int GetTextSize(void) const;
345 * Gets the text total height of the TextBox control.
348 * @return The total height of the text, @n
349 * else @c -1 if an error occurs
350 * @exception E_SUCCESS The method was successful.
351 * @exception E_SYSTEM A system error occurred.
352 * @remarks The specific error code can be accessed using the GetLastResult() method.
354 int GetTextTotalHeight(void) const;
357 * Sets the text size.
360 * @return An error code
361 * @param[in] size The text size
362 * @exception E_SUCCESS The method was successful.
363 * @exception E_INVALID_ARG A specified input parameter is invalid.@n
364 * -- The specified @c size cannot be negative integer.
365 * @exception E_SYSTEM A system error occurred.
368 result SetTextSize(int size);
372 * Gets the font typeface name and the style mask of the TextBox control.
375 * @return An error code
376 * @param[out] typefaceName The name of the font typeface
377 * @param[out] style The text style (see TextBoxTextStyle)
378 * @exception E_SUCCESS The method was successful.
379 * @exception E_SYSTEM A system error occurred.
380 * @remarks Multiple styles can be combined using the bitwise OR operator.
382 * @see Tizen::Graphics::Font::GetSystemFontListN()
383 * @see TextBoxTextStyle
385 result GetFontType(Tizen::Base::String& typefaceName, unsigned long& style) const;
387 unsigned long GetTextStyle(void) const;
390 * Sets the font and the style mask of the TextBox control.
393 * @return An error code
394 * @param[in] typefaceName The name of the font typeface
395 * @param[in] style The text style @n
396 * Multiple styles can be combined using the bitwise OR operator(see TextBoxTextStyle).
397 * @exception E_SUCCESS The method was successful.
398 * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified font typeface is not supported.
399 * @exception E_SYSTEM A system error occurred.
400 * @remarks The specified font typeface must be one of the system fonts. @n
401 * @c italic and @c bold cannot be applied at the same time. If the specified style mask contains both @c italic and @c bold, @c italic will be applied.
403 * @see Tizen::Graphics::Font::GetSystemFontListN()
404 * @see TextBoxTextStyle
406 result SetFontType(const Tizen::Base::String& typefaceName, unsigned long style);
408 result SetTextStyle(unsigned long style);
411 * Sets the font to render the text.
414 * @return An error code
415 * @param[in] font The text font
416 * @exception E_SUCCESS The method was successful.
417 * @exception E_SYSTEM A system error occurred.
418 * @remarks All previously set text attributes (style, weight, decoration, and size) will be discarded.
420 result SetFont(const Tizen::Graphics::Font& font);
424 * Releases the selection of the current text block.
427 * @return An error code
428 * @exception E_SUCCESS The method was successful.
429 * @exception E_SYSTEM A system error occurred.
430 * @see GetBlockRange()
431 * @see SetBlockRange()
433 result ReleaseBlock(void);
436 * Gets the start and the end index of the currently selected text block.
439 * @return An error code
440 * @param[out] start The start index of the text block
441 * @param[out] end The end index of the text block
442 * @exception E_SUCCESS The method was successful.
443 * @exception E_SYSTEM A system error occurred.
444 * @remarks The method returns @c start = 0 and @c end = 0 if there is no selected text block.
445 * @see ReleaseBlock()
446 * @see SetBlockRange()
448 result GetBlockRange(int& start, int& end) const;
451 * Sets the specified block of the text.
454 * @return An error code
455 * @param[in] start The start index of the text block
456 * @param[in] end The end index of the text block
457 * @exception E_SUCCESS The method was successful.
458 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or either the @c start or @c end parameters are greater than the number of elements or less than zero.
459 * @exception E_SYSTEM A system error occurred.
460 * @see ReleaseBlock()
461 * @see GetBlockRange()
463 result SetBlockRange(int start, int end);
467 * Gets the color of the TextBox control for the specified status.
470 * @return The color of the TextBox control, @n
471 * else RGBA (0,0,0,0) if an error occurs
472 * @exception E_SUCCESS The method was successful.
473 * @remarks The specific error code can be accessed using the GetLastResult() method.
476 Tizen::Graphics::Color GetColor(TextBoxStatus status) const;
479 * Gets the text color of the specified text color type.
482 * @return The color, @n
483 * else RGBA (0,0,0,0) if an error occurs
484 * @param[in] type The text color type
485 * @exception E_SUCCESS The method was successful.
486 * @exception E_SYSTEM A system error occurred.
487 * @remarks The specific error code can be accessed using the GetLastResult() method.
488 * @see SetTextColor()
490 Tizen::Graphics::Color GetTextColor(TextBoxTextColor type) const;
493 * Sets the background bitmap of the TextBox control.
496 * @return An error code
497 * @param[in] status The state of the TextBox control
498 * @param[in] bitmap The background bitmap
499 * @exception E_SUCCESS The method was successful.
500 * @exception E_SYSTEM A system error occurred.
501 * @see SetBackgroundColor()
503 result SetBackgroundBitmap(TextBoxStatus status, const Tizen::Graphics::Bitmap& bitmap);
506 * Sets the color of the TextBox control for the specified status.
509 * @return An error code
510 * @param[in] status The state of the TextBox control
511 * @param[in] color The color to set
512 * @exception E_SUCCESS The method was successful.
513 * @exception E_SYSTEM A system error occurred.
516 result SetColor(TextBoxStatus status, const Tizen::Graphics::Color& color);
519 * Sets the text color of the TextBox control for the specified text type.
522 * @return An error code
523 * @param[in] type The text color type
524 * @param[in] color The text color to set
525 * @exception E_SUCCESS The method was successful.
526 * @exception E_SYSTEM A system error occurred.
527 * @see GetTextColor()
529 result SetTextColor(TextBoxTextColor type, const Tizen::Graphics::Color& color);
532 * Adds a text block event listener.
535 * @param[in] listener The event listener to add
536 * @remarks Programmatically modifying the text selection does not cause the text block selection event to fire.
537 * @see RemoveTextBlockEventListener()
539 result AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
542 * Removes the specified text block event listener. @n
543 * The removed listener cannot listen to events when they are fired.
546 * @param[in] listener The event listener to remove
547 * @see AddTextBlockEventListener()
549 result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
551 virtual Tizen::Graphics::Dimension GetContentSize(void) const;
556 virtual result OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect);
557 virtual void OnLinkClicked(Tizen::Ui::_Control& source, const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link);
558 virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end);
561 static _TextBoxImpl* GetInstance(TextBox& textBox);
562 static const _TextBoxImpl* GetInstance(const TextBox& textBox);
567 // This is internal. If used in an application, the application can get rejected during the certification process.
568 // Frees the resources allocated by this control and destroys its native window if it is present).
570 virtual result Dispose(void);
573 // This is internal. Converts text color type between the Edit control and the TextBox control.
575 EditTextColor ConvertTextColorType(TextBoxTextColor color) const;
578 // This is internal. Converts text color type between the Edit control and the TextBox control.
580 EditStatus ConvertStatus(TextBoxStatus status) const;
583 _TextBoxImpl(const _TextBoxImpl&);
584 _TextBoxImpl& operator =(const _TextBoxImpl&);
588 _PublicTextBlockEvent* __pPublicTextBlockEvent;
589 _PublicLinkEvent* __pPublicLinkEvent;
590 unsigned long __autoLinkMask;
594 }}} // Tizen::Ui::Controls
596 #endif // _FUI_CTRL_INTERNAL_TEXT_BOX_IMPL_H_