Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_SearchBar.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_SearchBar.h
20  * @brief               This is the header file for the _SearchBar class.
21  *
22  * This header file contains the declarations of the %_SearchBar class.
23  */
24
25 #ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_H_
26 #define _FUI_CTRL_INTERNAL_SEARCH_BAR_H_
27
28 #include <FUiCtrlSearchBar.h>
29 #include "FUi_Control.h"
30 #include "FUiCtrl_Button.h"
31 #include "FUiCtrl_Edit.h"
32 #include "FUiCtrl_IActionEventListener.h"
33 #include "FUiCtrl_IKeypadEventListener.h"
34 #include "FUiCtrl_ILanguageEventListener.h"
35 #include "FUiCtrl_ITextBlockEventListener.h"
36 #include "FUiCtrl_ITextEventListener.h"
37 #include "FUiCtrl_ISearchBarEventListener.h"
38 #include "FUiCtrl_KeypadEvent.h"
39 #include "FUiCtrl_LanguageEvent.h"
40 #include "FUiCtrl_SearchBarEvent.h"
41
42 const int SEARCHBAR_COLOR_MAX = 3;
43 const int SEARCHBAR_BUTTON_COLOR_MAX = 4;
44 const int SEARCHBAR_TEXT_LENGTH_MAX = 500;
45 const int SEARCHBAR_DEFAULT_OPACITY = 100;
46
47 namespace Tizen { namespace Ui { namespace Animations
48 {
49 class _VisualElement;
50 }}} // Tizen::Ui::Animations
51
52 namespace Tizen { namespace Ui { namespace Controls
53 {
54
55 class _Panel;
56 class _SearchBarPresenter;
57 class _ActionEvent;
58 class _TextBlockEvent;
59 class _TextEvent;
60
61 /**
62  * @class _SearchBar
63  * @brief
64  * @since 2.0
65  */
66 class _SearchBar
67         : public _Control
68         , public _IActionEventListener
69         , public _IKeypadEventListener
70         , public _ITextBlockEventListener
71         , public _ITextEventListener
72         , virtual public Tizen::Base::Runtime::IEventListener
73         , virtual public Tizen::Ui::_IUiEventListener
74         , virtual public Tizen::Ui::_IUiEventPreviewer
75 {
76         DECLARE_CLASS_BEGIN(_SearchBar, _Control);
77         DECLARE_PROPERTY("buttonActionId", GetPropertyButtonActionId, SetPropertyButtonActionId);
78         DECLARE_PROPERTY("buttonDisabledColor", GetPropertyButtonDisabledColor, SetPropertyButtonDisabledColor);
79         DECLARE_PROPERTY("buttonHighlightedColor", GetPropertyButtonHighlightedColor, SetPropertyButtonHighlightedColor);
80         DECLARE_PROPERTY("buttonNormalColor", GetPropertyButtonNormalColor, SetPropertyButtonNormalColor);
81         DECLARE_PROPERTY("buttonPressedColor", GetPropertyButtonPressedColor, SetPropertyButtonPressedColor);
82         DECLARE_PROPERTY("buttonDisabledTextColor", GetPropertyButtonDisabledTextColor, SetPropertyButtonDisabledTextColor);
83         DECLARE_PROPERTY("buttonHighlightedTextColor", GetPropertyButtonHighlightedTextColor, SetPropertyButtonHighlightedTextColor);
84         DECLARE_PROPERTY("buttonNormalTextColor", GetPropertyButtonNormalTextColor, SetPropertyButtonNormalTextColor);
85         DECLARE_PROPERTY("buttonPressedTextColor", GetPropertyButtonPressedTextColor, SetPropertyButtonPressedTextColor);
86         DECLARE_PROPERTY("searchFieldDisabledColor", GetPropertySearchFieldDisabledColor, SetPropertySearchFieldDisabledColor);
87         DECLARE_PROPERTY("searchFieldHighlightedColor", GetPropertySearchFieldHighlightedColor, SetPropertySearchFieldHighlightedColor);
88         DECLARE_PROPERTY("searchFieldNormalColor", GetPropertySearchFieldNormalColor, SetPropertySearchFieldNormalColor);
89         DECLARE_PROPERTY("searchFieldDisabledTextColor", GetPropertySearchFieldDisabledTextColor, SetPropertySearchFieldDisabledTextColor);
90         DECLARE_PROPERTY("searchFieldHighlightedTextColor", GetPropertySearchFieldHighlightedTextColor, SetPropertySearchFieldHighlightedTextColor);
91         DECLARE_PROPERTY("searchFieldNormalTextColor", GetPropertySearchFieldNormalTextColor, SetPropertySearchFieldNormalTextColor);
92         DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor);
93         DECLARE_PROPERTY("contentAreaSize", GetPropertyContentAreaSize, SetPropertyContentAreaSize);
94         DECLARE_CLASS_END();
95
96         result SetPropertyButtonActionId(const Tizen::Ui::Variant& actionId);
97         Tizen::Ui::Variant GetPropertyButtonActionId(void) const;
98         result SetPropertyButtonDisabledColor(const Tizen::Ui::Variant& color);
99         Tizen::Ui::Variant GetPropertyButtonDisabledColor(void) const;
100         result SetPropertyButtonHighlightedColor(const Tizen::Ui::Variant& color);
101         Tizen::Ui::Variant GetPropertyButtonHighlightedColor(void) const;
102         result SetPropertyButtonNormalColor(const Tizen::Ui::Variant& color);
103         Tizen::Ui::Variant GetPropertyButtonNormalColor(void) const;
104         result SetPropertyButtonPressedColor(const Tizen::Ui::Variant& color);
105         Tizen::Ui::Variant GetPropertyButtonPressedColor(void) const;
106         result SetPropertyButtonDisabledTextColor(const Tizen::Ui::Variant& textColor);
107         Tizen::Ui::Variant GetPropertyButtonDisabledTextColor(void) const;
108         result SetPropertyButtonHighlightedTextColor(const Tizen::Ui::Variant& textColor);
109         Tizen::Ui::Variant GetPropertyButtonHighlightedTextColor(void) const;
110         result SetPropertyButtonNormalTextColor(const Tizen::Ui::Variant& textColor);
111         Tizen::Ui::Variant GetPropertyButtonNormalTextColor(void) const;
112         result SetPropertyButtonPressedTextColor(const Tizen::Ui::Variant& textColor);
113         Tizen::Ui::Variant GetPropertyButtonPressedTextColor(void) const;
114         result SetPropertySearchFieldDisabledColor(const Tizen::Ui::Variant& color);
115         Tizen::Ui::Variant GetPropertySearchFieldDisabledColor(void) const;
116         result SetPropertySearchFieldHighlightedColor(const Tizen::Ui::Variant& color);
117         Tizen::Ui::Variant GetPropertySearchFieldHighlightedColor(void) const;
118         result SetPropertySearchFieldNormalColor(const Tizen::Ui::Variant& color);
119         Tizen::Ui::Variant GetPropertySearchFieldNormalColor(void) const;
120         result SetPropertySearchFieldDisabledTextColor(const Tizen::Ui::Variant& textColor);
121         Tizen::Ui::Variant GetPropertySearchFieldDisabledTextColor(void) const;
122         result SetPropertySearchFieldHighlightedTextColor(const Tizen::Ui::Variant& textColor);
123         Tizen::Ui::Variant GetPropertySearchFieldHighlightedTextColor(void) const;
124         result SetPropertySearchFieldNormalTextColor(const Tizen::Ui::Variant& textColor);
125         Tizen::Ui::Variant GetPropertySearchFieldNormalTextColor(void) const;
126         result SetPropertyColor(const Tizen::Ui::Variant& color);
127         Tizen::Ui::Variant GetPropertyColor(void) const;
128         result SetPropertyContentAreaSize(const Tizen::Ui::Variant& size);
129         Tizen::Ui::Variant GetPropertyContentAreaSize(void) const;
130
131 public:
132         /**
133          * This is default constructor for this class.
134          *
135          * @since       2.0
136          */
137         _SearchBar(void);
138
139         /**
140          * This is the destructor for this class.
141          *
142          * @since       2.0
143          */
144         virtual ~_SearchBar(void);
145
146         static _SearchBar* CreateSearchBarN(void);
147
148         /**
149          * Initializes this instance of the SearchBar control with the specified parameters.
150          *
151          * @since               2.0
152          * @return      An error code
153          * @param[in]   enableSearchBarButton   Set to @c true to display the search bar button, @n
154          *                              else @c false
155          * @param[in]   keypadAction    The keypad action
156          * @exception   E_SUCCESS               The method was successful.
157          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or the action ID of the specified item must be a positive integer.
158          * @exception   E_SYSTEM                A system error occurred.
159          * @remarks     By default, a "Cancel" button is displayed if @c enableSearchBarButton is set to @c true. When the user presses the cancel button,
160          *              the SearchBar control returns to SEARCH_BAR_MODE_NORMAL automatically.
161          */
162         result Initialize(bool enableSearchBarButton = true, CoreKeypadAction keypadAction = CORE_KEYPAD_ACTION_SEARCH);
163
164         /**
165          * Gets the content of %Control.
166          *
167          * @since                2.0
168          * @return       The control that is displayed in the SearchBar's content area in SEARCH_BAR_MODE_INPUT mode, @n
169          *                               else @c null if an error occurs
170          * @exception    E_SUCCESS                      The method was successful.
171          * @remarks      The specific error code can be accessed using the GetLastResult() method.
172          */
173         Tizen::Ui::_Control* GetContent(void) const;
174
175         /**
176          * Sets the content control.
177          *
178          * @since               2.0
179          * @return      An error code
180          * @param[in]   pContent           The control that is to be displayed in the
181          *                                 SearchBar's content area.
182          * @exception   E_SUCCESS          The method was successful.
183          * @exception   E_INVALID_ARG      A specified input parameter is invalid. @n
184          *                                 The following controls cannot be set as the
185          *                                 content: @n
186          *                                 @li All classes derived from Window class
187          *                                 @li All picker classes (ex: DateTimePicker)
188          *                                 @li Form
189          *                                 @li Keypad
190          *                                 @li OverlayPanel
191          * @exception   E_SYSTEM           A system error occurred.
192          * @remarks     The specified content control is displayed when the SearchBar controls mode is changed to SEARCH_BAR_MODE_INPUT.
193          * @see         GetContentAreaSize()
194          * @see         AddSearchBarEventListener()
195          * @see         ISearchBarEventListener
196          */
197         result SetContent(const Tizen::Ui::_Control* pContent);
198
199         /**
200          * Updates the content area of the SearchBar control.
201          *
202          * @since  2.0
203          * @return      An error code
204          * @param[in]   show        A Boolean flag indicating whether to perform show on the content area.
205          * @exception   E_SUCCESS              The method was successful.
206          * @exception   E_INVALID_OPERATION    The current state of the instance prohibits the execution of the specified operation @n
207          *                                     -- the current mode of SearchBar prohibits the execution of the method. @n
208          * @exception   E_SYSTEM               A system error occurred.
209          * @remarks     The method performs Invalidate() on the content area.
210          */
211         result UpdateContentArea(bool invalidate = true);
212
213         /**
214          * Sets the visibility state of the content area.
215          *
216          * @since       2.0
217          * @return      An error code
218          * @param[in]   visible            The visibility state of the content area.
219          * @exception   E_SUCCESS          The method was successful.
220          * @exception   E_SYSTEM           A system error occurred.
221          * @see         IsContentAreaVisible()
222          */
223         result SetContentAreaVisible(bool visible);
224
225         /**
226          * Checks whether the content area is visible.
227          *
228          * @since       2.0
229          * @return      The visibility state of the content area.
230          * @exception   E_SUCCESS           The method was successful.
231          * @see         SetContentAreaVisible()
232          */
233         bool IsContentAreaVisible(void) const;
234
235         /**
236          * Sets the size of the content area of the SearchBar control.
237          *
238          * @since       2.0
239          * @return      An error code
240          * @param[in]   size               The content area size.
241          * @exception   E_SUCCESS          The method was successful.
242          * @exception   E_INVALID_ARG      A specified input parameter is invalid. @n
243          *                                 -- width and height of @c size must be greater than or equal to @c 0.
244          * @remarks     You must resize the content area when the Form's orientation is changed once you change the
245
246          *              the size of the content area.
247
248          * @see         GetContentAreaSize()
249          */
250         result SetContentAreaSize(const Tizen::Graphics::Dimension& size);
251
252         /**
253          * Gets the size of the content area of the SearchBar control.
254          *
255          * @since               2.0
256          * @return      The size of the content area
257          * @remarks     The content area is the area where the 'content' of the SearchBar control is displayed. The size of the content areas can
258          *              be changed at runtime.
259          * @see         AddSearchBarEventListener()
260          * @see         ISearchBarEventListener
261          */
262         Tizen::Graphics::Dimension GetContentAreaSize(void) const;
263
264         /**
265          * Gets the search bar mode.
266          *
267          * @since               2.0
268          * @return      The search bar mode
269          * @exception   E_SUCCESS           The method was successful.
270          * @exception   E_SYSTEM            A system error occurred.
271          * @remarks     The specific error code can be accessed using the GetLastResult() method.
272          * @see         SetMode()
273          */
274         SearchBarMode GetMode(void) const;
275
276         /**
277          * Determines whether the search bar mode is locked.
278          *
279          * @since               2.0
280          * @return      @c true if the mode is locked, @n
281          *                              else @c false
282          * @exception   E_SUCCESS           The method was successful.
283          * @exception   E_SYSTEM            A system error occurred.
284          * @remarks     The specific error code can be accessed using the GetLastResult() method.
285          * @see         SetModeLock()
286          */
287         bool IsModeLocked(void) const;
288
289         /**
290          * Sets the search bar mode.
291          *
292          * @since               2.0
293          * @return      An error code
294          * @exception   E_SUCCESS           The method was successful.
295          * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, or the mode is locked.
296          * @exception   E_SYSTEM            A system error occurred.
297          * @see         GetMode()
298          * @see         SetModeLock()
299          */
300         result SetMode(SearchBarMode mode);
301
302         /**
303          * Locks or unlocks the search bar mode.
304          *
305          * @since               2.0
306          * @return      An error code
307          * @param[in]   modeLocked      The mode lock
308          * @exception   E_SUCCESS       The method was successful.
309          * @exception   E_SYSTEM        A system error occurred.
310          * @see         GetMode()
311          */
312         result SetModeLocked(bool modeLocked);
313
314         /**
315          * Gets the search bar button's action Id
316          *
317          * @since               2.0
318          * @return      The action ID, @n
319          *                              else @c -1 if an error occurs
320          * @exception   E_SUCCESS           The method was successful.
321          * @exception   E_SYSTEM            A system error occurred.
322          * @remarks     The specific error code can be accessed using the GetLastResult() method. @n
323          *                              By default, the method returns @c -1 if no user defined search bar button is set.
324          */
325         int GetButtonActionId(void) const;
326
327         /**
328          * Gets the color of the search bar button for the specified state.
329          *
330          * @since               2.0
331          * @return      The color of the search bar button, @n
332          *                              else RGBA(0,0,0,0) if an error occurs
333          * @param[in]   status              The search bar button's status
334          * @exception   E_SUCCESS           The method was successful.
335          * @exception   E_SYSTEM            A system error occurred.
336          * @remarks     The specific error code can be accessed using the GetLastResult() method.
337          * @see         SetButtonColor()
338          */
339         Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const;
340
341         /**
342          * Gets the text color of the search bar button for the specified state.
343          *
344          * @since               2.0
345          * @return      The text color of the search bar button, @n
346          *                              else RGBA(0,0,0,0) if an error occurs
347          * @param[in]   status              The search bar button's status
348          * @exception   E_SUCCESS           The method was successful.
349          * @exception   E_SYSTEM            A system error occurred.
350          * @remarks     The specific error code can be accessed using the GetLastResult() method.
351          */
352         Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const;
353
354         /**
355          * Gets the state of the search bar button.
356          *
357          * @since               2.0
358          * @return      The state of the search bar button
359          * @exception   E_SUCCESS           The method was successful.
360          * @exception   E_SYSTEM            A system error occurred.
361          * @remarks     The specific error code can be accessed using the GetLastResult() method.
362          */
363         SearchBarButtonStatus GetButtonStatus(void) const;
364
365         /**
366          * Sets the user defined search bar button text.
367          *
368          * @since               2.0
369          * @return      An error code
370          * @param[in]   actionId        The button action ID
371          * @exception   E_SUCCESS       The method was successful.
372          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or the action ID of the specified item must greater than or equal to zero.
373          * @exception   E_SYSTEM        A system error occurred.
374          */
375         result SetButtonText(const Tizen::Base::String& text);
376
377         /**
378          * Sets the user defined search bar button action ID.
379          *
380          * @since               2.0
381          * @return      An error code
382          * @param[in]   actionId        The button action ID
383          * @exception   E_SUCCESS       The method was successful.
384          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or the action ID of the specified item must greater than or equal to zero.
385          * @exception   E_SYSTEM        A system error occurred.
386          */
387         result SetButtonActionId(int actionId);
388
389         /**
390          * Enables or disables the search bar button.
391          *
392          * @since               2.0
393          * @return      An error code
394          * @param[in]   enabled         Set to @c true to enable the search bar button, @n
395          *                              else @c false
396          * @exception   E_SUCCESS       The method was successful.
397          * @exception   E_SYSTEM        A system error occurred.
398          */
399         result SetButtonEnabled(bool enabled);
400
401         /**
402          * Sets the search bar button's color for the specified state.
403          *
404          * @since               2.0
405          * @return              An error code
406          * @param[in]   status          The button status
407          * @param[in]   color           The button color to set
408          * @exception   E_SUCCESS       The method was successful.
409          * @exception   E_SYSTEM            A system error occurred.
410          * @see         GetButtonColor()
411          */
412         result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
413
414         /**
415          * Sets the text color of the SearchBar control's button for the specified state.
416          *
417          * @since               2.0
418          * @return      An error code
419          * @param[in]   status          The button status
420          * @param[in]   color           The button text color to set
421          * @exception   E_SUCCESS       The method was successful.
422          * @exception   E_SYSTEM        A system error occurred.
423          */
424         result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
425
426         /**
427          * Appends the specified character at the end of the text.
428          *
429          * @since               2.0
430          * @return              An error code
431          * @param[in]   character           The character to add
432          * @exception   E_SUCCESS       The method was successful.
433          * @exception   E_SYSTEM            A system error occurred.
434          * @remarks             The method modifies the text buffer that is managed by the SearchBar control. @n
435          *              To display the changes, the control must be drawn again.
436          */
437         result AppendCharacter(const Tizen::Base::Character& character);
438
439         /**
440          * Appends the specified text at the end of the existing text.
441          *
442          * @since               1.0
443          * @return              An error code
444          * @param[in]   text        The text to append
445          * @exception   E_SUCCESS   The method was successful.
446          * @exception   E_SYSTEM    A system error occurred.
447          * @remarks     To denote the end of a line use '\\n'. @n
448          *              The method modifies the text buffer that is managed by the SearchBar control. @n
449          *              To display the changes, the control must be drawn again.
450          */
451         result AppendText(const Tizen::Base::String& text);
452
453         /**
454          * Sets the text to display.
455          *
456          * @since               2.0
457          * @return              An error code
458          * @param[in]   text            The text to display
459          * @exception   E_SUCCESS       The method was successful.
460          * @exception   E_SYSTEM        A system error occurred.
461          * @remarks     To denote the end of a line use '\\n'. @n
462          *              The method modifies the text buffer that is managed by the SearchBar control. @n
463          *              To display the changes, the control must be drawn again.
464          */
465         result SetText(const Tizen::Base::String& text);
466
467         /**
468          * Inserts the character at the specified index.
469          *
470          * @since               2.0
471          * @return              An error code
472          * @param[in]   index               The position to insert the character
473          * @param[in]   character           The character to insert
474          * @exception   E_SUCCESS       The method was successful.
475          * @exception   E_OUT_OF_RANGE  The specified @c index is outside the bounds of the data structure. @n
476          *                              -- @c index is greater than the number of elements or less than zero.
477          * @exception   E_MAX_EXCEEDED  The length of the specified @c text exceeds the system limitation.
478          * @exception   E_SYSTEM        A system error occurred.
479          * @remarks     The method modifies the text buffer that is managed by the SearchBar control.
480          *              To display the changes, the control must be drawn again.
481          */
482         result InsertCharacterAt(int index, const Tizen::Base::Character& character);
483
484         /**
485          * Inserts the specified text at the specified index.
486          *
487          * @since               2.0
488          * @return              An error code
489          * @param[in]   index               The position at which to insert.
490          * @param[in]   text                The text to be inserted
491          * @exception   E_SUCCESS       The method was successful.
492          * @exception   E_OUT_OF_RANGE  The specified @c index is outside the bounds
493          *                              of the data structure. @n
494          *                              -- @c index is greater than the number of elements or less than zero.
495          * @exception   E_MAX_EXCEEDED  The length of the specified @c text
496          *                              exceeds the system limitation.
497          * @exception   E_SYSTEM            A system error occurred.
498          * @remarks     The method modifies the text buffer that is managed by the SearchBar control.
499          *              To display the changes, the control must be drawn again.
500          */
501         result InsertTextAt(int index, const Tizen::Base::String& text);
502
503         /**
504          * Deletes the character at the specified position.
505          *
506          * @since       2.0
507          * @return      An error code
508          * @param[in]   index                   The index
509          * @exception   E_SUCCESS               The method was successful.
510          * @exception   E_INVALID_ARG   The specified @c index is negative.
511          * @exception   E_OUT_OF_RANGE  The specified @c index is outside the bounds
512          *                              of the data structure. @n
513          *                              -- @c index is greater than the number of elements or less than zero.
514          * @exception   E_SYSTEM                A system error occurred.
515          * @remarks     The method modifies the text buffer that is managed by the SearchBar control.
516          *              To display the changes, the control must be drawn again.
517          */
518         result DeleteCharacterAt(int index);
519
520         /**
521          * Clears text that is displayed by the SearchBar control.
522          *
523          * @since               2.0
524          * @return              An error code
525          * @exception   E_SUCCESS       The method was successful.
526          * @exception   E_SYSTEM            A system error occurred.
527          * @remarks     The method modifies the text buffer that is managed by the SearchBar control.
528          *              To display the changes, the control must be drawn again.
529          */
530         result Clear(void);
531
532         /**
533          * Gets the length of the text that is displayed by the SearchBar control.
534          *
535          * @since               2.0
536          * @return              The length of the text, @n
537          *              else @c -1 if an error occurs
538          * @exception   E_SUCCESS               The method was successful.
539          * @exception   E_SYSTEM                A system error occurred.
540          * @remarks             The specific error code can be accessed using the GetLastResult() method.
541          */
542         int GetTextLength(void) const;
543
544         /**
545          * Gets the text that is displayed by the SearchBar control.
546          *
547          * @since               2.0
548          * @return              The text of the SearchBar control, @n
549          *                          else an empty string if an error occurs
550          * @exception   E_SUCCESS           The method was successful.
551          * @exception   E_SYSTEM            A system error occurred.
552          * @remarks     The specific error code can be accessed using the GetLastResult() method.
553          * @see                 SetText()
554          */
555         Tizen::Base::String GetText(void) const;
556
557         /**
558          * Gets a portion of text that is displayed by the SearchBar control.
559          *
560          * @since               2.0
561          * @return              The specified portion of the text, @n
562          *                              else an empty string if an error occurs
563          * @param[in]   start           The starting index of range
564          * @param[in]   end                 The last index of range
565          * @exception   E_SUCCESS       The method was successful.
566          * @exception   E_OUT_OF_RANGE  The specified index is outside the bounds of the data structure, or either the @c start or @c end parameter is greater than the number of elements or less than zero.
567          * @exception   E_SYSTEM            A system error occurred.
568          * @remarks             The specific error code can be accessed using the GetLastResult() method.
569          * @see                 SetText()
570          */
571         Tizen::Base::String GetText(int start, int end) const;
572
573         /**
574          * Gets the limit of the length of the text.
575          *
576          * @since               2.0
577          * @return      The limit length, @n
578          *              else @c -1 if an error occurs
579          * @exception   E_SUCCESS               The method was successful.
580          * @exception   E_SYSTEM                A system error occurred.
581          * @remarks     The specific error code can be accessed using the GetLastResult() method. @n
582          *                              The default limit length is @c 500.
583          * @see         SetLimitLength()
584          */
585         int GetLimitLength(void) const;
586
587         /**
588          * Sets the limit of the length of the text.
589          *
590          * @since               2.0
591          * @return      An error code
592          * @param[in]   limitLength              The limit text length to set
593          * @exception   E_SUCCESS        The method was successful.
594          * @exception   E_INVALID_ARG    A specified input parameter is invalid, or the specified limit length cannot be negative value or zero.
595          * @exception   E_SYSTEM         A system error occurred.
596          * @see         GetLimitLength()
597          */
598         result SetLimitLength(int limitLength);
599
600         /**
601          * Opens the keypad associated with the SearchBar control.
602          *
603          * @since               2.0
604          * @return      An error code
605          * @exception   E_SUCCESS               The method was successful.
606          * @exception   E_SYSTEM                A system error occurred.
607          * @see         HideKeypad()
608          */
609         result ShowKeypad(void) const;
610
611         /**
612          * Closes the keypad associated with the SearchBar control.
613          *
614          * @since               2.0
615          * @return      An error code
616          * @exception   E_SUCCESS               The method was successful.
617          * @exception   E_SYSTEM                A system error occurred.
618          * @see         ShowKeypad()
619          */
620         result HideKeypad(void);
621
622         /**
623          * Gets the text size of the search field.
624          *
625          * @since               2.0
626          * @return      The size of the text, @n
627          *              else @c -1 if an error occurs
628          * @exception   E_SUCCESS               The method was successful.
629          * @exception   E_SYSTEM                A system error occurred.
630          * @remarks     The specific error code can be accessed using the GetLastResult() method.
631          * @see         SetSearchFieldTextSize()
632          */
633         int GetSearchFieldTextSize(void) const;
634
635         /**
636          * Sets the text size of the SearchBar control's text field.
637          *
638          * @since               2.0
639          * @return      An error code
640          * @param[in]   size                    The text size
641          * @exception   E_SUCCESS               The method was successful.
642          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or the specified @c size cannot be negative value.
643          * @exception   E_SYSTEM                A system error occurred.
644          * @see         GetSearchFieldTextSize()
645          */
646         result SetSearchFieldTextSize(int size);
647
648         /**
649          * Gets the start and the end index of the currently selected text block.
650          *
651          * @since               2.0
652          * @return              An error code
653          * @param[out]  start                   The start index of the text block
654          * @param[out]  end                             The end index of the text block
655          * @exception   E_SUCCESS               The method was successful.
656          * @exception   E_SYSTEM                A system error occurred.
657          * @remarks             The method returns @c start = 0 and @c end = 0 if no text block is selected.
658          * @see                 ReleaseBlock()
659          * @see                 SetBlockRange()
660          */
661         result GetBlockRange(int& start, int& end) const;
662
663         /**
664          * Releases the selection of the current text block.
665          *
666          * @since               2.0
667          * @return              An error code
668          * @exception   E_SUCCESS          The method was successful.
669          * @exception   E_SYSTEM           A system error occurred.
670          * @see                 GetBlockRange()
671          * @see                 SetBlockRange()
672          */
673         result ReleaseBlock(void);
674
675         /**
676          * Selects the specified block of the text.
677          *
678          * @since               2.0
679          * @return              An error code
680          * @param[in]   start           The start index of the text block
681          * @param[in]   end             The end index of the text block
682          * @exception   E_SUCCESS       The method was successful.
683          * @exception   E_OUT_OF_RANGE  The specified index is outside the bounds of the data structure, or either the @c start or @c end parameter is greater than the number of elements or less than zero.
684          * @exception   E_SYSTEM        A system error occurred.
685          * @see                 ReleaseBlock()
686          * @see                 GetBlockRange()
687          */
688         result SetBlockRange(int start, int end);
689
690         /**
691          * Removes the text of the selected text block.
692          *
693          * @since               2.0
694          * @return              An error code
695          * @exception   E_SUCCESS           The method was successful.
696          * @exception   E_SYSTEM                A system error occurred.
697          */
698         result RemoveTextBlock(void);
699
700         /**
701          * Gets the color of the SearchBar control for the specified status.
702          *
703          * @since               2.0
704          * @return              The color of the SearchBar control, @n
705          *                              else RGBA(0,0,0,0) if an error occurs
706          * @exception   E_SUCCESS               The method was successful.
707          * @exception   E_SYSTEM                A system error occurred.
708          * @remarks             The specific error code can be accessed using the GetLastResult() method.
709          * @see                 SetColor()
710          */
711         Tizen::Graphics::Color GetColor(void) const;
712
713         /**
714          * Gets the color of the search field for the specified status.
715          *
716          * @since               2.0
717          * @return              The color, @n
718          *                              else RGBA(0,0,0,0) if an error occurs
719          * @param[in]   status                  The search field status
720          * @exception   E_SUCCESS               The method was successful.
721          * @exception   E_SYSTEM                A system error occurred.
722          * @remarks             The specific error code can be accessed using the GetLastResult() method.
723          * @see                 SetSearchFieldColor()
724          */
725         Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const;
726
727         /**
728          * Gets the text color of the search field for the specified status.
729          *
730          * @since               2.0
731          * @return              The text color, @n
732          *                              else RGBA(0,0,0,0) if an error occurs
733          * @param[in]   status                  The search field status
734          * @exception   E_SUCCESS               The method was successful.
735          * @exception   E_SYSTEM                A system error occurred.
736          * @remarks             The specific error code can be accessed using the GetLastResult() method.
737          * @see                 SetSearchFieldTextColor()
738          */
739         Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const;
740
741         /**
742          * Sets the background bitmap of the SearchBar control.
743          *
744          * @since               2.0
745          * @return              An error code
746          * @param[in]   bitmap              The background bitmap
747          * @exception   E_SUCCESS       The method was successful.
748          * @exception   E_SYSTEM        A system error occurred.
749          */
750         result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap);
751
752         /**
753          * Sets the color of the search bar.
754          *
755          * @since               2.0
756          * @return              An error code
757          * @param[in]   status              The state of SearchBar
758          * @param[in]   color               The color
759          * @exception   E_SUCCESS       The method was successful.
760          * @exception   E_SYSTEM        A system error occurred.
761          * @see                 GetColor()
762          */
763         result SetColor(const Tizen::Graphics::Color& color);
764
765         /**
766          * Sets the color of the search field for the specified status.
767          *
768          * @since               2.0
769          * @return          An error code
770          * @param[in]   status               The state of search field
771          * @param[in]   color                The text color
772          * @exception   E_SUCCESS        The method was successful.
773          * @exception   E_SYSTEM         A system error occurred.
774          * @see         GetSearchFieldColor()
775          */
776         result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
777
778         /**
779          * Sets the text color of the search field for the specified status.
780          *
781          * @since               2.0
782          * @return          An error code
783          * @param[in]   status               The state of search field
784          * @param[in]   color                The text color
785          * @exception   E_SUCCESS        The method was successful.
786          * @exception   E_SYSTEM         A system error occurred.
787          * @see         GetSearchFieldTextColor()
788          */
789         result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
790
791         /**
792          * Gets the guide text.
793          *
794          * @since               2.0
795          * @return          The guide text, @n
796          *                              else an empty string if an error occurs
797          * @param[in]   guideText
798          * @exception   E_SUCCESS        The method was successful.
799          * @exception   E_SYSTEM         A system error occurred.
800          * @remarks     The specific error code can be accessed using the GetLastResult() method.
801          * @see         GetGuideText()
802          */
803         Tizen::Base::String GetGuideText(void) const;
804
805         /**
806          * Displays the specified text when there is no text in the SearchBar control.
807          *
808          * @since               2.0
809          * @return          An error code
810          * @param[in]   guideText                The guide text
811          * @exception   E_SUCCESS        The method was successful.
812          * @exception   E_SYSTEM         A system error occurred.
813          * @see         GetGuideText()
814          */
815         result SetGuideText(const Tizen::Base::String& guideText);
816
817         /**
818          * Gets the text color of the guide text.
819          *
820          * @since               2.0
821          * @return          The text color of the guide text, @n
822          *                              else RGBA(0,0,0,0) if an error occurs
823          * @exception   E_SUCCESS        The method was successful.
824          * @exception   E_SYSTEM         A system error occurred.
825          * @remarks     The specific error code can be accessed using the GetLastResult() method.
826          * @see         SetGuideTextColor()
827          */
828         Tizen::Graphics::Color GetGuideTextColor(void) const;
829
830         /**
831          * Sets the text color of the guide text.
832          *
833          * @since               2.0
834          * @return          An error code
835          * @param[in]   color                The guide text color
836          * @exception   E_SUCCESS        The method was successful.
837          * @exception   E_SYSTEM         A system error occurred.
838          * @see         GetGuideTextColor()
839          */
840         result SetGuideTextColor(const Tizen::Graphics::Color& color);
841
842         /**
843          * Gets the current cursor position index.
844          *
845          * @since               2.0
846          * @return              The cursor position, @n
847          *                              else @c -1 if an error occurs
848          * @exception   E_SUCCESS           The method was successful.
849          * @exception   E_SYSTEM            A system error occurred.
850          * @remarks             The specific error code can be accessed using the GetLastResult() method.
851          * @see                 SetCursorPosition()
852          */
853         int GetCursorPosition(void) const;
854
855         /**
856          * Sets the cursor at the specified index.
857          *
858          * @since               2.0
859          * @return      An error code
860          * @param[in]   index               The cursor index
861          * @exception   E_SUCCESS       The method was successful.
862          * @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.
863          * @exception   E_SYSTEM            A system error occurred.
864          * @see         GetCursorPosition()
865          */
866         result SetCursorPosition(int index);
867
868         /**
869          * Checks whether the lowercase mode is enabled.
870          *
871          * @since               2.0
872          * @return              @c true if the lowercase mode is enabled, @n
873          *                              else @c false
874          * @exception   E_SUCCESS               The method was successful.
875          * @exception   E_SYSTEM                A system error occurred.
876          * @remarks             The specific error code can be accessed using the GetLastResult() method.
877          * @see         SetLowerCaseModeEnabled()
878          */
879         bool IsLowerCaseModeEnabled(void) const;
880
881         /**
882          * Enables or disables the lowercase mode.
883          *
884          * @since               2.0
885          * @param[in]   enable  Set to @c true to enable lowercase mode, @n
886          *                                              else @c false
887          * @exception   E_SUCCESS               The method was successful.
888          * @exception   E_SYSTEM                A system error occurred.
889          * @see         IsLowerCaseModeEnabled()
890          */
891         void SetLowerCaseModeEnabled(bool enable);
892
893         /**
894          * Gets the ellipsis position.
895          *
896          * @since               2.0
897          * @return      The ellipsis position
898          * @exception   E_SUCCESS           The method was successful.
899          * @exception   E_SYSTEM            A system error occurred.
900          * @remarks     The specific error code can be accessed using the GetLastResult() method.
901          * @see         SetEllipsisPosition()
902          */
903         EllipsisPosition GetEllipsisPosition(void) const;
904
905         /**
906          * Sets the ellipsis position.
907          *
908          * @since               2.0
909          * @return      An error code
910          * @param[in]   position                The ellipsis position
911          * @exception   E_SUCCESS           The method was successful.
912          * @exception   E_SYSTEM            A system error occurred.
913          * @see         GetEllipsisPosition()
914          */
915         result SetEllipsisPosition(EllipsisPosition position);
916
917         /**
918          * Gets the keypad action type.
919          *
920          * @since               2.0
921          * @return      The keypad action
922          * @exception   E_SUCCESS           The method was successful.
923          * @exception   E_SYSTEM            A system error occurred.
924          * @remarks     The specific error code can be accessed using the GetLastResult() method.
925          */
926         CoreKeypadAction GetKeypadAction(void) const;
927
928         /**
929         * Checks whether the text prediction is enabled.
930         *
931         * @since 2.0
932         * @return               @c true if the text prediction is enabled, @n
933         *                                       else @c false
934         * @exception            E_SUCCESS                       The method is successful.
935         * @exception            E_SYSTEM                        A system error has occurred.
936         * @remarks                      The specific error code can be accessed using the GetLastResult() method.
937         * @see                          SetTextPredictionEnabled()
938         */
939         bool IsTextPredictionEnabled(void) const;
940
941         /**
942         * Enables or disables the text prediction.
943         *
944         * @since 2.0
945         * @param[in]            enable                          Set to @c true to enable the text prediction, @n
946         *                                                                               else @c false
947         * @return                       An error code
948         * @exception            E_SUCCESS                       The method is successful.
949         * @exception            E_SYSTEM                        A system error has occurred.
950         * @see                          IsTextPredictionEnabled()
951          */
952         result SetTextPredictionEnabled(bool enable);
953
954         result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const;
955         result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode);
956
957         result AddActionEventListener(const _IActionEventListener& listener);
958         result RemoveActionEventListener(const _IActionEventListener& listener);
959         result AddKeypadEventListener(const _IKeypadEventListener& listener);
960         result RemoveKeypadEventListener(const _IKeypadEventListener& listener);
961         result AddTextBlockEventListener(const _ITextBlockEventListener& listener);
962         result RemoveTextBlockEventListener(const _ITextBlockEventListener& listener);
963         result AddTextEventListener(const _ITextEventListener& listener);
964         result RemoveTextEventListener(const _ITextEventListener& listener);
965         result AddSearchBarEventListener(const _ISearchBarEventListener& listener);
966         result RemoveSearchBarEventListener(const _ISearchBarEventListener& listener);
967         result AddLanguageEventListener(const _ILanguageEventListener& listener);
968         result RemoveLanguageEventListener(const _ILanguageEventListener& listener);
969
970         void SetContentsArea(void);
971
972         Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const;
973         bool IsUsableCancelButton(void) const;
974
975         _Button* GetSearchBarButton(void) const;
976         _Edit* GetSearchField(void);
977         _Control* GetSearchBarContainer(void) const;
978         _Control* GetClippedGroupControl(void) const;
979
980         result SendSearchBarEvent(_SearchBarEventStatus status);
981         void SetHeaderVisibleState(bool visible);
982         void SetContentDimming(void);
983         bool IsContentAttachable(const _Control* pContent);
984         result ResizeCancelButton(void);
985
986         virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
987
988         virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
989
990         virtual void OnKeypadWillOpen(void);
991         virtual void OnKeypadOpened(void);
992         virtual void OnKeypadClosed(void);
993         virtual void OnKeypadBoundsChanged(void);
994         virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction);
995
996         virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end);
997
998         virtual void OnTextValueChanged(const Tizen::Ui::_Control& source);
999         virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source);
1000
1001         virtual void OnBoundsChanged(void);
1002         virtual result OnAttachedToMainTree(void);
1003         virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
1004         virtual void OnFontInfoRequested(unsigned long& style, int& size);
1005         virtual bool OnFocusGained(const _Control& source);
1006         virtual bool OnFocusLost(const _Control& source);
1007
1008 protected:
1009         virtual void OnDraw(void);
1010
1011 private:
1012         _SearchBar(const _SearchBar&);
1013         _SearchBar& operator =(const _SearchBar&);
1014
1015         _ButtonStatus ConvertSearchBarButtonStatus(SearchBarButtonStatus status);
1016         EditStatus ConvertSearchBarStatus(SearchFieldStatus status);
1017
1018         result CreateSearchField(void);
1019         result CreateCancelButton(void);
1020         result CreateFrontButton(void);
1021         result CreateContentsArea(void);
1022         result CreateClippedGroupControl(void);
1023         //Tizen::Graphics::Font* CreateEditFontN(const Tizen::Graphics::Font* pFont);
1024
1025         Tizen::Ui::_Control* GetParentForm(void) const;
1026
1027         _SearchBarPresenter* __pSearchBarPresenter;
1028
1029         _Control* __pClippedGroupControl;
1030         _Edit* __pEdit;
1031         _Button* __pCancelButton;
1032         _Control* __pContainer;
1033         _Control* __pContentControl;
1034
1035         int __actionId;
1036         int __searchBarStyle;
1037
1038         bool __isButtonEnabled;
1039         bool __isUsableCancelButton;
1040         bool __isUserContainerBounds;
1041         bool __isCancelActionInProgress;
1042
1043         CoreKeypadAction __keypadAction;
1044
1045         Tizen::Graphics::Bitmap* __pBackgroundBitmap;
1046         Tizen::Graphics::Color __backgroundColor;
1047         Tizen::Graphics::Color __contentColor;
1048
1049         Tizen::Graphics::Color __color[SEARCHBAR_COLOR_MAX];
1050         Tizen::Graphics::Color __textColor[SEARCHBAR_COLOR_MAX];
1051         Tizen::Graphics::Color __buttonColor[SEARCHBAR_BUTTON_COLOR_MAX];
1052         Tizen::Graphics::Color __buttonTextColor[SEARCHBAR_BUTTON_COLOR_MAX];
1053
1054         Tizen::Graphics::Rectangle __contentAreaBounds;
1055
1056         _ActionEvent* __pActionEvent;
1057         _KeypadEvent* __pKeypadEvent;
1058         _TextBlockEvent* __pTextBlockEvent;
1059         _TextEvent* __pTextEvent;
1060         _SearchBarEvent* __pSearchBarEvent;
1061         _LanguageEvent* __pLanguageEvent;
1062         static const byte _SEARCH_CONTENT_DIM_OPACITY = 128; //50%  opacity
1063
1064 };  // _SearchBar
1065
1066 }}} // Tizen::Ui::Controls
1067
1068 #endif  // _FUI_CTRL_INTERNAL_SEARCH_BAR_H_