2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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. @n
346 * For full construction, the %Construct() method must be called right after calling this constructor.
353 * This polymorphic destructor should be overridden if required.@n
354 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
358 virtual ~SearchBar(void);
361 * Initializes this instance of the %SearchBar control with the specified parameters.
365 * @return An error code
366 * @param[in] rect An instance of the Graphics::Rectangle class @n
367 * This instance represents the x and y coordinates of the top-left corner of the created window along with
368 * the width and height of the control. @n
369 * The optimal size of the control is defined in
370 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
371 * @param[in] searchBarButton Set to @c true to display the search bar button, @n
373 * @param[in] keypadAction The keypad action
374 * @exception E_SUCCESS The method is successful.
375 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
376 * the action ID of the specified item must be a positive integer.
377 * @exception E_SYSTEM A system error has occurred.
379 * - It is recommended that %SearchBar should be placed at the top-left corner of Form's client area.
380 * - By default, a "Cancel" button is displayed if @c searchBarButton is set to @c true. When the user presses the cancel button,
381 * the %SearchBar control returns to ::SEARCH_BAR_MODE_NORMAL automatically.
383 result Construct(const Tizen::Graphics::Rectangle& rect, bool searchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH);
386 * Initializes this instance of the %SearchBar control with the specified parameters.
390 * @return An error code
391 * @param[in] rect An instance of the Tizen::Graphics::FloatRectangle class @n
392 * This instance represents the x and y coordinates of the top-left corner of the created window along with
393 * the width and height of the control. @n
394 * The optimal size of the control is defined in
395 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
396 * @param[in] searchBarButton Set to @c true to display the search bar button, @n
398 * @param[in] keypadAction The keypad action
399 * @exception E_SUCCESS The method is successful.
400 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
401 * the action ID of the specified item must be a positive integer.
402 * @exception E_SYSTEM A system error has occurred.
404 * - It is recommended that %SearchBar should be placed at the top-left corner of Form's client area.
405 * - By default, a "Cancel" button is displayed if @c searchBarButton is set to @c true. When the user presses the cancel button,
406 * the %SearchBar control returns to ::SEARCH_BAR_MODE_NORMAL automatically.
408 result Construct(const Tizen::Graphics::FloatRectangle& rect, bool searchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH);
411 * Gets the content of Control.
415 * @return The control that is displayed in the content area of %SearchBar in the ::SEARCH_BAR_MODE_INPUT mode, @n
416 * else @c null if an error occurs
417 * @exception E_SUCCESS The method is successful.
418 * @remarks The specific error code can be accessed using the GetLastResult() method.
420 Tizen::Ui::Control* GetContent(void) const;
423 * Sets the content control.
426 * @brief <i> [Compatibility] </i>
430 * @compatibility This method has compatibility issues with OSP compatible applications. @n
431 * For more information, see @ref CompSetContentPage "here"
433 * @return An error code
434 * @param[in] pContent The control to display in the content area of the search bar
435 * @exception E_SUCCESS The method is successful.
436 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
437 * The following controls cannot be set as the content: @n
438 * @li All classes derived from the Window class
439 * @li All picker classes (For example, DateTimePicker)
443 * @exception E_SYSTEM A system error has occurred.
444 * @remarks The specified content control is displayed when the mode of the %SearchBar control is changed to SEARCH_BAR_MODE_INPUT.
445 * @see GetContentAreaSize()
446 * @see AddSearchBarEventListener()
447 * @see ISearchBarEventListener
449 result SetContent(const Tizen::Ui::Control* pContent);
451 * @page CompSetContentPage Compatibility for SetContent()
452 * @section CompSetContentPage IssueSection Issues
453 * Implementing this method in OSP compatible applications has the following issue: @n
454 * SetContent() method passes the ownership of Content control to SearchBar in OSP,
455 * whereas the Content control ownership remains with the caller in Tizen.
457 * @section CompSetContentPage SolutionSection Resolutions
458 * In Tizen, the caller should delete the previous Content control, if this method is called more than once.
462 * Updates the content area of the %SearchBar control.
466 * @return An error code
467 * @param[in] invalidate Set to @c true to perform invalidate on the content area, @n
469 * @exception E_SUCCESS The method is successful.
470 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
471 * The current mode of %SearchBar prohibits the execution of the method.
472 * @exception E_SYSTEM A system error has occurred.
473 * @remarks The method performs Invalidate() on the content area.
475 result UpdateContentArea(bool invalidate = true);
478 * Sets the visibility state of the content area.
482 * @return An error code
483 * @param[in] visible Set to @c true to make the content area visible, @n
485 * @exception E_SUCCESS The method is successful.
486 * @exception E_SYSTEM A system error has occurred.
487 * @see IsContentAreaVisible()
489 result SetContentAreaVisible(bool visible);
492 * Checks whether the content area is visible.
496 * @return @c true if the content area is visible, @n
498 * @exception E_SUCCESS The method is successful.
499 * @see SetContentAreaVisible()
501 bool IsContentAreaVisible(void) const;
504 * Sets the size of the content area of the %SearchBar control.
508 * @return An error code
509 * @param[in] size The size of the content area
510 * @exception E_SUCCESS The method is successful.
511 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
512 * The width and height of @c size must be greater than or equal to @c 0.
513 * @remarks The content area must be resized when the orientation of the form is changed once the size of the content area is changed.
514 * @see GetContentAreaSize()
516 result SetContentAreaSize(const Tizen::Graphics::Dimension& size);
519 * Sets the size of the content area of the %SearchBar control.
523 * @return An error code
524 * @param[in] size The size of the content area
525 * @exception E_SUCCESS The method is successful.
526 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
527 * The width and height of @c size must be greater than or equal to @c 0.
528 * @remarks The content area must be resized when the orientation of the form is changed once the size of the content area is changed.
529 * @see GetContentAreaSizeF()
531 result SetContentAreaSize(const Tizen::Graphics::FloatDimension& size);
534 * Gets the size of the content area of the %SearchBar control.
538 * @return The size of the content area
539 * @remarks The content area is the area where the 'content' of the %SearchBar control is displayed. The size of the content areas can
540 * be changed at runtime.
541 * @see AddSearchBarEventListener()
542 * @see ISearchBarEventListener
544 Tizen::Graphics::Dimension GetContentAreaSize(void) const;
547 * Gets the size of the content area of the %SearchBar control.
551 * @return The size of the content area
552 * @remarks The content area is the area where the 'content' of the %SearchBar control is displayed. The size of the content areas can
553 * be changed at runtime.
554 * @see AddSearchBarEventListener()
555 * @see ISearchBarEventListener
557 Tizen::Graphics::FloatDimension GetContentAreaSizeF(void) const;
561 * Gets the search bar mode.
565 * @return The search bar mode
566 * @exception E_SUCCESS The method is successful.
567 * @exception E_SYSTEM A system error has occurred.
568 * @remarks The specific error code can be accessed using the GetLastResult() method.
571 SearchBarMode GetMode(void) const;
574 * Checks whether the search bar mode is locked.
578 * @return @c true if the mode is locked, @n
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.
585 bool IsModeLocked(void) const;
588 * Sets the search bar mode.
592 * @return An error code
593 * @param[in] mode The search bar mode
594 * @exception E_SUCCESS The method is successful.
595 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or @n
596 * the mode is locked.
597 * @exception E_SYSTEM A system error has occurred.
601 result SetMode(SearchBarMode mode);
604 * Sets the lock status of the search bar mode.
608 * @return An error code
609 * @param[in] modeLocked Set to @c true to lock the search bar mode, @n
611 * @exception E_SUCCESS The method is successful.
612 * @exception E_SYSTEM A system error has occurred.
615 result SetModeLocked(bool modeLocked);
618 * Gets the action ID of the search bar button.
622 * @return The action ID, @n
623 * else @c -1 if an error occurs
624 * @exception E_SUCCESS The method is successful.
625 * @exception E_SYSTEM A system error has occurred.
627 * - The specific error code can be accessed using the GetLastResult() method.
628 * - By default, the method returns @c -1 if no user defined search bar button is set.
630 int GetButtonActionId(void) const;
633 * Gets the color of the search bar button for the specified state.
637 * @return The color of the search bar button, @n
638 * else RGBA(0,0,0,0) if an error occurs
639 * @param[in] status The status of the search bar button
640 * @exception E_SUCCESS The method is successful.
641 * @exception E_SYSTEM A system error has occurred.
642 * @remarks The specific error code can be accessed using the GetLastResult() method.
643 * @see SetButtonColor()
645 Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const;
648 * Gets the text color of the search bar button for the specified state.
652 * @return The text color of the search bar button, @n
653 * else RGBA(0,0,0,0) if an error occurs
654 * @param[in] status The status of the search bar button
655 * @exception E_SUCCESS The method is successful.
656 * @exception E_SYSTEM A system error has occurred.
657 * @remarks The specific error code can be accessed using the GetLastResult() method.
659 Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const;
662 * Gets the state of the search bar button.
666 * @return The state of the search bar button
667 * @exception E_SUCCESS The method is successful.
668 * @exception E_SYSTEM A system error has occurred.
669 * @remarks The specific error code can be accessed using the GetLastResult() method.
671 SearchBarButtonStatus GetButtonStatus(void) const;
674 * Sets the user defined search bar button.
678 * @return An error code
679 * @param[in] text The button text
680 * @param[in] actionId The button action ID
681 * @exception E_SUCCESS The method is successful.
682 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
683 * the specified @c actionId must be greater than or equal to @c 0.
684 * @exception E_SYSTEM A system error has occurred.
686 result SetButton(const Tizen::Base::String& text, int actionId);
689 * Sets the enabled status of the search bar button.
693 * @return An error code
694 * @param[in] enabled Set to @c true to enable the search bar button, @n
696 * @exception E_SUCCESS The method is successful.
697 * @exception E_SYSTEM A system error has occurred.
699 result SetButtonEnabled(bool enabled);
702 * Sets the color of the search bar button for the specified state.
706 * @return An error code
707 * @param[in] status The button status
708 * @param[in] color The button color to set
709 * @exception E_SUCCESS The method is successful.
710 * @exception E_SYSTEM A system error has occurred.
711 * @see GetButtonColor()
713 result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
716 * Sets the text color of the button of the %SearchBar control for the specified state.
720 * @return An error code
721 * @param[in] status The button status
722 * @param[in] color The button text color to set
723 * @exception E_SUCCESS The method is successful.
724 * @exception E_SYSTEM A system error has occurred.
726 result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
729 * Appends the specified character at the end of the text.
733 * @return An error code
734 * @param[in] character The character to add
735 * @exception E_SUCCESS The method is successful.
736 * @exception E_SYSTEM A system error has occurred.
738 * - The method modifies the text buffer that is managed by the %SearchBar control.
739 * - To display the changes, the control must be drawn again.
741 result AppendCharacter(const Tizen::Base::Character& character);
744 * Appends the specified text at the end of the existing text.
748 * @return An error code
749 * @param[in] text The text to append
750 * @exception E_SUCCESS The method is successful.
751 * @exception E_SYSTEM A system error has occurred.
753 * - To denote the end of a line use '\\n'.
754 * - The method modifies the text buffer that is managed by the %SearchBar control.
755 * - To display the changes, the control must be drawn again.
757 result AppendText(const Tizen::Base::String& text);
761 * Sets the text to be displayed.
765 * @return An error code
766 * @param[in] text The text to display
767 * @exception E_SUCCESS The method is successful.
768 * @exception E_SYSTEM A system error has occurred.
770 * - To denote the end of a line use '\\n'.
771 * - The method modifies the text buffer that is managed by the %SearchBar control.
772 * - To display the changes, the control must be drawn again.
774 result SetText(const Tizen::Base::String& text);
777 * Inserts the character at the specified index.
781 * @return An error code
782 * @param[in] index The position to insert the character
783 * @param[in] character The character to insert
784 * @exception E_SUCCESS The method is successful.
785 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
786 * The specified @c index is greater than the number of elements or less than @c 0.
787 * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation.
788 * @exception E_SYSTEM A system error has occurred.
790 * - The method modifies the text buffer that is managed by the %SearchBar control.
791 * - To display the changes, the control must be drawn again.
793 result InsertCharacterAt(int index, const Tizen::Base::Character& character);
796 * Inserts the specified text at the specified index.
800 * @return An error code
801 * @param[in] index The position at which to insert
802 * @param[in] text The text to insert
803 * @exception E_SUCCESS The method is successful.
804 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
805 * The specified @c index is greater than the number of elements or less than @c 0.
806 * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation.
807 * @exception E_SYSTEM A system error has occurred.
809 * - The method modifies the text buffer that is managed by the %SearchBar control.
810 * - To display the changes, the control must be drawn again.
812 result InsertTextAt(int index, const Tizen::Base::String& text);
815 * Deletes the character at the specified position.
819 * @return An error code
820 * @param[in] index The index
821 * @exception E_SUCCESS The method is successful.
822 * @exception E_INVALID_ARG The specified @c index is negative.
823 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
824 * The specified @c index is greater than the number of elements or less than @c 0.
825 * @exception E_SYSTEM A system error has occurred.
827 * - The method modifies the text buffer that is managed by the %SearchBar control.
828 * - To display the changes, the control must be drawn again.
830 result DeleteCharacterAt(int index);
833 * Clears the text that is displayed by the %SearchBar control.
837 * @return An error code
838 * @exception E_SUCCESS The method is successful.
839 * @exception E_SYSTEM A system error has occurred.
841 * - The method modifies the text buffer that is managed by the %SearchBar control.
842 * - To display the changes, the control must be drawn again.
847 * Gets the length of the text that is displayed by the %SearchBar control.
851 * @return The length of the text, @n
852 * else @c -1 if an error occurs
853 * @exception E_SUCCESS The method is successful.
854 * @exception E_SYSTEM A system error has occurred.
855 * @remarks The specific error code can be accessed using the GetLastResult() method.
857 int GetTextLength(void) const;
860 * Gets the text that is displayed by the %SearchBar control.
864 * @return The text displayed by the %SearchBar control, @n
865 * else an empty string if an error occurs
866 * @exception E_SUCCESS The method is successful.
867 * @exception E_SYSTEM A system error has occurred.
868 * @remarks The specific error code can be accessed using the GetLastResult() method.
871 Tizen::Base::String GetText(void) const;
874 * Gets a portion of text that is displayed by the %SearchBar control.
878 * @return The specified portion of the text, @n
879 * else an empty string if an error occurs
880 * @param[in] start The starting index of range
881 * @param[in] end The last index of range
882 * @exception E_SUCCESS The method is successful.
883 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n
884 * either the @c start or @c end parameter is greater than the number of elements or less than @c 0.
885 * @exception E_SYSTEM A system error has occurred.
886 * @remarks The specific error code can be accessed using the GetLastResult() method.
889 Tizen::Base::String GetText(int start, int end) const;
892 * Gets the limit of the length of the text.
896 * @return The limit of the text length, @n
897 * else @c -1 if an error occurs
898 * @exception E_SUCCESS The method is successful.
899 * @exception E_SYSTEM A system error has occurred.
901 * - The specific error code can be accessed using the GetLastResult() method.
902 * - The default limit length is @c 500.
903 * @see SetLimitLength()
905 int GetLimitLength(void) const;
908 * Sets the limit of the length of the text.
912 * @return An error code
913 * @param[in] limitLength The limit text length to set
914 * @exception E_SUCCESS The method is successful.
915 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
916 * the specified limit length cannot be @c 0 or negative.
917 * @exception E_SYSTEM A system error has occurred.
918 * @see GetLimitLength()
920 result SetLimitLength(int limitLength);
923 * Shows the keypad associated with the %SearchBar control.
927 * @return An error code
928 * @exception E_SUCCESS The method is successful.
929 * @exception E_INVALID_STATE This instance is in an invalid state.
930 * @exception E_SYSTEM A system error has occurred.
933 result ShowKeypad(void) const;
936 * Hides the keypad associated with the %SearchBar control.
940 * @return An error code
941 * @exception E_SUCCESS The method is successful.
942 * @exception E_SYSTEM A system error has occurred.
945 result HideKeypad(void) const;
948 * Gets the text size of the search field.
952 * @return The size of the text, @n
953 * else @c -1 if an error occurs
954 * @exception E_SUCCESS The method is successful.
955 * @exception E_SYSTEM A system error has occurred.
956 * @remarks The specific error code can be accessed using the GetLastResult() method.
957 * @see SetSearchFieldTextSize()
959 int GetSearchFieldTextSize(void) const;
962 * Gets the text size of the search field.
966 * @return The size of the text, @n
967 * else @c -1 if an error occurs
968 * @exception E_SUCCESS The method is successful.
969 * @exception E_SYSTEM A system error has occurred.
970 * @remarks The specific error code can be accessed using the GetLastResult() method.
971 * @see SetSearchFieldTextSize()
973 float GetSearchFieldTextSizeF(void) const;
976 * Sets the text size of the text field of the %SearchBar control.
980 * @return An error code
981 * @param[in] size The text size
982 * @exception E_SUCCESS The method is successful.
983 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
984 * the specified @c size cannot be a negative value.
985 * @exception E_SYSTEM A system error has occurred.
986 * @see GetSearchFieldTextSize()
988 result SetSearchFieldTextSize(int size);
991 * Sets the text size of the text field of the %SearchBar control.
995 * @return An error code
996 * @param[in] size The text size
997 * @exception E_SUCCESS The method is successful.
998 * @exception E_INVALID_ARG The specified input parameter is invalid, or @n
999 * the specified @c size cannot be a negative value.
1000 * @exception E_SYSTEM A system error has occurred.
1001 * @see GetSearchFieldTextSizeF()
1003 result SetSearchFieldTextSize(float size);
1006 * Gets the start and the end index of the currently selected text block.
1010 * @return An error code
1011 * @param[out] start The start index of the text block
1012 * @param[out] end The end index of the text block
1013 * @exception E_SUCCESS The method is successful.
1014 * @exception E_SYSTEM A system error has occurred.
1015 * @remarks The method returns @c start = 0 and @c end = 0 if no text block is selected.
1016 * @see ReleaseBlock()
1017 * @see SetBlockRange()
1019 result GetBlockRange(int& start, int& end) const;
1022 * Releases the selection of the current text block.
1026 * @return An error code
1027 * @exception E_SUCCESS The method is successful.
1028 * @exception E_SYSTEM A system error has occurred.
1029 * @see GetBlockRange()
1030 * @see SetBlockRange()
1032 result ReleaseBlock(void);
1035 * Sets the block range for the text.
1039 * @return An error code
1040 * @param[in] start The start index of the text block
1041 * @param[in] end The end index of the text block
1042 * @exception E_SUCCESS The method is successful.
1043 * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n
1044 * either the @c start or @c end parameter is greater than the number of elements or less than @c 0.
1045 * @exception E_SYSTEM A system error has occurred.
1046 * @see ReleaseBlock()
1047 * @see GetBlockRange()
1049 result SetBlockRange(int start, int end);
1052 * Removes the text of the selected text block.
1056 * @return An error code
1057 * @exception E_SUCCESS The method is successful.
1058 * @exception E_SYSTEM A system error has occurred.
1060 result RemoveTextBlock(void);
1063 * Gets the color of the %SearchBar control for the specified status.
1067 * @return The color of the %SearchBar control, @n
1068 * else RGBA(0,0,0,0) 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.
1074 Tizen::Graphics::Color GetColor(void) const;
1077 * Gets the color of the search field for the specified status.
1081 * @return The color, @n
1082 * else RGBA(0,0,0,0) if an error occurs
1083 * @param[in] status The search field status
1084 * @exception E_SUCCESS The method is successful.
1085 * @exception E_SYSTEM A system error has occurred.
1086 * @remarks The specific error code can be accessed using the GetLastResult() method.
1087 * @see SetSearchFieldColor()
1089 Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const;
1092 * Gets the text color of the search field for the specified status.
1096 * @return The text color, @n
1097 * else RGBA(0,0,0,0) if an error occurs
1098 * @param[in] status The search field status
1099 * @exception E_SUCCESS The method is successful.
1100 * @exception E_SYSTEM A system error has occurred.
1101 * @remarks The specific error code can be accessed using the GetLastResult() method.
1102 * @see SetSearchFieldTextColor()
1104 Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const;
1107 * Sets the background bitmap of the %SearchBar control.
1111 * @return An error code
1112 * @param[in] bitmap The background bitmap
1113 * @exception E_SUCCESS The method is successful.
1114 * @exception E_SYSTEM A system error has occurred.
1116 result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap);
1119 * Sets the color of the search bar.
1123 * @return An error code
1124 * @param[in] color The color
1125 * @exception E_SUCCESS The method is successful.
1126 * @exception E_SYSTEM A system error has occurred.
1129 result SetColor(const Tizen::Graphics::Color& color);
1132 * Sets the color of the search field for the specified status.
1136 * @return An error code
1137 * @param[in] status The state of the search field
1138 * @param[in] color The text color
1139 * @exception E_SUCCESS The method is successful.
1140 * @exception E_SYSTEM A system error has occurred.
1141 * @see GetSearchFieldColor()
1143 result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
1146 * Sets the text color of the search field for the specified status.
1150 * @return An error code
1151 * @param[in] status The state of the search field
1152 * @param[in] color The text color
1153 * @exception E_SUCCESS The method is successful.
1154 * @exception E_SYSTEM A system error has occurred.
1155 * @see GetSearchFieldTextColor()
1157 result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
1160 * Gets the guide text.
1164 * @return The guide text, @n
1165 * else an empty string if an error occurs
1166 * @exception E_SUCCESS The method is successful.
1167 * @exception E_SYSTEM A system error has occurred.
1168 * @remarks The specific error code can be accessed using the GetLastResult() method.
1169 * @see GetGuideText()
1171 Tizen::Base::String GetGuideText(void) const;
1174 * Sets the guide text. @n
1175 * This text is displayed when there is no text in the %SearchBar control.
1179 * @return An error code
1180 * @param[in] guideText The guide text
1181 * @exception E_SUCCESS The method is successful.
1182 * @exception E_SYSTEM A system error has occurred.
1183 * @see GetGuideText()
1185 result SetGuideText(const Tizen::Base::String& guideText);
1188 * Gets the text color of the guide text.
1192 * @return The text color of the guide text, @n
1193 * else RGBA(0,0,0,0) if an error occurs
1194 * @exception E_SUCCESS The method is successful.
1195 * @exception E_SYSTEM A system error has occurred.
1196 * @remarks The specific error code can be accessed using the GetLastResult() method.
1197 * @see SetGuideTextColor()
1199 Tizen::Graphics::Color GetGuideTextColor(void) const;
1202 * Sets the text color of the guide text.
1206 * @return An error code
1207 * @param[in] color The guide text color
1208 * @exception E_SUCCESS The method is successful.
1209 * @exception E_SYSTEM A system error has occurred.
1210 * @see GetGuideTextColor()
1212 result SetGuideTextColor(const Tizen::Graphics::Color& color);
1216 * Gets the current cursor position index.
1220 * @return The cursor position, @n
1221 * else @c -1 if an error occurs
1222 * @exception E_SUCCESS The method is successful.
1223 * @exception E_SYSTEM A system error has occurred.
1224 * @remarks The specific error code can be accessed using the GetLastResult() method.
1225 * @see SetCursorPosition()
1227 int GetCursorPosition(void) const;
1230 * Sets the cursor at the specified index.
1234 * @return An error code
1235 * @param[in] index The cursor index
1236 * @exception E_SUCCESS The method is successful.
1237 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n
1238 * The specified @c index is greater than the number of elements or less than @c 0.
1239 * @exception E_SYSTEM A system error has occurred.
1240 * @see GetCursorPosition()
1242 result SetCursorPosition(int index);
1245 * Checks whether the lowercase mode is enabled.
1249 * @return @c true if the lowercase mode is enabled, @n
1251 * @exception E_SUCCESS The method is successful.
1252 * @exception E_SYSTEM A system error has occurred.
1253 * @remarks The specific error code can be accessed using the GetLastResult() method.
1254 * @see SetLowerCaseModeEnabled()
1256 bool IsLowerCaseModeEnabled(void) const;
1259 * Enables or disables the lowercase mode.
1263 * @param[in] enable Set to @c true to enable the lowercase mode, @n
1265 * @exception E_SUCCESS The method is successful.
1266 * @exception E_SYSTEM A system error has occurred.
1267 * @see IsLowerCaseModeEnabled()
1269 void SetLowerCaseModeEnabled(bool enable);
1273 * Gets the ellipsis position.
1277 * @return The ellipsis position
1278 * @exception E_SUCCESS The method is successful.
1279 * @exception E_SYSTEM A system error has occurred.
1280 * @remarks The specific error code can be accessed using the GetLastResult() method.
1281 * @see SetEllipsisPosition()
1283 EllipsisPosition GetEllipsisPosition(void) const;
1286 * Sets the ellipsis position.
1290 * @return An error code
1291 * @param[in] position The ellipsis position
1292 * @exception E_SUCCESS The method is successful.
1293 * @exception E_SYSTEM A system error has occurred.
1294 * @see GetEllipsisPosition()
1296 result SetEllipsisPosition(EllipsisPosition position);
1299 * Sets the input language.
1303 * @brief <i> [Deprecated] </i>
1304 * @deprecated We no longer provide a method to set the language of the current keypad. @n
1305 * This method is provided only for backward compatibility and will be deleted in the near future.
1306 * @return An error code
1307 * @param[in] languageCode The language to set
1308 * @exception E_SUCCESS The method is successful.
1309 * @exception E_OUT_OF_MEMORY The memory is insufficient.
1311 * - The application can set the language of the current keypad that is associated with the current %SearchBar.
1312 * - This method only works if the language to set is supported by the current preloaded keypad.
1315 result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode);
1318 * Gets the current input language.
1322 * @return An error code
1323 * @param[out] language The current input language
1324 * @exception E_SUCCESS The method is successful.
1325 * @remarks The application can get the current language of the keypad that is associated with the current %SearchBar.
1328 result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const;
1331 * Gets the keypad action type.
1335 * @return The keypad action
1336 * @exception E_SUCCESS The method is successful.
1337 * @exception E_SYSTEM A system error has occurred.
1338 * @remarks The specific error code can be accessed using the GetLastResult() method.
1340 KeypadAction GetKeypadAction(void) const;
1343 * Checks whether the text prediction is enabled.
1346 * @return @c true if the text prediction is enabled, @n
1348 * @exception E_SUCCESS The method is successful.
1349 * @see SetTextPredictionEnabled()
1351 bool IsTextPredictionEnabled(void) const;
1354 * Enables or disables the text prediction.
1357 * @param[in] enable Set to @c true to enable the text prediction, @n
1359 * @return An error code
1360 * @exception E_SUCCESS The method is successful.
1361 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
1362 * @see IsTextPredictionEnabled()
1364 result SetTextPredictionEnabled(bool enable);
1367 * Adds the specified action event listener. @n
1368 * The added listener is notified when the user clicks the search bar button.
1372 * @param[in] listener The event listener to add
1373 * @see RemoveActionEventListener()
1375 void AddActionEventListener(Tizen::Ui::IActionEventListener& listener);
1378 * Removes the specified action event listener. @n
1379 * The removed listener cannot listen to events when they are fired.
1383 * @param[in] listener The event listener to remove
1384 * @see AddActionEventListener()
1386 void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
1389 * Adds the specified text event listener. @n
1390 * The added listener can listen to events on the context of the specified event dispatcher when they are fired.
1394 * @param[in] listener The event listener to add
1395 * @remarks The added listener is notified when: @n
1396 * @li The user presses a key on the software keypad.
1397 * @li The user selects a word in the candidate list.
1398 * @li The user pastes a text.
1399 * @see RemoveTextEventListener()
1401 void AddTextEventListener(Tizen::Ui::ITextEventListener& listener);
1404 * Removes the specified text event listener. @n
1405 * The removed listener cannot listen to events when they are fired.
1409 * @param[in] listener The event listener to remove
1410 * @see AddTextEventListener()
1412 void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener);
1415 * Adds the specified search bar event listener. @n
1416 * The added listener can listen to events on the context of the specified event dispatcher when they are fired.
1420 * @param[in] listener The event listener to add
1421 * @remarks The added listener is notified when: @n
1422 * @li The user presses a key on the software keypad.
1423 * @li The user selects a word in the candidate list.
1424 * @li The user pastes a text.
1425 * @see AddSearchBarEventListener()
1427 void AddSearchBarEventListener(ISearchBarEventListener& listener);
1430 * Removes the specified search bar event listener. @n
1431 * The removed listener cannot listen to events when they are fired.
1435 * @param[in] listener The event listener to remove
1436 * @see RemoveTextEventListener()
1438 void RemoveSearchBarEventListener(ISearchBarEventListener& listener);
1441 * Adds the specified text block event listener.
1445 * @param[in] listener The event listener to add
1446 * @remarks Programmatically, modification of the text selection does not cause the text block selection event to fire.
1447 * @see RemoveTextBlockEventListener()
1449 void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
1452 * Removes the specified text block event listener. @n
1453 * The removed listener cannot listen to events when they are fired.
1457 * @param[in] listener The event listener to remove
1458 * @see AddTextBlockEventListener()
1460 void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener);
1463 * Adds the specified keypad event listener. @n
1464 * The added listener is notified when the keypad associated with this text editor is opened or closed.
1468 * @param[in] listener The event listener to add
1469 * @see RemoveKeypadEventListener()
1471 void AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener);
1474 * Removes the specified keypad event listener. @n
1475 * The removed listener cannot listen to events when they are fired.
1479 * @param[in] listener The event listener to remove
1480 * @see AddKeypadEventListener()
1482 void RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener);
1485 * Adds a listener instance for language events. @n
1486 * The added listener is notified when the input language is changed.
1490 * @param[in] listener The listener to add
1491 * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener.
1492 * @see RemoveLanguageEventListener()
1495 void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener);
1498 * Removes the specified listener instance. @n
1499 * The removed listener cannot listen to events when they are fired.
1503 * @param[in] listener The listener to remove
1504 * @see AddLanguageEventListener()
1507 void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener);
1510 * Sets the text filter.
1514 * @param[in] pFilter The filter
1515 * @remarks The %SearchBar control checks with the registered filter to decide whether the user-entered text should be replaced.
1517 void SetEditTextFilter(IEditTextFilter* pFilter);
1520 * Sends opaque command to the input method.
1524 * @param[in] command The opaque command
1526 * - This method can be used to provide domain-specific features that are only known between certain input methods and their clients.
1527 * - This method may not work, depending on the active Input Method.
1529 void SendOpaqueCommand (const Tizen::Base::String& command);
1532 friend class _SearchBarImpl;
1536 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
1538 SearchBar(const SearchBar& rhs);
1541 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
1543 SearchBar& operator =(const SearchBar& rhs);
1547 }}} // Tizen::Ui::Controls
1549 #endif // _FUI_CTRL_SEARCH_BAR_H_