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 <FUiIActionEventListener.h>
34 #include <FUiIKeypadEventListener.h>
35 #include <FUiILanguageEventListener.h>
36 #include <FUiITextBlockEventListener.h>
37 #include <FUiITextEventListener.h>
39 namespace Tizen { namespace Graphics
44 namespace Tizen { namespace Ui { namespace Controls
47 class ISearchBarEventListener;
50 * @enum SearchFieldStatus
52 * Defines the possible states of the search field of the search bar.
56 enum SearchFieldStatus
58 SEARCH_FIELD_STATUS_NORMAL, /**< The normal state */
59 SEARCH_FIELD_STATUS_HIGHLIGHTED, /**< The focus-highlighted state */
60 SEARCH_FIELD_STATUS_DISABLED /**< The disabled state */
64 * @enum SearchBarButtonStatus
66 * Defines the possible states of the search bar button.
70 enum SearchBarButtonStatus
72 SEARCH_BAR_BUTTON_STATUS_NORMAL = 0, /**< The normal status */
73 SEARCH_BAR_BUTTON_STATUS_PRESSED, /**< The selected status */
74 SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, /**< The highlighted status */
75 SEARCH_BAR_BUTTON_STATUS_DISABLED /**< The disabled status */
81 * Defines the possible modes of the search bar.
87 SEARCH_BAR_MODE_NORMAL, /**< The normal mode */
88 SEARCH_BAR_MODE_INPUT /**< The input mode */
93 * @brief This class is an implementation of a search bar.
97 * The %SearchBar class displays an editable search field for entering keywords and an optional button that is displayed in the
100 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_searchbar.htm">SearchBar</a>.
102 * The following example demonstrates how to use the %SearchBar class.
105 // Sample code for SearchBarSample.h
108 class SearchBarSample
109 : public Tizen::Ui::Controls::Form
110 , public Tizen::Ui::Controls::ISearchBarEventListener
111 , public Tizen::Ui::Controls::IListViewItemEventListener
112 , public Tizen::Ui::Controls::IListViewItemProvider
113 , public Tizen::Ui::ITextEventListener
116 SearchBarSample(void)
118 , __pSearchBarListView(null){}
120 bool Initialize(void);
121 virtual result OnInitializing(void);
123 // ISearchBarEventListener
124 virtual void OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode);
125 virtual void OnSearchBarContentAreaResized(Tizen::Ui::Controls::SearchBar& source, Tizen::Graphics::Dimension& size) {};
126 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
127 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source){};
129 // IListViewItemEventListener
130 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
131 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
132 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction);
134 //IListViewItemProvider
135 virtual Tizen::Ui::Controls::ListItemBase* CreateItem (int index, int itemWidth);
136 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
137 virtual int GetItemCount(void);
140 static const int ID_FORMAT_STRING = 500;
142 Tizen::Ui::Controls::SearchBar* __pSearchBar;
143 Tizen::Ui::Controls::ListView* __pSearchBarListView;
148 // Sample code for SearchBarSample.cpp
150 #include <FGraphics.h>
152 #include "SearchBarSample.h"
154 using namespace Tizen::Base;
155 using namespace Tizen::Base::Collection;
156 using namespace Tizen::Graphics;
157 using namespace Tizen::Ui;
158 using namespace Tizen::Ui::Controls;
161 SearchBarSample::Initialize(void)
163 Construct(FORM_STYLE_NORMAL);
168 SearchBarSample::OnInitializing(void)
170 result r = E_SUCCESS;
172 // Creates an instance of SearchBar
173 __pSearchBar = new SearchBar();
174 __pSearchBar->Construct(Rectangle(0, 0, GetClientAreaBounds().width, 110));
175 __pSearchBar->SetText(L"Click here! ");
176 __pSearchBar->AddSearchBarEventListener(*this);
177 __pSearchBar->AddTextEventListener(*this);
179 // Creates an instance of ListView
180 __pSearchBarListView = new ListView();
181 __pSearchBarListView->Construct(Rectangle(0, 110, GetClientAreaBounds().width, GetClientAreaBounds().height - 110), true, false);
182 __pSearchBarListView->SetItemProvider(*this);
183 __pSearchBarListView->AddListViewItemEventListener(*this);
184 __pSearchBarListView->SetTextOfEmptyList(L"No search result");
185 __pSearchBarListView->SetShowState(false);
186 __pSearchBar->SetContent(__pSearchBarListView);
188 // Adds controls to the form
189 AddControl(*__pSearchBar);
194 // ISearchBarEventListener implementation
196 SearchBarSample::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
198 Rectangle clientRect = GetClientAreaBounds();
199 __pSearchBar->SetText(L"");
201 if(mode == SEARCH_BAR_MODE_INPUT)
203 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
204 __pSearchBar->SetContentAreaSize(Dimension(clientRect.width, clientRect.height));
205 __pSearchBarListView->SetSize(Dimension(clientRect.width, clientRect.height));
206 __pSearchBarListView->UpdateList();
210 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
211 __pSearchBarListView->UpdateList();
212 __pSearchBarListView->SetShowState(false);
213 __pSearchBar->SetText(L"Click here!");
219 SearchBarSample::OnTextValueChanged(const Tizen::Ui::Control& source)
221 if(__pSearchBarListView)
223 __pSearchBarListView->UpdateList();
224 __pSearchBarListView->ScrollToItem(0);
225 __pSearchBarListView->SetShowState(true);
230 // IListViewItemEventListener implementation
232 SearchBarSample::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
238 SearchBarSample::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
244 SearchBarSample::OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction)
249 //IListViewItemProvider
251 SearchBarSample::CreateItem (int index, int itemWidth)
253 // Creates an instance of CustomItem
254 CustomItem* pItem = new CustomItem();
255 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
257 // Gets texts of the search bar
258 String inputText = null;
259 inputText = __pSearchBar->GetText();
261 if(inputText.CompareTo(L"a") == 0 || inputText.CompareTo(L"A") == 0 )
267 pItem->Construct(Dimension(itemWidth,100), style);
268 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"ajo", true);
273 pItem->Construct(Dimension(itemWidth,100), style);
274 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"aeun", true);
279 pItem->Construct(Dimension(itemWidth,100), style);
280 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"abee", true);
287 else if (inputText.CompareTo(L"b") == 0 || inputText.CompareTo(L"B") == 0)
293 pItem->Construct(Dimension(itemWidth,100), style);
294 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bonge", true);
299 pItem->Construct(Dimension(itemWidth,100), style);
300 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bnpyo", true);
305 pItem->Construct(Dimension(itemWidth,100), style);
306 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bkueon", true);
315 pItem->Construct(Dimension(itemWidth,100), style);
316 pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"default", true);
323 SearchBarSample::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
331 SearchBarSample::GetItemCount(void)
339 class _OSP_EXPORT_ SearchBar
340 : public Tizen::Ui::Control
344 * 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.
351 * 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.
355 virtual ~SearchBar(void);
358 * Initializes this instance of the %SearchBar control with the specified parameters.
362 * @return An error code
363 * @param[in] rect An instance of the Graphics::Rectangle class @n
364 * This instance represents the x and y coordinates of the top-left corner of the created window along with
365 * the width and height of the control.
366 * @param[in] searchBarButton Set to @c true to display the search bar button, @n
368 * @param[in] keypadAction The keypad action
369 * @exception E_SUCCESS The method is successful.
370 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
371 * the action ID of the specified item must be a positive integer.
372 * @exception E_SYSTEM A system error has occurred.
373 * @remarks It is recommended that %SearchBar should be placed at the top-left corner of Form's client area.
374 * @remarks By default, a "Cancel" button is displayed if @c searchBarButton is set to @c true. When the user presses the cancel button,
375 * the %SearchBar control returns to SEARCH_BAR_MODE_NORMAL automatically.
377 result Construct(const Tizen::Graphics::Rectangle& rect, bool searchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH);
380 * Gets the content of Control.
384 * @return The control that is displayed in the content area of %SearchBar in the SEARCH_BAR_MODE_INPUT mode, @n
385 * else @c null if an error occurs
386 * @exception E_SUCCESS The method is successful.
387 * @remarks The specific error code can be accessed using the GetLastResult() method.
389 Tizen::Ui::Control* GetContent(void) const;
392 * Sets the content control.
395 * @brief <i> [Compatibility] </i>
399 * @compatibility This method has compatibility issues with OSP compatible applications. @n
400 * For more information, see @ref CompSetContentPage "here"
402 * @return An error code
403 * @param[in] pContent The control that is to be displayed in the content area of the search bar
404 * @exception E_SUCCESS The method is successful.
405 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
406 * The following controls cannot be set as the content: @n
407 * @li All classes derived from the Window class
408 * @li All picker classes (For example, DateTimePicker)
412 * @exception E_SYSTEM A system error has occurred.
413 * @remarks The specified content control is displayed when the mode of the %SearchBar control is changed to SEARCH_BAR_MODE_INPUT.
414 * @see GetContentAreaSize()
415 * @see AddSearchBarEventListener()
416 * @see ISearchBarEventListener
418 result SetContent(const Tizen::Ui::Control* pContent);
420 * @page CompSetContentPage Compatibility for SetContent()
421 * @section CompSetContentPage IssueSection Issues
422 * Implementing this method in OSP compatible applications has the following issue: @n
423 * SetContent() method passes the ownership of Content control to SearchBar in OSP,
424 * whereas the Content control ownership remains with the caller in Tizen.
426 * @section CompSetContentPage SolutionSection Resolutions
427 * In Tizen, the caller should delete the previous Content control, if this method is called more than once.
431 * Updates the content area of the %SearchBar control.
435 * @return An error code
436 * @param[in] show Set to @c true to perform show on the content area, @n
438 * @exception E_SUCCESS The method is successful.
439 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
440 * The current mode of %SearchBar prohibits the execution of the method.
441 * @exception E_SYSTEM A system error has occurred.
442 * @remarks The method performs Invalidate() on the content area.
444 result UpdateContentArea(bool invalidate = true);
447 * Sets the visibility state of the content area.
451 * @return An error code
452 * @param[in] visible Set to @c true to make the content area visible, @n
454 * @exception E_SUCCESS The method is successful.
455 * @exception E_SYSTEM A system error has occurred.
456 * @see IsContentAreaVisible()
458 result SetContentAreaVisible(bool visible);
461 * Checks whether the content area is visible.
465 * @return @c true if the content area is visible, @n
467 * @exception E_SUCCESS The method is successful.
468 * @see SetContentAreaVisible()
470 bool IsContentAreaVisible(void) const;
473 * Sets the size of the content area of the %SearchBar control.
477 * @return An error code
478 * @param[in] size The size of the content area
479 * @exception E_SUCCESS The method is successful.
480 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
481 * The width and height of @c size must be greater than or equal to @c 0.
482 * @remarks The content area must be resized when the orientation of the form is changed once the size of the content area is changed.
483 * @see GetContentAreaSize()
485 result SetContentAreaSize(const Tizen::Graphics::Dimension& size);
488 * Gets the size of the content area of the %SearchBar control.
492 * @return The size of the content area
493 * @remarks The content area is the area where the 'content' of the %SearchBar control is displayed. The size of the content areas can
494 * be changed at runtime.
495 * @see AddSearchBarEventListener()
496 * @see ISearchBarEventListener
498 Tizen::Graphics::Dimension GetContentAreaSize(void) const;
502 * Gets the search bar mode.
506 * @return The search bar mode
507 * @exception E_SUCCESS The method is successful.
508 * @exception E_SYSTEM A system error has occurred.
509 * @remarks The specific error code can be accessed using the GetLastResult() method.
512 SearchBarMode GetMode(void) const;
515 * Checks whether the search bar mode is locked.
519 * @return @c true if the mode is locked, @n
521 * @exception E_SUCCESS The method is successful.
522 * @exception E_SYSTEM A system error has occurred.
523 * @remarks The specific error code can be accessed using the GetLastResult() method.
526 bool IsModeLocked(void) const;
529 * Sets the search bar mode.
533 * @return An error code
534 * @param[in] mode The search bar mode
535 * @exception E_SUCCESS The method is successful.
536 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or @n
537 * the mode is locked.
538 * @exception E_SYSTEM A system error has occurred.
542 result SetMode(SearchBarMode mode);
545 * Sets the lock status of the search bar mode.
549 * @return An error code
550 * @param[in] modeLocked Set to @c true to lock the search bar mode, @n
552 * @exception E_SUCCESS The method is successful.
553 * @exception E_SYSTEM A system error has occurred.
556 result SetModeLocked(bool modeLocked);
559 * Gets the action ID of the search bar button.
563 * @return The action ID, @n
564 * else @c -1 if an error occurs
565 * @exception E_SUCCESS The method is successful.
566 * @exception E_SYSTEM A system error has occurred.
567 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
568 * By default, the method returns @c -1 if no user defined search bar button is set.
570 int GetButtonActionId(void) const;
573 * Gets the color of the search bar button for the specified state.
577 * @return The color of the search bar button, @n
578 * else RGBA(0,0,0,0) if an error occurs
579 * @param[in] status The status of the search bar button
580 * @exception E_SUCCESS The method is successful.
581 * @exception E_SYSTEM A system error has occurred.
582 * @remarks The specific error code can be accessed using the GetLastResult() method.
583 * @see SetButtonColor()
585 Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const;
588 * Gets the text color of the search bar button for the specified state.
592 * @return The text color of the search bar button, @n
593 * else RGBA(0,0,0,0) if an error occurs
594 * @param[in] status The status of the search bar button
595 * @exception E_SUCCESS The method is successful.
596 * @exception E_SYSTEM A system error has occurred.
597 * @remarks The specific error code can be accessed using the GetLastResult() method.
599 Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const;
602 * Gets the state of the search bar button.
606 * @return The state of the search bar button
607 * @exception E_SUCCESS The method is successful.
608 * @exception E_SYSTEM A system error has occurred.
609 * @remarks The specific error code can be accessed using the GetLastResult() method.
611 SearchBarButtonStatus GetButtonStatus(void) const;
614 * Sets the user defined search bar button.
618 * @return An error code
619 * @param[in] text The button text
620 * @param[in] actionId The button action ID
621 * @exception E_SUCCESS The method is successful.
622 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
623 * the specified @c actionId must be greater than or equal to @c 0.
624 * @exception E_SYSTEM A system error has occurred.
626 result SetButton(const Tizen::Base::String& text, int actionId);
629 * Sets the enabled status of the search bar button.
633 * @return An error code
634 * @param[in] enabled Set to @c true to enable the search bar button, @n
636 * @exception E_SUCCESS The method is successful.
637 * @exception E_SYSTEM A system error has occurred.
639 result SetButtonEnabled(bool enabled);
642 * Sets the color of the search bar button for the specified state.
646 * @return An error code
647 * @param[in] status The button status
648 * @param[in] color The button color to be set
649 * @exception E_SUCCESS The method is successful.
650 * @exception E_SYSTEM A system error has occurred.
651 * @see GetButtonColor()
653 result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
656 * Sets the text color of the button of the %SearchBar control for the specified state.
660 * @return An error code
661 * @param[in] status The button status
662 * @param[in] color The button text color to set
663 * @exception E_SUCCESS The method is successful.
664 * @exception E_SYSTEM A system error has occurred.
666 result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
669 * Appends the specified character at the end of the text.
673 * @return An error code
674 * @param[in] character The character to be added
675 * @exception E_SUCCESS The method is successful.
676 * @exception E_SYSTEM A system error has occurred.
677 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
678 * To display the changes, the control must be drawn again.
680 result AppendCharacter(const Tizen::Base::Character& character);
683 * Appends the specified text at the end of the existing text.
687 * @return An error code
688 * @param[in] text The text to be appended
689 * @exception E_SUCCESS The method is successful.
690 * @exception E_SYSTEM A system error has occurred.
691 * @remarks To denote the end of a line use '\\n'. @n
692 * The method modifies the text buffer that is managed by the %SearchBar control. @n
693 * To display the changes, the control must be drawn again.
695 result AppendText(const Tizen::Base::String& text);
699 * Sets the text to be displayed.
703 * @return An error code
704 * @param[in] text The text to be displayed
705 * @exception E_SUCCESS The method is successful.
706 * @exception E_SYSTEM A system error has occurred.
707 * @remarks To denote the end of a line use '\\n'. @n
708 * The method modifies the text buffer that is managed by the %SearchBar control. @n
709 * To display the changes, the control must be drawn again.
711 result SetText(const Tizen::Base::String& text);
714 * Inserts the character at the specified index.
718 * @return An error code
719 * @param[in] index The position to insert the character
720 * @param[in] character The character to be inserted
721 * @exception E_SUCCESS The method is successful.
722 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
723 * The specified @c index is greater than the number of elements or less than @c 0.
724 * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation.
725 * @exception E_SYSTEM A system error has occurred.
726 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
727 * To display the changes, the control must be drawn again.
729 result InsertCharacterAt(int index, const Tizen::Base::Character& character);
732 * Inserts the specified text at the specified index.
736 * @return An error code
737 * @param[in] index The position at which to insert
738 * @param[in] text The text to be inserted
739 * @exception E_SUCCESS The method is successful.
740 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
741 * The specified @c index is greater than the number of elements or less than @c 0.
742 * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation.
743 * @exception E_SYSTEM A system error has occurred.
744 * @remarks The method modifies the text buffer that is managed by the %SearchBar control.
745 * To display the changes, the control must be drawn again.
747 result InsertTextAt(int index, const Tizen::Base::String& text);
750 * Deletes the character at the specified position.
754 * @return An error code
755 * @param[in] index The index
756 * @exception E_SUCCESS The method is successful.
757 * @exception E_INVALID_ARG The specified @c index is negative.
758 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
759 * The specified @c index is greater than the number of elements or less than @c 0.
760 * @exception E_SYSTEM A system error has occurred.
761 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
762 * To display the changes, the control must be drawn again.
764 result DeleteCharacterAt(int index);
767 * Clears the text that is displayed by the %SearchBar control.
771 * @return An error code
772 * @exception E_SUCCESS The method is successful.
773 * @exception E_SYSTEM A system error has occurred.
774 * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n
775 * To display the changes, the control must be drawn again.
780 * Gets the length of the text that is displayed by the %SearchBar control.
784 * @return The length of the text, @n
785 * else @c -1 if an error occurs
786 * @exception E_SUCCESS The method is successful.
787 * @exception E_SYSTEM A system error has occurred.
788 * @remarks The specific error code can be accessed using the GetLastResult() method.
790 int GetTextLength(void) const;
793 * Gets the text that is displayed by the %SearchBar control.
797 * @return The text displayed by the %SearchBar control, @n
798 * else an empty string if an error occurs
799 * @exception E_SUCCESS The method is successful.
800 * @exception E_SYSTEM A system error has occurred.
801 * @remarks The specific error code can be accessed using the GetLastResult() method.
804 Tizen::Base::String GetText(void) const;
807 * Gets a portion of text that is displayed by the %SearchBar control.
811 * @return The specified portion of the text, @n
812 * else an empty string if an error occurs
813 * @param[in] start The starting index of range
814 * @param[in] end The last index of range
815 * @exception E_SUCCESS The method is successful.
816 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n
817 * either the @c start or @c end parameter is greater than the number of elements or less than @c 0.
818 * @exception E_SYSTEM A system error has occurred.
819 * @remarks The specific error code can be accessed using the GetLastResult() method.
822 Tizen::Base::String GetText(int start, int end) const;
825 * Gets the limit of the length of the text.
829 * @return The limit of the text length, @n
830 * else @c -1 if an error occurs
831 * @exception E_SUCCESS The method is successful.
832 * @exception E_SYSTEM A system error has occurred.
833 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
834 * The default limit length is @c 500.
835 * @see SetLimitLength()
837 int GetLimitLength(void) const;
840 * Sets the limit of the length of the text.
844 * @return An error code
845 * @param[in] limitLength The limit text length to be set
846 * @exception E_SUCCESS The method is successful.
847 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
848 * the specified limit length cannot be @c 0 or negative.
849 * @exception E_SYSTEM A system error has occurred.
850 * @see GetLimitLength()
852 result SetLimitLength(int limitLength);
855 * Shows the keypad associated with the %SearchBar control.
859 * @return An error code
860 * @exception E_SUCCESS The method is successful.
861 * @exception E_INVALID_STATE This instance is in an invalid state.
862 * @exception E_SYSTEM A system error has occurred.
865 result ShowKeypad(void) const;
868 * Hides the keypad associated with the %SearchBar control.
872 * @return An error code
873 * @exception E_SUCCESS The method is successful.
874 * @exception E_SYSTEM A system error has occurred.
877 result HideKeypad(void) const;
880 * Gets the text size of the search field.
884 * @return The size of the text, @n
885 * else @c -1 if an error occurs
886 * @exception E_SUCCESS The method is successful.
887 * @exception E_SYSTEM A system error has occurred.
888 * @remarks The specific error code can be accessed using the GetLastResult() method.
889 * @see SetSearchFieldTextSize()
891 int GetSearchFieldTextSize(void) const;
894 * Sets the text size of the text field of the %SearchBar control.
898 * @return An error code
899 * @param[in] size The text size
900 * @exception E_SUCCESS The method is successful.
901 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
902 * the specified @c size cannot be a negative value.
903 * @exception E_SYSTEM A system error has occurred.
904 * @see GetSearchFieldTextSize()
906 result SetSearchFieldTextSize(int size);
909 * Gets the start and the end index of the currently selected text block.
913 * @return An error code
914 * @param[out] start The start index of the text block
915 * @param[out] end The end index of the text block
916 * @exception E_SUCCESS The method is successful.
917 * @exception E_SYSTEM A system error has occurred.
918 * @remarks The method returns @c start = 0 and @c end = 0 if no text block is selected.
919 * @see ReleaseBlock()
920 * @see SetBlockRange()
922 result GetBlockRange(int& start, int& end) const;
925 * Releases the selection of the current text block.
929 * @return An error code
930 * @exception E_SUCCESS The method is successful.
931 * @exception E_SYSTEM A system error has occurred.
932 * @see GetBlockRange()
933 * @see SetBlockRange()
935 result ReleaseBlock(void);
938 * Sets the block range for the text.
942 * @return An error code
943 * @param[in] start The start index of the text block
944 * @param[in] end The end index of the text block
945 * @exception E_SUCCESS The method is successful.
946 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n
947 * either the @c start or @c end parameter is greater than the number of elements or less than @c 0.
948 * @exception E_SYSTEM A system error has occurred.
949 * @see ReleaseBlock()
950 * @see GetBlockRange()
952 result SetBlockRange(int start, int end);
955 * Removes the text of the selected text block.
959 * @return An error code
960 * @exception E_SUCCESS The method is successful.
961 * @exception E_SYSTEM A system error has occurred.
963 result RemoveTextBlock(void);
966 * Gets the color of the %SearchBar control for the specified status.
970 * @return The color of the %SearchBar control, @n
971 * else RGBA(0,0,0,0) if an error occurs
972 * @exception E_SUCCESS The method is successful.
973 * @exception E_SYSTEM A system error has occurred.
974 * @remarks The specific error code can be accessed using the GetLastResult() method.
977 Tizen::Graphics::Color GetColor(void) const;
980 * Gets the color of the search field for the specified status.
984 * @return The color, @n
985 * else RGBA(0,0,0,0) if an error occurs
986 * @param[in] status The search field status
987 * @exception E_SUCCESS The method is successful.
988 * @exception E_SYSTEM A system error has occurred.
989 * @remarks The specific error code can be accessed using the GetLastResult() method.
990 * @see SetSearchFieldColor()
992 Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const;
995 * Gets the text color of the search field for the specified status.
999 * @return The text color, @n
1000 * else RGBA(0,0,0,0) if an error occurs
1001 * @param[in] status The search field status
1002 * @exception E_SUCCESS The method is successful.
1003 * @exception E_SYSTEM A system error has occurred.
1004 * @remarks The specific error code can be accessed using the GetLastResult() method.
1005 * @see SetSearchFieldTextColor()
1007 Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const;
1010 * Sets the background bitmap of the %SearchBar control.
1014 * @return An error code
1015 * @param[in] bitmap The background bitmap
1016 * @exception E_SUCCESS The method is successful.
1017 * @exception E_SYSTEM A system error has occurred.
1019 result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap);
1022 * Sets the color of the search bar.
1026 * @return An error code
1027 * @param[in] color The color
1028 * @exception E_SUCCESS The method is successful.
1029 * @exception E_SYSTEM A system error has occurred.
1032 result SetColor(const Tizen::Graphics::Color& color);
1035 * Sets the color of the search field for the specified status.
1039 * @return An error code
1040 * @param[in] status The state of the search field
1041 * @param[in] color The text color
1042 * @exception E_SUCCESS The method is successful.
1043 * @exception E_SYSTEM A system error has occurred.
1044 * @see GetSearchFieldColor()
1046 result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
1049 * Sets the text color of the search field for the specified status.
1053 * @return An error code
1054 * @param[in] status The state of the search field
1055 * @param[in] color The text color
1056 * @exception E_SUCCESS The method is successful.
1057 * @exception E_SYSTEM A system error has occurred.
1058 * @see GetSearchFieldTextColor()
1060 result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
1063 * Gets the guide text.
1067 * @return The guide text, @n
1068 * else an empty string if an error occurs
1069 * @exception E_SUCCESS The method is successful.
1070 * @exception E_SYSTEM A system error has occurred.
1071 * @remarks The specific error code can be accessed using the GetLastResult() method.
1072 * @see GetGuideText()
1074 Tizen::Base::String GetGuideText(void) const;
1077 * Sets the guide text. @n
1078 * This text is displayed when there is no text in the %SearchBar control.
1082 * @return An error code
1083 * @param[in] guideText The guide text
1084 * @exception E_SUCCESS The method is successful.
1085 * @exception E_SYSTEM A system error has occurred.
1086 * @see GetGuideText()
1088 result SetGuideText(const Tizen::Base::String& guideText);
1091 * Gets the text color of the guide text.
1095 * @return The text color of the guide text, @n
1096 * else RGBA(0,0,0,0) if an error occurs
1097 * @exception E_SUCCESS The method is successful.
1098 * @exception E_SYSTEM A system error has occurred.
1099 * @remarks The specific error code can be accessed using the GetLastResult() method.
1100 * @see SetGuideTextColor()
1102 Tizen::Graphics::Color GetGuideTextColor(void) const;
1105 * Sets the text color of the guide text.
1109 * @return An error code
1110 * @param[in] color The guide text color
1111 * @exception E_SUCCESS The method is successful.
1112 * @exception E_SYSTEM A system error has occurred.
1113 * @see GetGuideTextColor()
1115 result SetGuideTextColor(const Tizen::Graphics::Color& color);
1119 * Gets the current cursor position index.
1123 * @return The cursor position, @n
1124 * else @c -1 if an error occurs
1125 * @exception E_SUCCESS The method is successful.
1126 * @exception E_SYSTEM A system error has occurred.
1127 * @remarks The specific error code can be accessed using the GetLastResult() method.
1128 * @see SetCursorPosition()
1130 int GetCursorPosition(void) const;
1133 * Sets the cursor at the specified index.
1137 * @return An error code
1138 * @param[in] index The cursor index
1139 * @exception E_SUCCESS The method is successful.
1140 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
1141 * The specified @c index is greater than the number of elements or less than @c 0.
1142 * @exception E_SYSTEM A system error has occurred.
1143 * @see GetCursorPosition()
1145 result SetCursorPosition(int index);
1148 * Checks whether the lowercase mode is enabled.
1152 * @return @c true if the lowercase mode is enabled, @n
1154 * @exception E_SUCCESS The method is successful.
1155 * @exception E_SYSTEM A system error has occurred.
1156 * @remarks The specific error code can be accessed using the GetLastResult() method.
1157 * @see SetLowerCaseModeEnabled()
1159 bool IsLowerCaseModeEnabled(void) const;
1162 * Enables or disables the lowercase mode.
1166 * @param[in] enable Set to @c true to enable the lowercase mode, @n
1168 * @exception E_SUCCESS The method is successful.
1169 * @exception E_SYSTEM A system error has occurred.
1170 * @see IsLowerCaseModeEnabled()
1172 void SetLowerCaseModeEnabled(bool enable);
1176 * Gets the ellipsis position.
1180 * @return The ellipsis position
1181 * @exception E_SUCCESS The method is successful.
1182 * @exception E_SYSTEM A system error has occurred.
1183 * @remarks The specific error code can be accessed using the GetLastResult() method.
1184 * @see SetEllipsisPosition()
1186 EllipsisPosition GetEllipsisPosition(void) const;
1189 * Sets the ellipsis position.
1193 * @return An error code
1194 * @param[in] position The ellipsis position
1195 * @exception E_SUCCESS The method is successful.
1196 * @exception E_SYSTEM A system error has occurred.
1197 * @see GetEllipsisPosition()
1199 result SetEllipsisPosition(EllipsisPosition position);
1202 * Sets the input language.
1206 * @return An error code
1207 * @param[in] languageCode The language to set
1208 * @exception E_SUCCESS The method is successful.
1209 * @exception E_OUT_OF_MEMORY The memory is insufficient.
1210 * @remarks The application can set the language of the current keypad that is associated with the current %SearchBar. @n
1211 * This method only works if the language to set is supported by the current preloaded keypad.
1214 result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode);
1217 * Gets the current input language.
1221 * @return An error code
1222 * @param[out] language The current input language
1223 * @exception E_SUCCESS The method is successful.
1224 * @remarks The application can get the current language of the keypad that is associated with the current %SearchBar.
1227 result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const;
1230 * Gets the keypad action type.
1234 * @return The keypad action
1235 * @exception E_SUCCESS The method is successful.
1236 * @exception E_SYSTEM A system error has occurred.
1237 * @remarks The specific error code can be accessed using the GetLastResult() method.
1239 KeypadAction GetKeypadAction(void) const;
1242 * Checks whether the text prediction is enabled.
1245 * @return @c true if the text prediction is enabled, @n
1247 * @exception E_SUCCESS The method is successful.
1248 * @see SetTextPredictionEnabled()
1250 bool IsTextPredictionEnabled(void) const;
1253 * Enables or disables the text prediction.
1256 * @param[in] enable Set to @c true to enable the text prediction, @n
1258 * @return An error code
1259 * @exception E_SUCCESS The method is successful.
1260 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
1261 * @see IsTextPredictionEnabled()
1263 result SetTextPredictionEnabled(bool enable);
1266 * Adds the specified action event listener. @n
1267 * The added listener is notified when the user clicks the search bar button.
1271 * @param[in] listener The event listener to be added
1272 * @see RemoveActionEventListener()
1274 void AddActionEventListener(Tizen::Ui::IActionEventListener& listener);
1277 * Removes the specified action event listener. @n
1278 * The removed listener cannot listen to events when they are fired.
1282 * @param[in] listener The event listener to be removed
1283 * @see AddActionEventListener()
1285 void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
1288 * Adds the specified text event listener. @n
1289 * The added listener can listen to events on the context of the specified event dispatcher when they are fired.
1293 * @param[in] listener The event listener to be added
1294 * @remarks The added listener is notified when: @n
1295 * @li The user presses a key on the software keypad.
1296 * @li The user selects a word in the candidate list.
1297 * @li The user pastes a text.
1298 * @see RemoveTextEventListener()
1300 void AddTextEventListener(Tizen::Ui::ITextEventListener& listener);
1303 * Removes the specified text event listener. @n
1304 * The removed listener cannot listen to events when they are fired.
1308 * @param[in] listener The event listener to be removed
1309 * @see AddTextEventListener()
1311 void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener);
1314 * Adds the specified search bar event listener. @n
1315 * The added listener can listen to events on the context of the specified event dispatcher when they are fired.
1319 * @param[in] listener The event listener to be added
1320 * @remarks The added listener is notified when: @n
1321 * @li The user presses a key on the software keypad.
1322 * @li The user selects a word in the candidate list.
1323 * @li The user pastes a text.
1324 * @see AddSearchBarEventListener()
1326 void AddSearchBarEventListener(ISearchBarEventListener& listener);
1329 * Removes the specified search bar event listener. @n
1330 * The removed listener cannot listen to events when they are fired.
1334 * @param[in] listener The event listener to be removed
1335 * @see RemoveTextEventListener()
1337 void RemoveSearchBarEventListener(ISearchBarEventListener& listener);
1340 * Adds the specified text block event listener.
1344 * @param[in] listener The event listener to be added
1345 * @remarks Programmatically, modification of the text selection does not cause the text block selection event to fire.
1346 * @see RemoveTextBlockEventListener()
1348 void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
1351 * Removes the specified text block event listener. @n
1352 * The removed listener cannot listen to events when they are fired.
1356 * @param[in] listener The event listener to be removed
1357 * @see AddTextBlockEventListener()
1359 void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
1362 * Adds the specified keypad event listener. @n
1363 * The added listener is notified when the keypad associated with this text editor is opened or closed.
1367 * @param[in] listener The event listener to be added
1368 * @see RemoveKeypadEventListener()
1370 void AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener);
1373 * Removes the specified keypad event listener. @n
1374 * The removed listener cannot listen to events when they are fired.
1378 * @param[in] listener The event listener to be removed
1379 * @see AddKeypadEventListener()
1381 void RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener);
1384 * Adds a listener instance for language events. @n
1385 * The added listener is notified when the input language is changed.
1389 * @param[in] listener The listener to add
1390 * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener.
1391 * @see RemoveLanguageEventListener()
1394 void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener);
1397 * Removes the specified listener instance. @n
1398 * The removed listener cannot listen to events when they are fired.
1402 * @param[in] listener The listener to remove
1403 * @see AddLanguageEventListener()
1406 void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener);
1410 friend class _SearchBarImpl;
1414 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
1416 SearchBar(const SearchBar& rhs);
1419 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
1421 SearchBar& operator =(const SearchBar& rhs);
1425 }}} // Tizen::Ui::Controls
1427 #endif // _FUI_CTRL_SEARCH_BAR_H_