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 FUiCtrlSearchBar.h
20 * @brief This is the header file for the %SearchBar class.
22 * This header file contains the declarations of the %SearchBar class.
25 #ifndef _FUI_CTRL_SEARCH_BAR_H_
26 #define _FUI_CTRL_SEARCH_BAR_H_
28 #include <FBaseObject.h>
29 #include <FBaseTypes.h>
30 #include <FBaseString.h>
31 #include <FUiControl.h>
32 #include <FUiCtrlEditTypes.h>
33 #include <FUiCtrlIEditTextFilter.h>
34 #include <FUiIActionEventListener.h>
35 #include <FUiIKeypadEventListener.h>
36 #include <FUiILanguageEventListener.h>
37 #include <FUiITextBlockEventListener.h>
38 #include <FUiITextEventListener.h>
40 namespace Tizen { namespace Graphics
45 namespace Tizen { namespace Ui { namespace Controls
48 class ISearchBarEventListener;
51 * @enum SearchFieldStatus
53 * Defines the possible states of the search field of the search bar.
57 enum SearchFieldStatus
59 SEARCH_FIELD_STATUS_NORMAL, /**< The normal state */
60 SEARCH_FIELD_STATUS_HIGHLIGHTED, /**< The focus-highlighted state */
61 SEARCH_FIELD_STATUS_DISABLED /**< The disabled state */
65 * @enum SearchBarButtonStatus
67 * Defines the possible states of the search bar button.
71 enum SearchBarButtonStatus
73 SEARCH_BAR_BUTTON_STATUS_NORMAL = 0, /**< The normal status */
74 SEARCH_BAR_BUTTON_STATUS_PRESSED, /**< The selected status */
75 SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, /**< The highlighted status */
76 SEARCH_BAR_BUTTON_STATUS_DISABLED /**< The disabled status */
82 * Defines the possible modes of the search bar.
88 SEARCH_BAR_MODE_NORMAL, /**< The normal mode */
89 SEARCH_BAR_MODE_INPUT /**< The input mode */
94 * @brief This class is an implementation of a search bar.
98 * The %SearchBar class displays an editable search field for entering keywords and an optional button that is displayed in the
101 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_searchbar.htm">SearchBar</a>.
103 * The following example demonstrates how to use the %SearchBar class.
106 // Sample code for SearchBarSample.h
109 class SearchBarSample
110 : public Tizen::Ui::Controls::Form
111 , public Tizen::Ui::Controls::ISearchBarEventListener
112 , public Tizen::Ui::Controls::IListViewItemEventListener
113 , public Tizen::Ui::Controls::IListViewItemProvider
114 , public Tizen::Ui::ITextEventListener
117 SearchBarSample(void)
119 , __pSearchBarListView(null){}
121 bool Initialize(void);
122 virtual result OnInitializing(void);
124 // ISearchBarEventListener
125 virtual void OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode);
126 virtual void OnSearchBarContentAreaResized(Tizen::Ui::Controls::SearchBar& source, Tizen::Graphics::Dimension& size) {};
127 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
128 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source){};
130 // IListViewItemEventListener
131 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
132 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
133 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction);
135 //IListViewItemProvider
136 virtual Tizen::Ui::Controls::ListItemBase* CreateItem (int index, int itemWidth);
137 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
138 virtual int GetItemCount(void);
141 static const int ID_FORMAT_STRING = 500;
143 Tizen::Ui::Controls::SearchBar* __pSearchBar;
144 Tizen::Ui::Controls::ListView* __pSearchBarListView;
149 // Sample code for SearchBarSample.cpp
151 #include <FGraphics.h>
153 #include "SearchBarSample.h"
155 using namespace Tizen::Base;
156 using namespace Tizen::Base::Collection;
157 using namespace Tizen::Graphics;
158 using namespace Tizen::Ui;
159 using namespace Tizen::Ui::Controls;
162 SearchBarSample::Initialize(void)
164 Construct(FORM_STYLE_NORMAL);
169 SearchBarSample::OnInitializing(void)
171 result r = E_SUCCESS;
173 // Creates an instance of SearchBar
174 __pSearchBar = new SearchBar();
175 __pSearchBar->Construct(Rectangle(0, 0, GetClientAreaBounds().width, 110));
176 __pSearchBar->SetText(L"Click here! ");
177 __pSearchBar->AddSearchBarEventListener(*this);
178 __pSearchBar->AddTextEventListener(*this);
180 // Creates an instance of ListView
181 __pSearchBarListView = new ListView();
182 __pSearchBarListView->Construct(Rectangle(0, 110, GetClientAreaBounds().width, GetClientAreaBounds().height - 110), true, false);
183 __pSearchBarListView->SetItemProvider(*this);
184 __pSearchBarListView->AddListViewItemEventListener(*this);
185 __pSearchBarListView->SetTextOfEmptyList(L"No search result");
186 __pSearchBarListView->SetShowState(false);
187 __pSearchBar->SetContent(__pSearchBarListView);
189 // Adds controls to the form
190 AddControl(*__pSearchBar);
195 // ISearchBarEventListener implementation
197 SearchBarSample::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
199 Rectangle clientRect = GetClientAreaBounds();
200 __pSearchBar->SetText(L"");
202 if(mode == SEARCH_BAR_MODE_INPUT)
204 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
205 __pSearchBar->SetContentAreaSize(Dimension(clientRect.width, clientRect.height));
206 __pSearchBarListView->SetSize(Dimension(clientRect.width, clientRect.height));
207 __pSearchBarListView->UpdateList();
211 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
212 __pSearchBarListView->UpdateList();
213 __pSearchBarListView->SetShowState(false);
214 __pSearchBar->SetText(L"Click here!");
220 SearchBarSample::OnTextValueChanged(const Tizen::Ui::Control& source)
222 if(__pSearchBarListView)
224 __pSearchBarListView->UpdateList();
225 __pSearchBarListView->ScrollToItem(0);
226 __pSearchBarListView->SetShowState(true);
231 // IListViewItemEventListener implementation
233 SearchBarSample::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
239 SearchBarSample::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
245 SearchBarSample::OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction)
250 //IListViewItemProvider
252 SearchBarSample::CreateItem (int index, int itemWidth)
254 // Creates an instance of CustomItem
255 CustomItem* pItem = new CustomItem();
256 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
258 // Gets texts of the search bar
259 String inputText = null;
260 inputText = __pSearchBar->GetText();
262 if(inputText.CompareTo(L"a") == 0 || inputText.CompareTo(L"A") == 0 )
268 pItem->Construct(Dimension(itemWidth,100), style);
269 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"ajo", true);
274 pItem->Construct(Dimension(itemWidth,100), style);
275 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"aeun", true);
280 pItem->Construct(Dimension(itemWidth,100), style);
281 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"abee", true);
288 else if (inputText.CompareTo(L"b") == 0 || inputText.CompareTo(L"B") == 0)
294 pItem->Construct(Dimension(itemWidth,100), style);
295 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bonge", true);
300 pItem->Construct(Dimension(itemWidth,100), style);
301 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bnpyo", true);
306 pItem->Construct(Dimension(itemWidth,100), style);
307 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bkueon", true);
316 pItem->Construct(Dimension(itemWidth,100), style);
317 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"default", true);
324 SearchBarSample::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
332 SearchBarSample::GetItemCount(void)
340 class _OSP_EXPORT_ SearchBar
341 : public Tizen::Ui::Control
345 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
352 * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
356 virtual ~SearchBar(void);
359 * Initializes this instance of the %SearchBar control with the specified parameters.
363 * @return An error code
364 * @param[in] rect An instance of the Graphics::Rectangle class @n
365 * This instance represents the x and y coordinates of the top-left corner of the created window along with
366 * the width and height of the control.
367 * @param[in] searchBarButton Set to @c true to display the search bar button, @n
369 * @param[in] keypadAction The keypad action
370 * @exception E_SUCCESS The method is successful.
371 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
372 * the action ID of the specified item must be a positive integer.
373 * @exception E_SYSTEM A system error has occurred.
374 * @remarks It is recommended that %SearchBar should be placed at the top-left corner of Form's client area.
375 * @remarks By default, a "Cancel" button is displayed if @c searchBarButton is set to @c true. When the user presses the cancel button,
376 * the %SearchBar control returns to SEARCH_BAR_MODE_NORMAL automatically.
378 result Construct(const Tizen::Graphics::Rectangle& rect, bool searchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH);
381 * Initializes this instance of the %SearchBar control with the specified parameters.
385 * @return An error code
386 * @param[in] rect An instance of the Graphics::FloatRectangle class @n
387 * This instance represents the x and y coordinates of the top-left corner of the created window along with
388 * the width and height of the control.
389 * @param[in] searchBarButton Set to @c true to display the search bar button, @n
391 * @param[in] keypadAction The keypad action
392 * @exception E_SUCCESS The method is successful.
393 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
394 * the action ID of the specified item must be a positive integer.
395 * @exception E_SYSTEM A system error has occurred.
396 * @remarks It is recommended that %SearchBar should be placed at the top-left corner of Form's client area.
397 * @remarks By default, a "Cancel" button is displayed if @c searchBarButton is set to @c true. When the user presses the cancel button,
398 * the %SearchBar control returns to SEARCH_BAR_MODE_NORMAL automatically.
400 result Construct(const Tizen::Graphics::FloatRectangle& rect, bool searchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH);
403 * Gets the content of Control.
407 * @return The control that is displayed in the content area of %SearchBar in the SEARCH_BAR_MODE_INPUT mode, @n
408 * else @c null if an error occurs
409 * @exception E_SUCCESS The method is successful.
410 * @remarks The specific error code can be accessed using the GetLastResult() method.
412 Tizen::Ui::Control* GetContent(void) const;
415 * Sets the content control.
418 * @brief <i> [Compatibility] </i>
422 * @compatibility This method has compatibility issues with OSP compatible applications. @n
423 * For more information, see @ref CompSetContentPage "here"
425 * @return An error code
426 * @param[in] pContent The control to display in the content area of the search bar
427 * @exception E_SUCCESS The method is successful.
428 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
429 * The following controls cannot be set as the content: @n
430 * @li All classes derived from the Window class
431 * @li All picker classes (For example, DateTimePicker)
435 * @exception E_SYSTEM A system error has occurred.
436 * @remarks The specified content control is displayed when the mode of the %SearchBar control is changed to SEARCH_BAR_MODE_INPUT.
437 * @see GetContentAreaSize()
438 * @see AddSearchBarEventListener()
439 * @see ISearchBarEventListener
441 result SetContent(const Tizen::Ui::Control* pContent);
443 * @page CompSetContentPage Compatibility for SetContent()
444 * @section CompSetContentPage IssueSection Issues
445 * Implementing this method in OSP compatible applications has the following issue: @n
446 * SetContent() method passes the ownership of Content control to SearchBar in OSP,
447 * whereas the Content control ownership remains with the caller in Tizen.
449 * @section CompSetContentPage SolutionSection Resolutions
450 * In Tizen, the caller should delete the previous Content control, if this method is called more than once.
454 * Updates the content area of the %SearchBar control.
458 * @return An error code
459 * @param[in] invalidate Set to @c true to perform invalidate on the content area, @n
461 * @exception E_SUCCESS The method is successful.
462 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
463 * The current mode of %SearchBar prohibits the execution of the method.
464 * @exception E_SYSTEM A system error has occurred.
465 * @remarks The method performs Invalidate() on the content area.
467 result UpdateContentArea(bool invalidate = true);
470 * Sets the visibility state of the content area.
474 * @return An error code
475 * @param[in] visible Set to @c true to make the content area visible, @n
477 * @exception E_SUCCESS The method is successful.
478 * @exception E_SYSTEM A system error has occurred.
479 * @see IsContentAreaVisible()
481 result SetContentAreaVisible(bool visible);
484 * Checks whether the content area is visible.
488 * @return @c true if the content area is visible, @n
490 * @exception E_SUCCESS The method is successful.
491 * @see SetContentAreaVisible()
493 bool IsContentAreaVisible(void) const;
496 * Sets the size of the content area of the %SearchBar control.
500 * @return An error code
501 * @param[in] size The size of the content area
502 * @exception E_SUCCESS The method is successful.
503 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
504 * The width and height of @c size must be greater than or equal to @c 0.
505 * @remarks The content area must be resized when the orientation of the form is changed once the size of the content area is changed.
506 * @see GetContentAreaSize()
508 result SetContentAreaSize(const Tizen::Graphics::Dimension& size);
511 * Sets the size of the content area of the %SearchBar control.
515 * @return An error code
516 * @param[in] size The size of the content area
517 * @exception E_SUCCESS The method is successful.
518 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
519 * The width and height of @c size must be greater than or equal to @c 0.
520 * @remarks The content area must be resized when the orientation of the form is changed once the size of the content area is changed.
521 * @see GetContentAreaSizeF()
523 result SetContentAreaSize(const Tizen::Graphics::FloatDimension& size);
526 * Gets the size of the content area of the %SearchBar control.
530 * @return The size of the content area
531 * @remarks The content area is the area where the 'content' of the %SearchBar control is displayed. The size of the content areas can
532 * be changed at runtime.
533 * @see AddSearchBarEventListener()
534 * @see ISearchBarEventListener
536 Tizen::Graphics::Dimension GetContentAreaSize(void) const;
539 * Gets the size of the content area of the %SearchBar control.
543 * @return The size of the content area
544 * @remarks The content area is the area where the 'content' of the %SearchBar control is displayed. The size of the content areas can
545 * be changed at runtime.
546 * @see AddSearchBarEventListener()
547 * @see ISearchBarEventListener
549 Tizen::Graphics::FloatDimension GetContentAreaSizeF(void) const;
553 * Gets the search bar mode.
557 * @return The search bar mode
558 * @exception E_SUCCESS The method is successful.
559 * @exception E_SYSTEM A system error has occurred.
560 * @remarks The specific error code can be accessed using the GetLastResult() method.
563 SearchBarMode GetMode(void) const;
566 * Checks whether the search bar mode is locked.
570 * @return @c true if the mode is locked, @n
572 * @exception E_SUCCESS The method is successful.
573 * @exception E_SYSTEM A system error has occurred.
574 * @remarks The specific error code can be accessed using the GetLastResult() method.
577 bool IsModeLocked(void) const;
580 * Sets the search bar mode.
584 * @return An error code
585 * @param[in] mode The search bar mode
586 * @exception E_SUCCESS The method is successful.
587 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or @n
588 * the mode is locked.
589 * @exception E_SYSTEM A system error has occurred.
593 result SetMode(SearchBarMode mode);
596 * Sets the lock status of the search bar mode.
600 * @return An error code
601 * @param[in] modeLocked Set to @c true to lock the search bar mode, @n
603 * @exception E_SUCCESS The method is successful.
604 * @exception E_SYSTEM A system error has occurred.
607 result SetModeLocked(bool modeLocked);
610 * Gets the action ID of the search bar button.
614 * @return The action ID, @n
615 * else @c -1 if an error occurs
616 * @exception E_SUCCESS The method is successful.
617 * @exception E_SYSTEM A system error has occurred.
618 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
619 * By default, the method returns @c -1 if no user defined search bar button is set.
621 int GetButtonActionId(void) const;
624 * Gets the color of the search bar button for the specified state.
628 * @return The color of the search bar button, @n
629 * else RGBA(0,0,0,0) if an error occurs
630 * @param[in] status The status of the search bar button
631 * @exception E_SUCCESS The method is successful.
632 * @exception E_SYSTEM A system error has occurred.
633 * @remarks The specific error code can be accessed using the GetLastResult() method.
634 * @see SetButtonColor()
636 Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const;
639 * Gets the text color of the search bar button for the specified state.
643 * @return The text color of the search bar button, @n
644 * else RGBA(0,0,0,0) if an error occurs
645 * @param[in] status The status of the search bar button
646 * @exception E_SUCCESS The method is successful.
647 * @exception E_SYSTEM A system error has occurred.
648 * @remarks The specific error code can be accessed using the GetLastResult() method.
650 Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const;
653 * Gets the state of the search bar button.
657 * @return The state of the search bar button
658 * @exception E_SUCCESS The method is successful.
659 * @exception E_SYSTEM A system error has occurred.
660 * @remarks The specific error code can be accessed using the GetLastResult() method.
662 SearchBarButtonStatus GetButtonStatus(void) const;
665 * Sets the user defined search bar button.
669 * @return An error code
670 * @param[in] text The button text
671 * @param[in] actionId The button action ID
672 * @exception E_SUCCESS The method is successful.
673 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
674 * the specified @c actionId must be greater than or equal to @c 0.
675 * @exception E_SYSTEM A system error has occurred.
677 result SetButton(const Tizen::Base::String& text, int actionId);
680 * Sets the enabled status of the search bar button.
684 * @return An error code
685 * @param[in] enabled Set to @c true to enable the search bar button, @n
687 * @exception E_SUCCESS The method is successful.
688 * @exception E_SYSTEM A system error has occurred.
690 result SetButtonEnabled(bool enabled);
693 * Sets the color of the search bar button for the specified state.
697 * @return An error code
698 * @param[in] status The button status
699 * @param[in] color The button color to set
700 * @exception E_SUCCESS The method is successful.
701 * @exception E_SYSTEM A system error has occurred.
702 * @see GetButtonColor()
704 result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
707 * Sets the text color of the button of the %SearchBar control for the specified state.
711 * @return An error code
712 * @param[in] status The button status
713 * @param[in] color The button text color to set
714 * @exception E_SUCCESS The method is successful.
715 * @exception E_SYSTEM A system error has occurred.
717 result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
720 * Appends the specified character at the end of the text.
724 * @return An error code
725 * @param[in] character The character to add
726 * @exception E_SUCCESS The method is successful.
727 * @exception E_SYSTEM A system error has occurred.
728 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
729 * To display the changes, the control must be drawn again.
731 result AppendCharacter(const Tizen::Base::Character& character);
734 * Appends the specified text at the end of the existing text.
738 * @return An error code
739 * @param[in] text The text to append
740 * @exception E_SUCCESS The method is successful.
741 * @exception E_SYSTEM A system error has occurred.
742 * @remarks To denote the end of a line use '\\n'. @n
743 * The method modifies the text buffer that is managed by the %SearchBar control. @n
744 * To display the changes, the control must be drawn again.
746 result AppendText(const Tizen::Base::String& text);
750 * Sets the text to be displayed.
754 * @return An error code
755 * @param[in] text The text to display
756 * @exception E_SUCCESS The method is successful.
757 * @exception E_SYSTEM A system error has occurred.
758 * @remarks To denote the end of a line use '\\n'. @n
759 * The method modifies the text buffer that is managed by the %SearchBar control. @n
760 * To display the changes, the control must be drawn again.
762 result SetText(const Tizen::Base::String& text);
765 * Inserts the character at the specified index.
769 * @return An error code
770 * @param[in] index The position to insert the character
771 * @param[in] character The character to insert
772 * @exception E_SUCCESS The method is successful.
773 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
774 * The specified @c index is greater than the number of elements or less than @c 0.
775 * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation.
776 * @exception E_SYSTEM A system error has occurred.
777 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
778 * To display the changes, the control must be drawn again.
780 result InsertCharacterAt(int index, const Tizen::Base::Character& character);
783 * Inserts the specified text at the specified index.
787 * @return An error code
788 * @param[in] index The position at which to insert
789 * @param[in] text The text to insert
790 * @exception E_SUCCESS The method is successful.
791 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
792 * The specified @c index is greater than the number of elements or less than @c 0.
793 * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation.
794 * @exception E_SYSTEM A system error has occurred.
795 * @remarks The method modifies the text buffer that is managed by the %SearchBar control.
796 * To display the changes, the control must be drawn again.
798 result InsertTextAt(int index, const Tizen::Base::String& text);
801 * Deletes the character at the specified position.
805 * @return An error code
806 * @param[in] index The index
807 * @exception E_SUCCESS The method is successful.
808 * @exception E_INVALID_ARG The specified @c index is negative.
809 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
810 * The specified @c index is greater than the number of elements or less than @c 0.
811 * @exception E_SYSTEM A system error has occurred.
812 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
813 * To display the changes, the control must be drawn again.
815 result DeleteCharacterAt(int index);
818 * Clears the text that is displayed by the %SearchBar control.
822 * @return An error code
823 * @exception E_SUCCESS The method is successful.
824 * @exception E_SYSTEM A system error has occurred.
825 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
826 * To display the changes, the control must be drawn again.
831 * Gets the length of the text that is displayed by the %SearchBar control.
835 * @return The length of the text, @n
836 * else @c -1 if an error occurs
837 * @exception E_SUCCESS The method is successful.
838 * @exception E_SYSTEM A system error has occurred.
839 * @remarks The specific error code can be accessed using the GetLastResult() method.
841 int GetTextLength(void) const;
844 * Gets the text that is displayed by the %SearchBar control.
848 * @return The text displayed by the %SearchBar control, @n
849 * else an empty string if an error occurs
850 * @exception E_SUCCESS The method is successful.
851 * @exception E_SYSTEM A system error has occurred.
852 * @remarks The specific error code can be accessed using the GetLastResult() method.
855 Tizen::Base::String GetText(void) const;
858 * Gets a portion of text that is displayed by the %SearchBar control.
862 * @return The specified portion of the text, @n
863 * else an empty string if an error occurs
864 * @param[in] start The starting index of range
865 * @param[in] end The last index of range
866 * @exception E_SUCCESS The method is successful.
867 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n
868 * either the @c start or @c end parameter is greater than the number of elements or less than @c 0.
869 * @exception E_SYSTEM A system error has occurred.
870 * @remarks The specific error code can be accessed using the GetLastResult() method.
873 Tizen::Base::String GetText(int start, int end) const;
876 * Gets the limit of the length of the text.
880 * @return The limit of the text length, @n
881 * else @c -1 if an error occurs
882 * @exception E_SUCCESS The method is successful.
883 * @exception E_SYSTEM A system error has occurred.
884 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
885 * The default limit length is @c 500.
886 * @see SetLimitLength()
888 int GetLimitLength(void) const;
891 * Sets the limit of the length of the text.
895 * @return An error code
896 * @param[in] limitLength The limit text length to set
897 * @exception E_SUCCESS The method is successful.
898 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
899 * the specified limit length cannot be @c 0 or negative.
900 * @exception E_SYSTEM A system error has occurred.
901 * @see GetLimitLength()
903 result SetLimitLength(int limitLength);
906 * Shows the keypad associated with the %SearchBar control.
910 * @return An error code
911 * @exception E_SUCCESS The method is successful.
912 * @exception E_INVALID_STATE This instance is in an invalid state.
913 * @exception E_SYSTEM A system error has occurred.
916 result ShowKeypad(void) const;
919 * Hides the keypad associated with the %SearchBar control.
923 * @return An error code
924 * @exception E_SUCCESS The method is successful.
925 * @exception E_SYSTEM A system error has occurred.
928 result HideKeypad(void) const;
931 * Gets the text size of the search field.
935 * @return The size of the text, @n
936 * else @c -1 if an error occurs
937 * @exception E_SUCCESS The method is successful.
938 * @exception E_SYSTEM A system error has occurred.
939 * @remarks The specific error code can be accessed using the GetLastResult() method.
940 * @see SetSearchFieldTextSize()
942 int GetSearchFieldTextSize(void) const;
945 * Gets the text size of the search field.
949 * @return The size of the text, @n
950 * else @c -1 if an error occurs
951 * @exception E_SUCCESS The method is successful.
952 * @exception E_SYSTEM A system error has occurred.
953 * @remarks The specific error code can be accessed using the GetLastResult() method.
954 * @see SetSearchFieldTextSize()
956 float GetSearchFieldTextSizeF(void) const;
959 * Sets the text size of the text field of the %SearchBar control.
963 * @return An error code
964 * @param[in] size The text size
965 * @exception E_SUCCESS The method is successful.
966 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
967 * the specified @c size cannot be a negative value.
968 * @exception E_SYSTEM A system error has occurred.
969 * @see GetSearchFieldTextSize()
971 result SetSearchFieldTextSize(int size);
974 * Sets the text size of the text field of the %SearchBar control.
978 * @return An error code
979 * @param[in] size The text size
980 * @exception E_SUCCESS The method is successful.
981 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
982 * the specified @c size cannot be a negative value.
983 * @exception E_SYSTEM A system error has occurred.
984 * @see GetSearchFieldTextSizeF()
986 result SetSearchFieldTextSize(float size);
989 * Gets the start and the end index of the currently selected text block.
993 * @return An error code
994 * @param[out] start The start index of the text block
995 * @param[out] end The end index of the text block
996 * @exception E_SUCCESS The method is successful.
997 * @exception E_SYSTEM A system error has occurred.
998 * @remarks The method returns @c start = 0 and @c end = 0 if no text block is selected.
999 * @see ReleaseBlock()
1000 * @see SetBlockRange()
1002 result GetBlockRange(int& start, int& end) const;
1005 * Releases the selection of the current text block.
1009 * @return An error code
1010 * @exception E_SUCCESS The method is successful.
1011 * @exception E_SYSTEM A system error has occurred.
1012 * @see GetBlockRange()
1013 * @see SetBlockRange()
1015 result ReleaseBlock(void);
1018 * Sets the block range for the text.
1022 * @return An error code
1023 * @param[in] start The start index of the text block
1024 * @param[in] end The end index of the text block
1025 * @exception E_SUCCESS The method is successful.
1026 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n
1027 * either the @c start or @c end parameter is greater than the number of elements or less than @c 0.
1028 * @exception E_SYSTEM A system error has occurred.
1029 * @see ReleaseBlock()
1030 * @see GetBlockRange()
1032 result SetBlockRange(int start, int end);
1035 * Removes the text of the selected text block.
1039 * @return An error code
1040 * @exception E_SUCCESS The method is successful.
1041 * @exception E_SYSTEM A system error has occurred.
1043 result RemoveTextBlock(void);
1046 * Gets the color of the %SearchBar control for the specified status.
1050 * @return The color of the %SearchBar control, @n
1051 * else RGBA(0,0,0,0) if an error occurs
1052 * @exception E_SUCCESS The method is successful.
1053 * @exception E_SYSTEM A system error has occurred.
1054 * @remarks The specific error code can be accessed using the GetLastResult() method.
1057 Tizen::Graphics::Color GetColor(void) const;
1060 * Gets the color of the search field for the specified status.
1064 * @return The color, @n
1065 * else RGBA(0,0,0,0) if an error occurs
1066 * @param[in] status The search field status
1067 * @exception E_SUCCESS The method is successful.
1068 * @exception E_SYSTEM A system error has occurred.
1069 * @remarks The specific error code can be accessed using the GetLastResult() method.
1070 * @see SetSearchFieldColor()
1072 Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const;
1075 * Gets the text color of the search field for the specified status.
1079 * @return The text color, @n
1080 * else RGBA(0,0,0,0) if an error occurs
1081 * @param[in] status The search field status
1082 * @exception E_SUCCESS The method is successful.
1083 * @exception E_SYSTEM A system error has occurred.
1084 * @remarks The specific error code can be accessed using the GetLastResult() method.
1085 * @see SetSearchFieldTextColor()
1087 Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const;
1090 * Sets the background bitmap of the %SearchBar control.
1094 * @return An error code
1095 * @param[in] bitmap The background bitmap
1096 * @exception E_SUCCESS The method is successful.
1097 * @exception E_SYSTEM A system error has occurred.
1099 result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap);
1102 * Sets the color of the search bar.
1106 * @return An error code
1107 * @param[in] color The color
1108 * @exception E_SUCCESS The method is successful.
1109 * @exception E_SYSTEM A system error has occurred.
1112 result SetColor(const Tizen::Graphics::Color& color);
1115 * Sets the color of the search field for the specified status.
1119 * @return An error code
1120 * @param[in] status The state of the search field
1121 * @param[in] color The text color
1122 * @exception E_SUCCESS The method is successful.
1123 * @exception E_SYSTEM A system error has occurred.
1124 * @see GetSearchFieldColor()
1126 result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
1129 * Sets the text color of the search field for the specified status.
1133 * @return An error code
1134 * @param[in] status The state of the search field
1135 * @param[in] color The text color
1136 * @exception E_SUCCESS The method is successful.
1137 * @exception E_SYSTEM A system error has occurred.
1138 * @see GetSearchFieldTextColor()
1140 result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
1143 * Gets the guide text.
1147 * @return The guide text, @n
1148 * else an empty string if an error occurs
1149 * @exception E_SUCCESS The method is successful.
1150 * @exception E_SYSTEM A system error has occurred.
1151 * @remarks The specific error code can be accessed using the GetLastResult() method.
1152 * @see GetGuideText()
1154 Tizen::Base::String GetGuideText(void) const;
1157 * Sets the guide text. @n
1158 * This text is displayed when there is no text in the %SearchBar control.
1162 * @return An error code
1163 * @param[in] guideText The guide text
1164 * @exception E_SUCCESS The method is successful.
1165 * @exception E_SYSTEM A system error has occurred.
1166 * @see GetGuideText()
1168 result SetGuideText(const Tizen::Base::String& guideText);
1171 * Gets the text color of the guide text.
1175 * @return The text color of the guide text, @n
1176 * else RGBA(0,0,0,0) if an error occurs
1177 * @exception E_SUCCESS The method is successful.
1178 * @exception E_SYSTEM A system error has occurred.
1179 * @remarks The specific error code can be accessed using the GetLastResult() method.
1180 * @see SetGuideTextColor()
1182 Tizen::Graphics::Color GetGuideTextColor(void) const;
1185 * Sets the text color of the guide text.
1189 * @return An error code
1190 * @param[in] color The guide text color
1191 * @exception E_SUCCESS The method is successful.
1192 * @exception E_SYSTEM A system error has occurred.
1193 * @see GetGuideTextColor()
1195 result SetGuideTextColor(const Tizen::Graphics::Color& color);
1199 * Gets the current cursor position index.
1203 * @return The cursor position, @n
1204 * else @c -1 if an error occurs
1205 * @exception E_SUCCESS The method is successful.
1206 * @exception E_SYSTEM A system error has occurred.
1207 * @remarks The specific error code can be accessed using the GetLastResult() method.
1208 * @see SetCursorPosition()
1210 int GetCursorPosition(void) const;
1213 * Sets the cursor at the specified index.
1217 * @return An error code
1218 * @param[in] index The cursor index
1219 * @exception E_SUCCESS The method is successful.
1220 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
1221 * The specified @c index is greater than the number of elements or less than @c 0.
1222 * @exception E_SYSTEM A system error has occurred.
1223 * @see GetCursorPosition()
1225 result SetCursorPosition(int index);
1228 * Checks whether the lowercase mode is enabled.
1232 * @return @c true if the lowercase mode is enabled, @n
1234 * @exception E_SUCCESS The method is successful.
1235 * @exception E_SYSTEM A system error has occurred.
1236 * @remarks The specific error code can be accessed using the GetLastResult() method.
1237 * @see SetLowerCaseModeEnabled()
1239 bool IsLowerCaseModeEnabled(void) const;
1242 * Enables or disables the lowercase mode.
1246 * @param[in] enable Set to @c true to enable the lowercase mode, @n
1248 * @exception E_SUCCESS The method is successful.
1249 * @exception E_SYSTEM A system error has occurred.
1250 * @see IsLowerCaseModeEnabled()
1252 void SetLowerCaseModeEnabled(bool enable);
1256 * Gets the ellipsis position.
1260 * @return The ellipsis position
1261 * @exception E_SUCCESS The method is successful.
1262 * @exception E_SYSTEM A system error has occurred.
1263 * @remarks The specific error code can be accessed using the GetLastResult() method.
1264 * @see SetEllipsisPosition()
1266 EllipsisPosition GetEllipsisPosition(void) const;
1269 * Sets the ellipsis position.
1273 * @return An error code
1274 * @param[in] position The ellipsis position
1275 * @exception E_SUCCESS The method is successful.
1276 * @exception E_SYSTEM A system error has occurred.
1277 * @see GetEllipsisPosition()
1279 result SetEllipsisPosition(EllipsisPosition position);
1282 * Sets the input language.
1286 * @return An error code
1287 * @param[in] languageCode The language to set
1288 * @exception E_SUCCESS The method is successful.
1289 * @exception E_OUT_OF_MEMORY The memory is insufficient.
1290 * @remarks The application can set the language of the current keypad that is associated with the current %SearchBar. @n
1291 * This method only works if the language to set is supported by the current preloaded keypad.
1294 result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode);
1297 * Gets the current input language.
1301 * @return An error code
1302 * @param[out] language The current input language
1303 * @exception E_SUCCESS The method is successful.
1304 * @remarks The application can get the current language of the keypad that is associated with the current %SearchBar.
1307 result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const;
1310 * Gets the keypad action type.
1314 * @return The keypad action
1315 * @exception E_SUCCESS The method is successful.
1316 * @exception E_SYSTEM A system error has occurred.
1317 * @remarks The specific error code can be accessed using the GetLastResult() method.
1319 KeypadAction GetKeypadAction(void) const;
1322 * Checks whether the text prediction is enabled.
1325 * @return @c true if the text prediction is enabled, @n
1327 * @exception E_SUCCESS The method is successful.
1328 * @see SetTextPredictionEnabled()
1330 bool IsTextPredictionEnabled(void) const;
1333 * Enables or disables the text prediction.
1336 * @param[in] enable Set to @c true to enable the text prediction, @n
1338 * @return An error code
1339 * @exception E_SUCCESS The method is successful.
1340 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
1341 * @see IsTextPredictionEnabled()
1343 result SetTextPredictionEnabled(bool enable);
1346 * Adds the specified action event listener. @n
1347 * The added listener is notified when the user clicks the search bar button.
1351 * @param[in] listener The event listener to add
1352 * @see RemoveActionEventListener()
1354 void AddActionEventListener(Tizen::Ui::IActionEventListener& listener);
1357 * Removes the specified action event listener. @n
1358 * The removed listener cannot listen to events when they are fired.
1362 * @param[in] listener The event listener to remove
1363 * @see AddActionEventListener()
1365 void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
1368 * Adds the specified text event listener. @n
1369 * The added listener can listen to events on the context of the specified event dispatcher when they are fired.
1373 * @param[in] listener The event listener to add
1374 * @remarks The added listener is notified when: @n
1375 * @li The user presses a key on the software keypad.
1376 * @li The user selects a word in the candidate list.
1377 * @li The user pastes a text.
1378 * @see RemoveTextEventListener()
1380 void AddTextEventListener(Tizen::Ui::ITextEventListener& listener);
1383 * Removes the specified text event listener. @n
1384 * The removed listener cannot listen to events when they are fired.
1388 * @param[in] listener The event listener to remove
1389 * @see AddTextEventListener()
1391 void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener);
1394 * Adds the specified search bar event listener. @n
1395 * The added listener can listen to events on the context of the specified event dispatcher when they are fired.
1399 * @param[in] listener The event listener to add
1400 * @remarks The added listener is notified when: @n
1401 * @li The user presses a key on the software keypad.
1402 * @li The user selects a word in the candidate list.
1403 * @li The user pastes a text.
1404 * @see AddSearchBarEventListener()
1406 void AddSearchBarEventListener(ISearchBarEventListener& listener);
1409 * Removes the specified search bar event listener. @n
1410 * The removed listener cannot listen to events when they are fired.
1414 * @param[in] listener The event listener to remove
1415 * @see RemoveTextEventListener()
1417 void RemoveSearchBarEventListener(ISearchBarEventListener& listener);
1420 * Adds the specified text block event listener.
1424 * @param[in] listener The event listener to add
1425 * @remarks Programmatically, modification of the text selection does not cause the text block selection event to fire.
1426 * @see RemoveTextBlockEventListener()
1428 void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
1431 * Removes the specified text block event listener. @n
1432 * The removed listener cannot listen to events when they are fired.
1436 * @param[in] listener The event listener to remove
1437 * @see AddTextBlockEventListener()
1439 void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
1442 * Adds the specified keypad event listener. @n
1443 * The added listener is notified when the keypad associated with this text editor is opened or closed.
1447 * @param[in] listener The event listener to add
1448 * @see RemoveKeypadEventListener()
1450 void AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener);
1453 * Removes the specified keypad event listener. @n
1454 * The removed listener cannot listen to events when they are fired.
1458 * @param[in] listener The event listener to remove
1459 * @see AddKeypadEventListener()
1461 void RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener);
1464 * Adds a listener instance for language events. @n
1465 * The added listener is notified when the input language is changed.
1469 * @param[in] listener The listener to add
1470 * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener.
1471 * @see RemoveLanguageEventListener()
1474 void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener);
1477 * Removes the specified listener instance. @n
1478 * The removed listener cannot listen to events when they are fired.
1482 * @param[in] listener The listener to remove
1483 * @see AddLanguageEventListener()
1486 void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener);
1489 * Sets the text filter.
1493 * @param[in] pFilter The filter
1494 * @remarks The %SearchBar control checks with the registered filter to decide whether the user-entered text should be replaced.
1496 void SetEditTextFilter(IEditTextFilter* pFilter);
1499 * Sends opaque command to the input method.
1503 * @param[in] command The opaque command
1504 * @remarks This method can be used to provide domain-specific features that are only known between certain input methods and their clients.
1505 * This method may not work, depending on the active Input Method.
1507 void SendOpaqueCommand (const Tizen::Base::String& command);
1510 friend class _SearchBarImpl;
1514 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
1516 SearchBar(const SearchBar& rhs);
1519 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
1521 SearchBar& operator =(const SearchBar& rhs);
1525 }}} // Tizen::Ui::Controls
1527 #endif // _FUI_CTRL_SEARCH_BAR_H_