2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_SearchBarImpl.cpp
20 * @brief This is the implementation file for _SearchBarImpl class.
23 #include <FApp_AppInfo.h>
24 #include <FBaseSysLog.h>
25 #include <FLclLocale.h>
26 #include "FUi_ResourceSizeInfo.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUi_UiBuilder.h"
29 #include "FUiCtrl_PublicActionEvent.h"
30 #include "FUiCtrl_PublicTextBlockEvent.h"
31 #include "FUiCtrl_PublicTextEvent.h"
32 #include "FUiCtrl_SearchBarImpl.h"
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Locales;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Ui;
41 namespace Tizen { namespace Ui { namespace Controls
44 _SearchBarImpl::_SearchBarImpl(SearchBar* pPublic, _SearchBar* pCore)
45 : _ControlImpl(pPublic, pCore)
47 , __pContentControl(null)
48 , __pPublicActionEvent(null)
49 , __pPublicKeypadEvent(null)
50 , __pPublicTextBlockEvent(null)
51 , __pPublicTextEvent(null)
52 , __pPublicSearchBarEvent(null)
53 , __pPublicLanguageEvent(null)
58 _SearchBarImpl::~_SearchBarImpl(void)
65 if (__pPublicActionEvent)
67 delete __pPublicActionEvent;
68 __pPublicActionEvent = null;
71 if (__pPublicKeypadEvent)
73 delete __pPublicKeypadEvent;
74 __pPublicKeypadEvent = null;
77 if (__pPublicTextBlockEvent)
79 delete __pPublicTextBlockEvent;
80 __pPublicTextBlockEvent = null;
83 if (__pPublicTextEvent)
85 delete __pPublicTextEvent;
86 __pPublicTextEvent = null;
89 if (__pPublicSearchBarEvent)
91 delete __pPublicSearchBarEvent;
92 __pPublicSearchBarEvent = null;
97 _SearchBarImpl::CreateSearchBarImplN(SearchBar* pControl, const Rectangle& bounds, bool enableSearchBarButton, KeypadAction keypadAction)
100 result r = E_SUCCESS;
102 r = GET_SIZE_INFO(SearchBar).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
103 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG,
104 "[E_INVALID_ARG] Invalid argument(s) is used. The given size is not valid.");
106 _SearchBar* pCore = _SearchBar::CreateSearchBarN();
108 SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
110 _SearchBarImpl* pImpl = new (std::nothrow) _SearchBarImpl(pControl, pCore);
112 r = CheckConstruction(pCore, pImpl);
113 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
115 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(SearchBar), bounds, pCore->GetOrientation());
116 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
118 r = pImpl->Initialize(enableSearchBarButton, keypadAction);
119 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
128 _SearchBarImpl::GetPublicClassName(void) const
130 return "Tizen::Ui::Controls::SearchBar";
134 _SearchBarImpl::GetPublic(void) const
136 return static_cast <const SearchBar&>(_ControlImpl::GetPublic());
140 _SearchBarImpl::GetPublic(void)
142 return static_cast <SearchBar&>(_ControlImpl::GetPublic());
146 _SearchBarImpl::GetCore(void) const
148 return static_cast <const _SearchBar&>(_ControlImpl::GetCore());
152 _SearchBarImpl::GetCore(void)
154 return static_cast <_SearchBar&>(_ControlImpl::GetCore());
158 _SearchBarImpl::GetInstance(SearchBar& searchBar)
160 return (static_cast<_SearchBarImpl*>(searchBar._pControlImpl));
163 const _SearchBarImpl*
164 _SearchBarImpl::GetInstance(const SearchBar& searchBar)
166 return (static_cast<const _SearchBarImpl*>(searchBar._pControlImpl));
171 _SearchBarImpl::Initialize(bool enableSearchBarButton, KeypadAction keypadAction)
175 result r = E_SUCCESS;
177 CoreKeypadAction coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH;
178 switch (keypadAction)
180 case KEYPAD_ACTION_ENTER:
181 coreKeypadAction = CORE_KEYPAD_ACTION_ENTER;
184 case KEYPAD_ACTION_GO:
185 coreKeypadAction = CORE_KEYPAD_ACTION_GO;
188 case KEYPAD_ACTION_NEXT:
189 coreKeypadAction = CORE_KEYPAD_ACTION_NEXT;
192 case KEYPAD_ACTION_SEND:
193 coreKeypadAction = CORE_KEYPAD_ACTION_SEND;
196 case KEYPAD_ACTION_SEARCH:
197 coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH;
200 case KEYPAD_ACTION_LOGIN:
201 coreKeypadAction = CORE_KEYPAD_ACTION_LOGIN;
204 case KEYPAD_ACTION_SIGN_IN:
205 coreKeypadAction = CORE_KEYPAD_ACTION_SIGN_IN;
208 case KEYPAD_ACTION_JOIN:
209 coreKeypadAction = CORE_KEYPAD_ACTION_JOIN;
212 case KEYPAD_ACTION_DONE:
213 coreKeypadAction = CORE_KEYPAD_ACTION_DONE;
220 r = __pSearchBar->Initialize(enableSearchBarButton, coreKeypadAction);
221 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
223 __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
225 SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
227 r = __pSearchBar->AddActionEventListener(*this);
228 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
230 __pPublicKeypadEvent = _PublicKeypadEvent::CreateInstanceN(GetPublic());
232 SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
234 r = __pSearchBar->AddKeypadEventListener(*this);
235 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
237 __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic());
239 SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
241 r = __pSearchBar->AddTextBlockEventListener(*this);
242 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
244 __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic());
246 SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
248 r = __pSearchBar->AddTextEventListener(*this);
249 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
251 __pPublicSearchBarEvent = _PublicSearchBarEvent::CreateInstanceN(GetPublic());
253 SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
255 r = __pSearchBar->AddSearchBarEventListener(*this);
256 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
258 __pPublicLanguageEvent = _PublicLanguageEvent::CreateInstanceN(GetPublic());
260 SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
262 r = __pSearchBar->AddLanguageEventListener(*this);
263 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
269 _SearchBarImpl::GetContent(void) const
273 return __pContentControl;
277 _SearchBarImpl::SetContent(const Control* pContent)
281 result r = E_SUCCESS;
282 if (pContent != null)
284 const _Control& content = _ControlImpl::GetInstance(*pContent)->GetCore();
285 bool isContentAttachable = __pSearchBar->IsContentAttachable(&content);
286 SysTryReturn(NID_UI_CTRL, isContentAttachable, E_INVALID_ARG, E_INVALID_ARG,
287 "[E_INVALID_ARG] Invalid argument(s) is used. The content cannot be set.");
290 if (__pContentControl != null)
292 _Control& contentControl = _ControlImpl::GetInstance(*__pContentControl)->GetCore();
294 if (pContent != null)
296 const _Control& content = _ControlImpl::GetInstance(*pContent)->GetCore();
298 if (contentControl.GetHandle() == content.GetHandle())
304 _Control* pContainer = __pSearchBar->GetSearchBarContainer();
308 pContainer->DetachChild(contentControl);
310 if(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
312 delete __pContentControl;
314 __pContentControl = null;
318 if (pContent != null && __pContentControl == null)
320 __pContentControl = const_cast <Control*>(pContent);
321 _Control& control = _ControlImpl::GetInstance(*__pContentControl)->GetCore();
323 r = __pSearchBar->SetContent(&control);
330 _SearchBarImpl::UpdateContentArea(bool invalidate)
334 return __pSearchBar->UpdateContentArea(invalidate);
338 _SearchBarImpl::SetContentAreaVisible(bool visible)
342 return __pSearchBar->SetContentAreaVisible(visible);
346 _SearchBarImpl::IsContentAreaVisible(void) const
350 return __pSearchBar->IsContentAreaVisible();
354 _SearchBarImpl::SetContentAreaSize(const Dimension& size)
360 return __pSearchBar->SetPropertyContentAreaSize(var);
364 _SearchBarImpl::GetContentAreaSize(void) const
368 return __pSearchBar->GetPropertyContentAreaSize().ToDimension();
372 _SearchBarImpl::GetMode(void) const
376 return __pSearchBar->GetMode();
380 _SearchBarImpl::IsModeLocked(void) const
384 return __pSearchBar->IsModeLocked();
388 _SearchBarImpl::SetMode(SearchBarMode mode)
392 return __pSearchBar->SetMode(mode);
396 _SearchBarImpl::SetModeLocked(bool modeLocked)
400 return __pSearchBar->SetModeLocked(modeLocked);
404 _SearchBarImpl::GetButtonActionId(void) const
408 return __pSearchBar->GetPropertyButtonActionId().ToInt();
412 _SearchBarImpl::GetButtonColor(SearchBarButtonStatus status) const
420 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
421 buttonColor = __pSearchBar->GetPropertyButtonNormalColor();
423 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
424 buttonColor = __pSearchBar->GetPropertyButtonPressedColor();
426 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
427 buttonColor = __pSearchBar->GetPropertyButtonHighlightedColor();
429 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
430 buttonColor = __pSearchBar->GetPropertyButtonDisabledColor();
436 return buttonColor.ToColor();
440 _SearchBarImpl::GetButtonTextColor(SearchBarButtonStatus status) const
444 Variant buttonTextColor;
448 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
449 buttonTextColor = __pSearchBar->GetPropertyButtonNormalTextColor();
451 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
452 buttonTextColor = __pSearchBar->GetPropertyButtonPressedTextColor();
454 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
455 buttonTextColor = __pSearchBar->GetPropertyButtonHighlightedTextColor();
457 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
458 buttonTextColor = __pSearchBar->GetPropertyButtonDisabledTextColor();
464 return buttonTextColor.ToColor();
467 SearchBarButtonStatus
468 _SearchBarImpl::GetButtonStatus(void) const
472 return __pSearchBar->GetButtonStatus();
476 _SearchBarImpl::SetButton(const String& text, int actionId)
480 result r = E_SUCCESS;
481 Variant var(actionId);
483 r = __pSearchBar->SetButtonText(text);
484 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
486 r = __pSearchBar->SetPropertyButtonActionId(var);
492 _SearchBarImpl::SetButtonEnabled(bool enabled)
496 return __pSearchBar->SetButtonEnabled(enabled);
500 _SearchBarImpl::SetButtonColor(SearchBarButtonStatus status, const Color& color)
504 result r = E_SUCCESS;
509 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
510 r = __pSearchBar->SetPropertyButtonNormalColor(var);
512 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
513 r = __pSearchBar->SetPropertyButtonPressedColor(var);
515 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
516 r = __pSearchBar->SetPropertyButtonHighlightedColor(var);
518 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
519 r = __pSearchBar->SetPropertyButtonDisabledColor(var);
529 _SearchBarImpl::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
533 result r = E_SUCCESS;
538 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
539 r = __pSearchBar->SetPropertyButtonNormalTextColor(var);
541 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
542 r = __pSearchBar->SetPropertyButtonPressedTextColor(var);
544 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
545 r = __pSearchBar->SetPropertyButtonHighlightedTextColor(var);
547 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
548 r = __pSearchBar->SetPropertyButtonDisabledTextColor(var);
558 _SearchBarImpl::AppendCharacter(const Character& character)
562 return __pSearchBar->AppendCharacter(character);
566 _SearchBarImpl::AppendText(const String& text)
570 return __pSearchBar->AppendText(text);
574 _SearchBarImpl::SetText(const String& text)
578 return __pSearchBar->SetText(text);
582 _SearchBarImpl::InsertCharacterAt(int index, const Character& character)
586 return __pSearchBar->InsertCharacterAt(index, character);
590 _SearchBarImpl::InsertTextAt(int index, const String& text)
594 return __pSearchBar->InsertTextAt(index, text);
598 _SearchBarImpl::DeleteCharacterAt(int index)
602 return __pSearchBar->DeleteCharacterAt(index);
606 _SearchBarImpl::Clear(void)
610 return __pSearchBar->Clear();
614 _SearchBarImpl::GetTextLength(void) const
618 return __pSearchBar->GetTextLength();
622 _SearchBarImpl::GetText(void) const
626 return __pSearchBar->GetText();
630 _SearchBarImpl::GetText(int start, int end) const
634 return __pSearchBar->GetText(start, end);
638 _SearchBarImpl::GetLimitLength(void) const
642 return __pSearchBar->GetLimitLength();
646 _SearchBarImpl::SetLimitLength(int limitLength)
650 return __pSearchBar->SetLimitLength(limitLength);
654 _SearchBarImpl::ShowKeypad(void) const
658 return __pSearchBar->ShowKeypad();
662 _SearchBarImpl::HideKeypad(void) const
666 return __pSearchBar->HideKeypad();
670 _SearchBarImpl::GetSearchFieldTextSize(void) const
674 return __pSearchBar->GetSearchFieldTextSize();
678 _SearchBarImpl::SetSearchFieldTextSize(int size)
682 return __pSearchBar->SetSearchFieldTextSize(size);
686 _SearchBarImpl::GetBlockRange(int& start, int& end) const
690 return __pSearchBar->GetBlockRange(start, end);
694 _SearchBarImpl::ReleaseBlock(void)
698 return __pSearchBar->ReleaseBlock();
702 _SearchBarImpl::SetBlockRange(int start, int end)
706 int tempTextLength = 0;
708 tempTextLength = __pSearchBar->GetTextLength();
709 SysTryReturnResult(NID_UI_CTRL, tempTextLength > start && tempTextLength > end, E_INVALID_ARG,
710 "Invalid argument(s) is used. tempTextLength(%d),start(%d), end(%d)",
711 tempTextLength, start, end);
713 SysTryReturnResult(NID_UI_CTRL, (start <= end && start >= 0), E_INVALID_ARG,
714 "Invalid argument(s) is used. start(%d), end(%d)", start, end);
716 return __pSearchBar->SetBlockRange(start, end);
720 _SearchBarImpl::RemoveTextBlock(void)
723 result r = __pSearchBar->RemoveTextBlock();
724 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
725 "[E_SYSTEM] A system error has occured. Unable to remove the text block.")
731 _SearchBarImpl::GetColor(void) const
735 return __pSearchBar->GetPropertyColor().ToColor();
739 _SearchBarImpl::GetSearchFieldColor(SearchFieldStatus status) const
743 Variant searchFieldColor;
747 case SEARCH_FIELD_STATUS_NORMAL:
748 searchFieldColor = __pSearchBar->GetPropertySearchFieldNormalColor();
750 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
751 searchFieldColor = __pSearchBar->GetPropertySearchFieldHighlightedColor();
753 case SEARCH_FIELD_STATUS_DISABLED:
754 searchFieldColor = __pSearchBar->GetPropertySearchFieldDisabledColor();
760 return searchFieldColor.ToColor();
764 _SearchBarImpl::GetSearchFieldTextColor(SearchFieldStatus status) const
769 _Edit* pEdit = __pSearchBar->GetSearchField();
774 case SEARCH_FIELD_STATUS_NORMAL:
775 color = pEdit->GetTextColor(EDIT_TEXT_COLOR_NORMAL);
777 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
778 color = pEdit->GetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED);
780 case SEARCH_FIELD_STATUS_DISABLED:
781 color = pEdit->GetTextColor(EDIT_TEXT_COLOR_DISABLED);
791 _SearchBarImpl::SetBackgroundBitmap(const Bitmap& bitmap)
795 return __pSearchBar->SetBackgroundBitmap(bitmap);
799 _SearchBarImpl::SetColor(const Color& color)
805 return __pSearchBar->SetPropertyColor(var);
809 _SearchBarImpl::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
813 result r = E_SUCCESS;
818 case SEARCH_FIELD_STATUS_NORMAL:
819 r = __pSearchBar->SetPropertySearchFieldNormalColor(var);
821 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
822 r = __pSearchBar->SetPropertySearchFieldHighlightedColor(var);
824 case SEARCH_FIELD_STATUS_DISABLED:
825 r = __pSearchBar->SetPropertySearchFieldDisabledColor(var);
835 _SearchBarImpl::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
839 result r = E_SUCCESS;
840 _Edit* pEdit = __pSearchBar->GetSearchField();
845 case SEARCH_FIELD_STATUS_NORMAL:
846 r = pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, color);
848 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
849 r = pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, color);
851 case SEARCH_FIELD_STATUS_DISABLED:
852 r = pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, color);
863 _SearchBarImpl::GetGuideText(void) const
867 return __pSearchBar->GetGuideText();
871 _SearchBarImpl::SetGuideText(const String& guideText)
875 return __pSearchBar->SetGuideText(guideText);
879 _SearchBarImpl::GetGuideTextColor(void) const
883 return __pSearchBar->GetGuideTextColor();
887 _SearchBarImpl::SetGuideTextColor(const Color& color)
891 return __pSearchBar->SetGuideTextColor(color);
895 _SearchBarImpl::GetCursorPosition(void) const
899 return __pSearchBar->GetCursorPosition();
903 _SearchBarImpl::SetCursorPosition(int index)
907 return __pSearchBar->SetCursorPosition(index);
911 _SearchBarImpl::IsLowerCaseModeEnabled(void) const
915 return __pSearchBar->IsLowerCaseModeEnabled();
919 _SearchBarImpl::SetLowerCaseModeEnabled(bool enable)
923 return __pSearchBar->SetLowerCaseModeEnabled(enable);
927 _SearchBarImpl::GetEllipsisPosition(void) const
931 return __pSearchBar->GetEllipsisPosition();
935 _SearchBarImpl::SetEllipsisPosition(EllipsisPosition position)
939 return __pSearchBar->SetEllipsisPosition(position);
943 _SearchBarImpl::GetKeypadAction(void) const
947 CoreKeypadAction coreKeypadAction = __pSearchBar->GetKeypadAction();
948 KeypadAction publicKeypadAction = ConvertKeypadAction(coreKeypadAction);
950 return publicKeypadAction;
954 _SearchBarImpl::IsTextPredictionEnabled(void) const
956 return __pSearchBar->IsTextPredictionEnabled();
960 _SearchBarImpl::SetTextPredictionEnabled(bool enable)
962 return __pSearchBar->SetTextPredictionEnabled(enable);
966 _SearchBarImpl::SetCurrentLanguage(LanguageCode languageCode)
968 return __pSearchBar->SetCurrentLanguage(languageCode);
972 _SearchBarImpl::GetCurrentLanguage(LanguageCode& language) const
974 return __pSearchBar->GetCurrentLanguage(language);
978 _SearchBarImpl::AddActionEventListener(IActionEventListener& listener)
982 SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM,
983 "[E_SYSTEM] A system error has occurred.");
985 result r = __pPublicActionEvent->AddListener(listener);
986 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
987 "A system error has occurred. The same listener instance already exists in the event listener list.");
992 _SearchBarImpl::RemoveActionEventListener(IActionEventListener& listener)
996 SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM,
997 "[E_SYSTEM] A system error has occurred.");
999 result r = __pPublicActionEvent->RemoveListener(listener);
1000 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1001 "A system error has occurred. The specified listener does not exist in the event listener list.");
1006 _SearchBarImpl::AddKeypadEventListener(IKeypadEventListener& listener)
1010 SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM,
1011 "[E_SYSTEM] A system error has occurred.");
1013 result r = __pPublicKeypadEvent->AddListener(listener);
1014 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1015 "A system error has occurred. The same listener instance already exists in the event listener list.");
1022 _SearchBarImpl::RemoveKeypadEventListener(IKeypadEventListener& listener)
1026 SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM,
1027 "[E_SYSTEM] A system error has occurred.");
1029 result r = __pPublicKeypadEvent->RemoveListener(listener);
1030 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1031 "A system error has occurred. The specified listener does not exist in the event listener list.");
1037 _SearchBarImpl::AddTextBlockEventListener(ITextBlockEventListener& listener)
1041 SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM,
1042 "[E_SYSTEM] A system error has occurred.");
1044 result r = __pPublicTextBlockEvent->AddListener(listener);
1045 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1046 "A system error has occurred. The same listener instance already exists in the event listener list.");
1052 _SearchBarImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener)
1056 SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM,
1057 "[E_SYSTEM] A system error has occurred.");
1059 result r = __pPublicTextBlockEvent->RemoveListener(listener);
1060 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1061 "A system error has occurred. The specified listener does not exist in the event listener list.");
1068 _SearchBarImpl::AddTextEventListener(ITextEventListener& listener)
1072 SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM,
1073 "[E_SYSTEM] A system error has occurred.");
1075 result r = __pPublicTextEvent->AddListener(listener);
1076 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1077 "A system error has occurred. The same listener instance already exists in the event listener list.");
1083 _SearchBarImpl::RemoveTextEventListener(ITextEventListener& listener)
1087 SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM,
1088 "[E_SYSTEM] A system error has occurred.");
1090 result r = __pPublicTextEvent->RemoveListener(listener);
1091 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1092 "A system error has occurred. The specified listener does not exist in the event listener list.");
1098 _SearchBarImpl::AddSearchBarEventListener(const ISearchBarEventListener& listener)
1102 SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, E_SYSTEM, E_SYSTEM,
1103 "[E_SYSTEM] A system error has occurred.");
1105 result r = __pPublicSearchBarEvent->AddListener(listener);
1106 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1107 "A system error has occurred. The same listener instance already exists in the event listener list.");
1113 _SearchBarImpl::RemoveSearchBarEventListener(const ISearchBarEventListener& listener)
1117 SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, E_SYSTEM, E_SYSTEM,
1118 "[E_SYSTEM] A system error has occurred.");
1120 result r = __pPublicSearchBarEvent->RemoveListener(listener);
1121 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1122 "A system error has occurred. The specified listener does not exist in the event listener list.");
1128 _SearchBarImpl::AddLanguageEventListener(ILanguageEventListener& listener)
1132 SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use.");
1134 return __pPublicLanguageEvent->AddListener(listener);
1138 _SearchBarImpl::RemoveLanguageEventListener(ILanguageEventListener& listener)
1142 SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use.");
1144 return __pPublicLanguageEvent->RemoveListener(listener);
1148 _SearchBarImpl::OnActionPerformed(const _Control& source, int actionId)
1152 if (__pPublicActionEvent != null)
1154 IEventArg* pEventArg = _PublicActionEvent::CreateActionEventArgN(actionId);
1155 result r = GetLastResult();
1156 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1158 __pPublicActionEvent->Fire(*pEventArg);
1164 _SearchBarImpl::OnKeypadWillOpen(void)
1168 if (__pPublicKeypadEvent != null)
1170 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1171 GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_CREATED);
1172 result r = GetLastResult();
1173 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1175 __pPublicKeypadEvent->Fire(*pEventArg);
1181 _SearchBarImpl::OnKeypadOpened(void)
1185 if (__pPublicKeypadEvent != null)
1187 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1188 GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_OPEN);
1189 result r = GetLastResult();
1190 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1192 __pPublicKeypadEvent->Fire(*pEventArg);
1199 _SearchBarImpl::OnKeypadClosed(void)
1203 if (__pPublicKeypadEvent != null)
1205 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1206 GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_CLOSE);
1207 result r = GetLastResult();
1208 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1210 __pPublicKeypadEvent->Fire(*pEventArg);
1216 _SearchBarImpl::OnKeypadBoundsChanged(void)
1220 if (__pPublicKeypadEvent != null)
1222 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1223 GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1224 result r = GetLastResult();
1225 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1227 __pPublicKeypadEvent->Fire(*pEventArg);
1233 _SearchBarImpl::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1237 if (__pPublicKeypadEvent != null)
1239 KeypadAction publicKeypadAction = ConvertKeypadAction(keypadAction);
1241 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1242 GetPublic(), publicKeypadAction, KEYPAD_EVENT_STATUS_ENTERACTION);
1243 result r = GetLastResult();
1244 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1246 __pPublicKeypadEvent->Fire(*pEventArg);
1252 _SearchBarImpl::OnTextBlockSelected(_Control& source, int start, int end)
1256 if (__pPublicTextBlockEvent != null)
1258 IEventArg* pEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end);
1259 result r = GetLastResult();
1260 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1262 __pPublicTextBlockEvent->Fire(*pEventArg);
1268 _SearchBarImpl::OnTextValueChanged(const _Control& source)
1272 if (__pPublicTextEvent != null)
1274 IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED);
1275 result r = GetLastResult();
1276 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1278 __pPublicTextEvent->Fire(*pEventArg);
1284 _SearchBarImpl::OnTextValueChangeCanceled(const _Control& source)
1288 if (__pPublicTextEvent != null)
1290 IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED);
1291 result r = GetLastResult();
1292 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1294 __pPublicTextEvent->Fire(*pEventArg);
1300 _SearchBarImpl::OnSearchBarModeChanged(_SearchBar& source, SearchBarMode mode)
1304 if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && __pSearchBar != null)
1306 if (mode == SEARCH_BAR_MODE_NORMAL)
1308 __pSearchBar->SetHeaderVisibleState(true);
1312 __pSearchBar->SetHeaderVisibleState(false);
1314 __pSearchBar->SetContentsArea();
1317 if (__pPublicSearchBarEvent != null)
1319 IEventArg* pEventArg = _PublicSearchBarEvent::CreateSearchBarEventArgN(SEARCH_BAR_EVENT_MODE_CHANGE);
1320 result r = GetLastResult();
1321 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1323 __pPublicSearchBarEvent->Fire(*pEventArg);
1329 _SearchBarImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLanguage)
1331 if (__pPublicLanguageEvent)
1333 IEventArg* pKLanguageEventArg = _PublicLanguageEvent::CreateLanguageEventArgN(GetPublic(), oldLanguage, newLanguage);
1334 result r = GetLastResult();
1335 SysTryReturnVoidResult(NID_UI_CTRL, pKLanguageEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1337 __pPublicLanguageEvent->Fire(*pKLanguageEventArg);
1341 SysLog(NID_UI_CTRL, "Event is not created.");
1347 _SearchBarImpl::ConvertKeypadAction(CoreKeypadAction keypadAction) const
1349 KeypadAction publicKeypadAction = KEYPAD_ACTION_SEARCH;
1350 switch (keypadAction)
1352 case CORE_KEYPAD_ACTION_ENTER:
1353 publicKeypadAction = KEYPAD_ACTION_ENTER;
1356 case CORE_KEYPAD_ACTION_GO:
1357 publicKeypadAction = KEYPAD_ACTION_GO;
1360 case CORE_KEYPAD_ACTION_NEXT:
1361 publicKeypadAction = KEYPAD_ACTION_NEXT;
1364 case CORE_KEYPAD_ACTION_SEND:
1365 publicKeypadAction = KEYPAD_ACTION_SEND;
1368 case CORE_KEYPAD_ACTION_SEARCH:
1369 publicKeypadAction = KEYPAD_ACTION_SEARCH;
1372 case CORE_KEYPAD_ACTION_LOGIN:
1373 publicKeypadAction = KEYPAD_ACTION_LOGIN;
1376 case CORE_KEYPAD_ACTION_SIGN_IN:
1377 publicKeypadAction = KEYPAD_ACTION_SIGN_IN;
1380 case CORE_KEYPAD_ACTION_JOIN:
1381 publicKeypadAction = KEYPAD_ACTION_JOIN;
1384 case CORE_KEYPAD_ACTION_DONE:
1385 publicKeypadAction = KEYPAD_ACTION_DONE;
1392 return publicKeypadAction;
1395 class _SearchBarMaker
1396 : public _UiBuilderControlMaker
1399 _SearchBarMaker(_UiBuilder* pUibuilder)
1400 : _UiBuilderControlMaker(pUibuilder){}
1401 virtual ~_SearchBarMaker(void){}
1402 static _UiBuilderControlMaker*
1403 GetInstance(_UiBuilder* pUibuilder)
1405 _SearchBarMaker* pSearchBarMaker = new (std::nothrow) _SearchBarMaker(pUibuilder);
1406 return pSearchBarMaker;
1411 Make(_UiBuilderControl* pControl)
1413 result r = E_SUCCESS;
1416 SearchBar* pSearchBar = null;
1417 _UiBuilderControlLayout* pControlProperty = null;
1418 bool showSearchBarButton = true;
1419 KeypadAction keypadAction = KEYPAD_ACTION_ENTER;
1421 int opacity = SEARCHBAR_DEFAULT_OPACITY;
1422 EllipsisPosition ellipsisPosition = ELLIPSIS_POSITION_END;
1425 int limitLength = SEARCHBAR_TEXT_LENGTH_MAX;
1426 int buttonActionId = -1;
1428 int searchFieldTextSize = 0;
1429 bool lowercaseEnable = false;
1430 String elementString;
1432 GetProperty(pControl, &pControlProperty);
1433 if (pControlProperty == null)
1438 pSearchBar = new (std::nothrow) SearchBar;
1439 if (pSearchBar == null)
1444 rect = pControlProperty->GetRect();
1445 if (pControl->GetElement("showSearchBarButton", elementString))
1447 if (elementString.Equals(L"false", false))
1449 showSearchBarButton = false;
1453 if (pControl->GetElement("keypadAction", elementString))
1455 if (elementString.Equals(L"KEYPAD_ACTION_ENTER", false))
1457 keypadAction = KEYPAD_ACTION_ENTER;
1459 else if (elementString.Equals(L"KEYPAD_ACTION_GO", false))
1461 keypadAction = KEYPAD_ACTION_GO;
1463 else if (elementString.Equals(L"KEYPAD_ACTION_NEXT", false))
1465 keypadAction = KEYPAD_ACTION_NEXT;
1467 else if (elementString.Equals(L"KEYPAD_ACTION_SEND", false))
1469 keypadAction = KEYPAD_ACTION_SEND;
1471 else if (elementString.Equals(L"KEYPAD_ACTION_SEARCH", false))
1473 keypadAction = KEYPAD_ACTION_SEARCH;
1475 else if (elementString.Equals(L"KEYPAD_ACTION_LOGIN", false))
1477 keypadAction = KEYPAD_ACTION_LOGIN;
1479 else if (elementString.Equals(L"KEYPAD_ACTION_SIGN_IN", false))
1481 keypadAction = KEYPAD_ACTION_SIGN_IN;
1483 else if (elementString.Equals(L"KEYPAD_ACTION_JOIN", false))
1485 keypadAction = KEYPAD_ACTION_JOIN;
1487 else if (elementString.Equals(L"KEYPAD_ACTION_DONE", false))
1489 keypadAction = KEYPAD_ACTION_DONE;
1493 r = pSearchBar->Construct(rect, showSearchBarButton, keypadAction);
1500 if (showSearchBarButton)
1502 if (pControl->GetElement("buttonActionId", elementString))
1504 Base::Integer::Parse(elementString, buttonActionId);
1507 if (pControl->GetElement("buttonText", elementString))
1509 r = pSearchBar->SetButton(elementString, buttonActionId);
1513 if (pControl->GetElement("text", elementString))
1515 r = pSearchBar->SetText(elementString);
1518 if (pControl->GetElement("guideText", elementString))
1520 r = pSearchBar->SetGuideText(elementString);
1523 if (pControl->GetElement("searchFieldTextSize", elementString))
1525 Base::Integer::Parse(elementString, searchFieldTextSize);
1526 _ICoordinateSystemTransformer* pTransform = GetTransformer();
1529 searchFieldTextSize = pTransform->Transform(searchFieldTextSize);
1531 r = pSearchBar->SetSearchFieldTextSize(searchFieldTextSize);
1534 if (pControl->GetElement("limitLength", elementString))
1536 Base::Integer::Parse(elementString, limitLength);
1537 r = pSearchBar->SetLimitLength(limitLength);
1540 if (pControl->GetElement("lowerCaseMode", elementString))
1542 if (elementString.Equals(L"true", false))
1544 lowercaseEnable = true;
1548 lowercaseEnable = false;
1551 pSearchBar->SetLowerCaseModeEnabled(lowercaseEnable);
1554 if (pControl->GetElement("ellipsisPosition", elementString))
1556 if (elementString.Equals(L"ELLIPSIS_POSITION_START", false))
1558 ellipsisPosition = ELLIPSIS_POSITION_START;
1560 else if (elementString.Equals(L"ELLIPSIS_POSITION_MIDDLE", false))
1562 ellipsisPosition = ELLIPSIS_POSITION_MIDDLE;
1566 ellipsisPosition = ELLIPSIS_POSITION_END;
1569 r = pSearchBar->SetEllipsisPosition(ellipsisPosition);
1572 if (pControl->GetElement("backgroundBitmapPath", elementString))
1574 Bitmap* pBackgroundBitmap = null;
1575 pBackgroundBitmap = LoadBitmapN(elementString);
1576 if (pBackgroundBitmap != null)
1578 pSearchBar->SetBackgroundBitmap(*pBackgroundBitmap);
1579 delete pBackgroundBitmap;
1583 if (pControl->GetElement("colorOpacity", elementString))
1585 Base::Integer::Parse(elementString, opacity);
1587 if (pControl->GetElement("color", elementString))
1589 ConvertStringToColor32(elementString, opacity, color);
1590 r = pSearchBar->SetColor(color);
1593 opacity = SEARCHBAR_DEFAULT_OPACITY;
1594 if (pControl->GetElement("normalButtonColor", elementString))
1596 ConvertStringToColor32(elementString, opacity, color);
1597 r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_NORMAL, color);
1600 if (pControl->GetElement("normalButtonTextColor", elementString))
1602 ConvertStringToColor32(elementString, opacity, color);
1603 r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_NORMAL, color);
1606 if (pControl->GetElement("normalSearchFieldColor", elementString))
1608 ConvertStringToColor32(elementString, opacity, color);
1609 r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_NORMAL, color);
1612 if (pControl->GetElement("normalSearchFieldTextColor", elementString))
1614 ConvertStringToColor32(elementString, opacity, color);
1615 r = pSearchBar->SetSearchFieldTextColor(SEARCH_FIELD_STATUS_NORMAL, color);
1618 if (pControl->GetElement("disabledButtonColor", elementString))
1620 ConvertStringToColor32(elementString, opacity, color);
1621 r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_DISABLED, color);
1624 if (pControl->GetElement("disabledButtonTextColor", elementString))
1626 ConvertStringToColor32(elementString, opacity, color);
1627 r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_DISABLED, color);
1630 if (pControl->GetElement("disabledSearchFieldColor", elementString))
1632 ConvertStringToColor32(elementString, opacity, color);
1633 r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_DISABLED, color);
1636 if (pControl->GetElement("disabledSearchFieldTextColor", elementString))
1638 ConvertStringToColor32(elementString, opacity, color);
1639 r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_DISABLED, color);
1642 if (pControl->GetElement("highlightedButtonColor", elementString))
1644 ConvertStringToColor32(elementString, opacity, color);
1645 r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, color);
1648 if (pControl->GetElement("highlightedButtonTextColor", elementString))
1650 ConvertStringToColor32(elementString, opacity, color);
1651 r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, color);
1654 if (pControl->GetElement("highlightedSearchFieldColor", elementString))
1656 ConvertStringToColor32(elementString, opacity, color);
1657 r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_HIGHLIGHTED, color);
1660 if (pControl->GetElement("highlightedSearchFieldTextColor", elementString))
1662 ConvertStringToColor32(elementString, opacity, color);
1663 r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_HIGHLIGHTED, color);
1666 if (pControl->GetElement("pressedButtonColor", elementString))
1668 ConvertStringToColor32(elementString, opacity, color);
1669 r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_PRESSED, color);
1672 if (pControl->GetElement("pressedButtonTextColor", elementString))
1674 ConvertStringToColor32(elementString, opacity, color);
1675 r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_PRESSED, color);
1678 if (pControl->GetElement("guideTextColor", elementString))
1680 ConvertStringToColor32(elementString, opacity, color);
1681 r = pSearchBar->SetGuideTextColor(color);
1688 _SearchBarRegister::_SearchBarRegister(void)
1690 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1691 pUiBuilderControlTableManager->RegisterControl(L"SearchBar", _SearchBarMaker::GetInstance);
1694 _SearchBarRegister::~_SearchBarRegister(void)
1696 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1697 pUiBuilderControlTableManager->UnregisterControl(L"SearchBar");
1699 static _SearchBarRegister SearchBarRegisterToUiBuilder;
1700 }}} // Tizen::Ui::Controls